Collect OPC-UA Data using Telegraf into QuestDB in a dense format

I am collecting OPC UA data with Telegraf using the OPC-UA plugin. All is good and works as expected. I can read data from my server and I can see the data into QuestDB. However, since Telegraf is getting each different metric as a different row, I end up with a sparse dataset in which for each row I have only the timestamp, the tags, and the value for one column, even when the metrics in such columns are from the same exact timestamp.

Any pointers?

This my working telegraf.conf file

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>[agent]
omit_hostname = true
[[inputs.opcua]]
endpoint = "${OPCUA_ENDPOINT}"
connect_timeout = "30s"
request_timeout = "30s"
security_policy = "None"
security_mode = "None"
auth_method = "Anonymous"
name_override = "${METRICS_TABLE_NAME}" # Common measurement name for all metrics
[[inputs.opcua.nodes]]
name = "ServerLoad"
namespace = "2"
identifier_type = "s"
identifier = "Server/Load"
[[inputs.opcua.nodes]]
name = "ServerRAM"
namespace = "2"
identifier_type = "s"
identifier = "Server/RAM"
[[inputs.opcua.nodes]]
name = "ServerIO"
namespace = "2"
identifier_type = "s"
identifier = "Server/IO"
[[outputs.influxdb_v2]]
urls = ["${QUESTDB_HTTP_ENDPOINT}"]
token = "${QUESTDB_HTTP_TOKEN}"
content_encoding = "identity" # Important to ensuring no gzip encoding
</code>
<code>[agent] omit_hostname = true [[inputs.opcua]] endpoint = "${OPCUA_ENDPOINT}" connect_timeout = "30s" request_timeout = "30s" security_policy = "None" security_mode = "None" auth_method = "Anonymous" name_override = "${METRICS_TABLE_NAME}" # Common measurement name for all metrics [[inputs.opcua.nodes]] name = "ServerLoad" namespace = "2" identifier_type = "s" identifier = "Server/Load" [[inputs.opcua.nodes]] name = "ServerRAM" namespace = "2" identifier_type = "s" identifier = "Server/RAM" [[inputs.opcua.nodes]] name = "ServerIO" namespace = "2" identifier_type = "s" identifier = "Server/IO" [[outputs.influxdb_v2]] urls = ["${QUESTDB_HTTP_ENDPOINT}"] token = "${QUESTDB_HTTP_TOKEN}" content_encoding = "identity" # Important to ensuring no gzip encoding </code>
[agent]
  omit_hostname = true  

[[inputs.opcua]]
  endpoint = "${OPCUA_ENDPOINT}"
  connect_timeout = "30s"
  request_timeout = "30s"
  security_policy = "None"
  security_mode = "None"
  auth_method = "Anonymous"
  name_override = "${METRICS_TABLE_NAME}"  # Common measurement name for all metrics

  [[inputs.opcua.nodes]]
    name = "ServerLoad"
    namespace = "2"
    identifier_type = "s"
    identifier = "Server/Load"
   
  [[inputs.opcua.nodes]]
    name = "ServerRAM"
    namespace = "2"
    identifier_type = "s"
    identifier = "Server/RAM"
   

  [[inputs.opcua.nodes]]
    name = "ServerIO"
    namespace = "2"
    identifier_type = "s"
    identifier = "Server/IO"
 

[[outputs.influxdb_v2]]
  urls = ["${QUESTDB_HTTP_ENDPOINT}"]
  token = "${QUESTDB_HTTP_TOKEN}"
  content_encoding = "identity"  # Important to ensuring no gzip encoding
 

In Telegraf you can merge your metrics into one if the timestamp for the metrics is the same and all the tags match by using an aggregator. I don’t know if your metrics have any common tags, but if not, you can add an extra tag to each of them. The name of the tag is not important.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code> [[inputs.opcua.nodes]]
name = "ServerLoad"
namespace = "2"
identifier_type = "s"
identifier = "Server/Load"
default_tags = { source="opcua_merge" }
[[inputs.opcua.nodes]]
name = "ServerRAM"
namespace = "2"
identifier_type = "s"
identifier = "Server/RAM"
default_tags = { source="opcua_merge" }
[[inputs.opcua.nodes]]
name = "ServerIO"
namespace = "2"
identifier_type = "s"
identifier = "Server/IO"
default_tags = { source="opcua_merge" }
</code>
<code> [[inputs.opcua.nodes]] name = "ServerLoad" namespace = "2" identifier_type = "s" identifier = "Server/Load" default_tags = { source="opcua_merge" } [[inputs.opcua.nodes]] name = "ServerRAM" namespace = "2" identifier_type = "s" identifier = "Server/RAM" default_tags = { source="opcua_merge" } [[inputs.opcua.nodes]] name = "ServerIO" namespace = "2" identifier_type = "s" identifier = "Server/IO" default_tags = { source="opcua_merge" } </code>
  [[inputs.opcua.nodes]]
    name = "ServerLoad"
    namespace = "2"
    identifier_type = "s"
    identifier = "Server/Load"
    default_tags = { source="opcua_merge" }

  [[inputs.opcua.nodes]]
    name = "ServerRAM"
    namespace = "2"
    identifier_type = "s"
    identifier = "Server/RAM"
    default_tags = { source="opcua_merge" }

  [[inputs.opcua.nodes]]
    name = "ServerIO"
    namespace = "2"
    identifier_type = "s"
    identifier = "Server/IO"
    default_tags = { source="opcua_merge" }

And now, before the output section you can add the merge definition

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>[[aggregators.merge]]
drop_original = true
tags = ["source"] # Merge metrics with the same value for the source tag
</code>
<code>[[aggregators.merge]] drop_original = true tags = ["source"] # Merge metrics with the same value for the source tag </code>
[[aggregators.merge]]
  drop_original = true
  tags = ["source"]  # Merge metrics with the same value for the source tag

In this case, since we are adding the same value for the source tag, as long as the timestamp is the same they will merge. For this to work, you need to make sure you don’t have any other tags with different values in each metric. If you have other tags and they can have different values but you still want to merge, you could either convert from tags to strings using the telegraf converter processor, or just drop the tags if you don’t need them using the override.tags processor, as in:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>[[processors.override]]
[processors.override.tags]
id = "" # Removing the 'id' tag
</code>
<code>[[processors.override]] [processors.override.tags] id = "" # Removing the 'id' tag </code>
[[processors.override]]
  [processors.override.tags]
    id = ""  # Removing the 'id' tag

You could also drop the source tag if you don’t want it on the final table using the same processor.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật