Relevent telegraf.conf
[agent]
interval = "1s"
flush_interval = "1s"
[[inputs.file]]
files = ["./foo.json"]
data_format = "value"
data_type = "string"
[[processors.parser]]
parse_fields = ["value"]
data_format = "json_v2"
[[processors.parser.json_v2]]
[[processors.parser.json_v2.object]]
path = "@this"
timestamp_key = "time"
timestamp_format = "2006-01-02T15:04:05"
timestamp_timezone = "Local"
disable_prepend_keys = true
[[processors.parser.json_v2.object.field]]
path = "test"
type = "uint"
[[outputs.file]]
files = ["stdout"]
data_format = "influx"
Logs from Telegraf
2022-01-02T22:08:47Z I! Starting Telegraf 1.21.1
2022-01-02T22:08:47Z E! [telegraf] Error running agent: Error loading config file telegraf.conf: plugin processors.parser: line 14: configuration specified the fields ["object"], but they weren't used
System info
Telegraf 1.21.1 (git: HEAD 7c9a9c1) (both on Debian 11 and Ubuntu 20.04, amd64); installed via Debian package downloaded from Github Releases page
Docker
not applicable
Steps to reproduce
- Place a file
foo.json into working directory with content e.g. {"time": "2022-01-01T21:57:10", "test": 123}
- Start telegraf with
telegraf --config telegraf.conf with the config from above
- Error message is shown
Expected behavior
Telegraf should print the one metric from the JSON file to stdout in influx format every second.
Actual behavior
Telegraf exits with an error because of invalid config.
It seems it doesn't recognize that the object section must be handed to the json_v2 parser or something.
Additional info
- When I use
data_format = "json_v2" in the input.file section and place the same config there, data is parsed correctly, so I think the json_v2 config should be OK
- If I replace the
data_format in the processors.parser section with influx, remove the additional json_v2 config and place an influx-formatted metric into the input file, then it also works
- I'm not 100% sure if the way I specified the config for the json_v2 parser is correct for
processors.parser. I didn't find any example. If this is a user error on my part it would at least be good to add a correct example to the processors.parser Readme
Relevent telegraf.conf
Logs from Telegraf
System info
Telegraf 1.21.1 (git: HEAD 7c9a9c1) (both on Debian 11 and Ubuntu 20.04, amd64); installed via Debian package downloaded from Github Releases page
Docker
not applicable
Steps to reproduce
foo.jsoninto working directory with content e.g.{"time": "2022-01-01T21:57:10", "test": 123}telegraf --config telegraf.confwith the config from aboveExpected behavior
Telegraf should print the one metric from the JSON file to stdout in influx format every second.
Actual behavior
Telegraf exits with an error because of invalid config.
It seems it doesn't recognize that the
objectsection must be handed to the json_v2 parser or something.Additional info
data_format = "json_v2"in theinput.filesection and place the same config there, data is parsed correctly, so I think the json_v2 config should be OKdata_formatin theprocessors.parsersection withinflux, remove the additionaljson_v2config and place an influx-formatted metric into the input file, then it also worksprocessors.parser. I didn't find any example. If this is a user error on my part it would at least be good to add a correct example to theprocessors.parserReadme