Default field values in telegraf

I was looking for a way in which I could add/introduce a default field from telegraf. I looked into processors and saw that it is possible to modify tags but not fields. Is there any way around this? Maybe through the parsers?

Can you provide some examples:

  1. What it does currently / by default
  2. What you would prefer it to do

The intend is that the output of an executable using the exec command. However, this particular field is not generated by the executable and hence we need to add a placeholder field before sending from telegraf to influx.

Sorry I meant the actual line protocol output.

Can you clarify why you need it as a field? What is the concern if it was inserted as a tag, given the plugins can do that now ?

The output line protocol is influx line
the input would be a json string that is is the stdout from a binary application that is run with exec plugin.
This json string would not contain the field. so I’d like to inject a field with a constant value. This value would always be “1”. Always. You can tell like status

Hmm, I’m still not clear why you need it that way.

If you’re open to it, since you said it will always be the same value, you could insert that field in a task once it’s inside influxdb

Awesom, found 2 plugins in processors to serve the need

  1. defaults: Fills the field with a default value.
  2. enum: Can map filed values to another.

Opted for “enum” as it serves the need with some scope of additional capabilities :slight_smile:

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.