Framework to compose e.g. telegraf.conf from snippets?

Hi,

I am searching for some framework, where I have e.g. telegraf.conf snippets and would like to create hardware/board/container-specific telegraf.conf files out of those.
I guess I could create my own .conf parser and add the snippets, but also I guess I am not the only person on this planet who has this problem.

I figured out that I can load telegraf.conf either from a file or from some web server or git repo with web interface, but it’s a bit annoying to update each and every telegraf.conf file manually when I want a change.

How do you normally do something like that?

Are there tools you would recommend for this job?

Regards,

Robert

Hello @ReliableEmbeddedSys,
I don’t know if I have a good solution for you of the top of my head. That being said I just want to double check that you’re aware of the following tools/commands:

Run telegraf, enabling specific plugins:

telegraf --config telegraf.conf --input-filter cpu:mem --output-filter influxdb

Run telegraf with env var

[agent]
    interval = "${env var}"

Finally this presentation is really good to learn all about telegraf and helpful hints and tools you might not be aware of

@ReliableEmbeddedSys,
I am sharing your question with the telegraf team though and I hope they can provide you with a better solution.

Thanks for the answer.

The use case is slightly different.

Take a telegraf.conf file and cut it in small pieces (some of them host specific, others are reused on various hosts) and reassemble them to a telegraf.conf file.

I saw that I can load the config from some web server as well and could probably compose the configs somehow on the server side.

I am just wondering how people usually do that, since I guess also others will reuse parts of their telegraf.conf files on various machines.

I’m not quite sure yet how your deployment path looks like.
Basically the following ideas would come to my mind:

  • Use a DevOps tool, these usually bring powerful template engines with them. I would use Ansible, which works under the hood with the jinja2 engine, since it is written in Python. But other tools like Chef, Puppet etc. work as well.
  • Write your own config generator script that uses the jinja2 template engine for example. Or a template engine in a programming language of your choice. Or use the sed/awk tools for this.
1 Like