I am interested in collecting data from an OPC UA server and ingesting it into Postgresql via Telegraf. I have had some success in that I can input the data from an OPC server and ingest it into Postgresql in a wide format with each tag having its own column. Thus, I end up with thousands of columns and many null values. What I need to do is to log the data in a narrow format so I would have something like: TagID, Time, quality and a single value column. Currently, I have a Tag lookup but struggling to store the values in a narrow format. See the attached screenshot
. My telegraf.conf file is:
[[inputs.opcua]]
endpoint = "opc.tcp://WS2019:49310"
security_policy = "None"
security_mode = "None"
nodes = [
{name = "M1039_Flow", namespace="2", identifier_type="s", identifier="Simulator.Pumps.M1039_Flow"},
{name = "M1039_Power", namespace="2", identifier_type="s", identifier="Simulator.Pumps.M1039_Power"}
]
[[outputs.postgresql]]
connection = "host=172.16.13.24 user=myUser password=myPassword dbname=timescaledb sslmode=disable"
schema = "public"
# Enable this to store tags in a separate table with foreign keys
tags_as_foreign_keys = true
# Optional: You can customize the suffix for the tag table name
tag_table_suffix = "_tags"
timestamp_column_name = "time"
create_templates = [
'''CREATE TABLE {{ .table }} ({{ .columns }})''',
]
Any guidance would be very much appreciated. Thanks.