diff --git a/plugins/parsers/json_v2/parser.go b/plugins/parsers/json_v2/parser.go index e586b35ebddc2..d013f6b35e24f 100644 --- a/plugins/parsers/json_v2/parser.go +++ b/plugins/parsers/json_v2/parser.go @@ -484,6 +484,8 @@ func (p *Parser) isIncluded(key string, val gjson.Result) bool { if len(p.currentSettings.IncludedKeys) == 0 { return true } + // automatically adds tags to included_keys so it does NOT have to be repeated in the config + p.currentSettings.IncludedKeys = append(p.currentSettings.IncludedKeys, p.currentSettings.Tags...) for _, i := range p.currentSettings.IncludedKeys { if i == key { return true diff --git a/plugins/parsers/json_v2/testdata/nested_and_nonnested_tags/telegraf.conf b/plugins/parsers/json_v2/testdata/nested_and_nonnested_tags/telegraf.conf index 45692dc5df0e2..e1748b463690b 100644 --- a/plugins/parsers/json_v2/testdata/nested_and_nonnested_tags/telegraf.conf +++ b/plugins/parsers/json_v2/testdata/nested_and_nonnested_tags/telegraf.conf @@ -9,10 +9,8 @@ data_format = "json_v2" disable_prepend_keys = true path = "@this" included_keys = [ - "hostname", "systemVoltage", "systemCurrent", "tables", - "tables_outputname", ] tags = ["hostname", "tables_outputname"] diff --git a/plugins/parsers/json_v2/testdata/object/telegraf.conf b/plugins/parsers/json_v2/testdata/object/telegraf.conf index 6ad244fd71418..50ed245a3cf00 100644 --- a/plugins/parsers/json_v2/testdata/object/telegraf.conf +++ b/plugins/parsers/json_v2/testdata/object/telegraf.conf @@ -6,7 +6,7 @@ [[inputs.file.json_v2.object]] path = "root.station" disable_prepend_keys = true - included_keys = ["name", "etd_destination", "etd_estimate_minutes"] + included_keys = ["etd_estimate_minutes"] tags = ["name", "etd_destination"] [inputs.file.json_v2.object.fields] etd_estimate_minutes = "int"