Different time interval for each telegraf input

Hi,

We are trying to send data to Influx2.0 using opcua group plugin in the telegraf file, but is it possible to send data of each opcua group in different time interval? How can I do this?

1 Like

Hi, if you split each group up into a separate inputs config section, you can set a different interval for each section.

Ok, but I think I can set interval only under [agent]. Can I set different intervals under [[inputs.opcua.groupA]] & [[inputs.opcua.groupB]] ?

Hi @Aritra666B,
Yes, you can here is an example:

# Configuration for telegraf agent
[agent]
  interval = "5s"
  round_interval = true
  metric_batch_size = 1000
  metric_buffer_limit = 10000

  collection_jitter = "5s"
  flush_interval = "10s"
  flush_jitter = "5s"

  precision = ""
  hostname = ""
  omit_hostname = false


###############################################################################
#                            INPUT PLUGINS                                    #
###############################################################################
[[inputs.opcua]]
  interval = "10s"
  name = "groupA"
  endpoint = "opc.tcp://localhost:49330"
  security_policy = "auto"
   security_mode = "auto"
   certificate = ""
   private_key = ""
  
   auth_method = "UserName"
   username = "Administrator"
   password = "serverserverserver"

   nodes = [
    {name="Tag1", namespace="2", identifier_type="s", identifier="Channel1.Device1.Tag1"},
    {name="Tag2", namespace="2", identifier_type="s", identifier="Channel1.Device1.Tag2"},
  ]

[[inputs.opcua]]
  interval = "60s"
  name = "groupB"
  endpoint = "opc.tcp://localhost:49330"
  security_policy = "auto"
   security_mode = "auto"
   certificate = ""
   private_key = ""
  
   auth_method = "UserName"
   username = "Administrator"
   password = "serverserverserver"

   nodes = [
    {name="Tag1", namespace="2", identifier_type="s", identifier="Channel1.Device1.Tag1"},
    {name="Tag2", namespace="2", identifier_type="s", identifier="Channel1.Device1.Tag2"},
  ]


The interval specified within the input plugin overrules the global interval.

1 Like

Thanks. It worked perfectly.

1 Like

Awesome! Glad its up and running :slight_smile:

Hey Jay,

I have a related question.I have set telegraf up with multiple config files in the telegraf.d directory and an Agent configuration file in the root directory. Each config in the telegraf.d directory has a different collection interval ranging from 30s to 10 min, I’m wondering what would be the best option for configuring the flush_interval in the agent config? Can I override the agent level flush_interval in each config file or just set the flush interval to the greatest collection interval. According to telegraf documentation the flush_interval shouldn’t be set lower then the collection interval. Any help would be greatly appreciated.

Flush interval is a setting for the output plugin, not something you can set any input level.

It really depends on your situation how fast you want the metrics being sent after collection.

I get that. What I’m trying to do is set up grafana live with the 30s data, ideally the flush interval would be 30 seconds, so the data is being written right away. The problem is, is that I’m also writing data to influx using the same agent and some of the input configs have collection intervals greater then the 30 second requirement. According to the influx documentation your flush_interval shouldn’t be less then your collection interval, so I’m wondering what the best course of action would be?

Hi @blharvey,
So I believe what @Hipska was explaining is you can set the flush interval as a specific option for each output plugin: telegraf/CONFIGURATION.md at master · influxdata/telegraf · GitHub

This overrides the primary agent’s default flush time. So for your Grafana output plugin you can specify:

[[outputs.file]]
  files = [ "stdout" ]
  flush_interval = "1s"
2 Likes

Perfect, thanks Jay.

For grafana live, do you use the web socket output?

Splitting the same opcua input plugin creates a different TCP connection for each “split”. Working with embedded devices and high speed acquisition is troublesome. Is there a possibility to have different intervals in the same opcua input? I tried adding interval in different places like [[inputs.opcua.group]] or [[inputs.opcua.nodes]] but didn’t work. Am I doing it wrong or it’s not possible… yet.

Hi @alxgan,
We have a new OPC UA plugin: telegraf/plugins/inputs/opcua_listener at master · influxdata/telegraf · GitHub

This introduces node subscriptions which means you no longer have to rely on the telegraf interval to pull changes in the node value. It is currently not part of the official release yet but you can download and try it via one of the nightly builds: telegraf/NIGHTLIES.md at master · influxdata/telegraf · GitHub

I would suggest making one plugin per device.

Thank you @Jay_Clifford .
I’ve seen the code there and I will try it out on two industrial devices with opc ua server, hopefully this resolves “onchange” update for other projects. Anyway this does not resolve the monitoring/collecting at different intervals. I was thinking more in terms as:

nodes = [
{name=“pressure”, namespace=“1”, identifier_type=“i”, identifier=“3”, interval=200ms},
{name=“temperature”, namespace=“1”, identifier_type=“i”, identifier=“4”, interval=5s},
]

@alxgan this is not how Telegraf works and would require an enormous change to core-code. In Telegraf the gather cycles are per plugin. I still don’t see why you cannot separate out into multiple plugin instances, but if this is really the case, my way forward would be to set the interval to the shortest value and then subsample the values having longer periods using e.g. the final processor and metric filtering.

1 Like

Dear @srebhan I work with Telegraf with opcua input and influx2 output for about one year. I use them in my industrial machines for monitoring and fault prediction. I have around 20 to 30 signals where half of them are 250ms…500ms and security_mode is “SignAndEncrypt”. I use so far the workaround with more inputs tables and group them based on interval, also with processor and filtering (it’s a pain) but more connections with SignAndEncrypt takes a toll on a limited computing resource device.
To answer your question, about the need, is that in industrial/embedded devices you have limited computing resources. With at top PLC my current configuration warns me about communications resources and the actual process’s real-time communication (2 to 4ms) has to “suffer”.
I see that IIoT and Edge advances so maybe a v2 telegraf is needed. :face_with_hand_over_mouth:

Hi @alxgan, this is why I am curious the OPC UA listener will not fit your needs? It removes the need for defining a collection interval. Is it due to the fact you only want to sample at a given time rather than waiting for your node values to change?