From 1ca17652cda94b731473e52315a311653f3a200b Mon Sep 17 00:00:00 2001 From: Daniel Nelson Date: Mon, 10 Sep 2018 11:55:08 -0700 Subject: [PATCH] Fix parsing and documentation for json_string_fields (#4656) --- docs/DATA_FORMATS_INPUT.md | 10 +++++----- internal/config/config.go | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/DATA_FORMATS_INPUT.md b/docs/DATA_FORMATS_INPUT.md index 235e3b308..e0358e95c 100644 --- a/docs/DATA_FORMATS_INPUT.md +++ b/docs/DATA_FORMATS_INPUT.md @@ -108,11 +108,11 @@ but can be overridden using the `name_override` config option. #### JSON Configuration: -The JSON data format supports specifying "tag_keys", "string_keys", and "json_query". -If specified, keys in "tag_keys" and "string_keys" will be searched for in the root-level +The JSON data format supports specifying "tag_keys", "json_string_fields", and "json_query". +If specified, keys in "tag_keys" and "json_string_fields" will be searched for in the root-level and any nested lists of the JSON blob. All int and float values are added to fields by default. If the key(s) exist, they will be applied as tags or fields to the Telegraf metrics. -If "string_keys" is specified, the string will be added as a field. +If "json_string_fields" is specified, the string will be added as a field. The "json_query" configuration is a gjson path to an JSON object or list of JSON objects. If this path leads to an array of values or @@ -225,7 +225,7 @@ For example, if the following configuration: ] ## List of field names to extract from JSON and add as string fields - # string_fields = [] + # json_string_fields = [] ## gjson query path to specify a specific chunk of JSON to be parsed with ## the above configuration. If not specified, the whole file will be parsed @@ -293,7 +293,7 @@ For example, with the following config: tag_keys = ["first"] ## List of field names to extract from JSON and add as string fields - string_fields = ["last"] + json_string_fields = ["last"] ## gjson query path to specify a specific chunk of JSON to be parsed with ## the above configuration. If not specified, the whole file will be parsed diff --git a/internal/config/config.go b/internal/config/config.go index c712af85e..e10a5fc4c 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -1563,11 +1563,11 @@ func buildParser(name string, tbl *ast.Table) (parsers.Parser, error) { delete(tbl.Fields, "separator") delete(tbl.Fields, "templates") delete(tbl.Fields, "tag_keys") - delete(tbl.Fields, "string_fields") - delete(tbl.Fields, "json_query") delete(tbl.Fields, "json_name_key") - delete(tbl.Fields, "json_time_key") + delete(tbl.Fields, "json_query") + delete(tbl.Fields, "json_string_fields") delete(tbl.Fields, "json_time_format") + delete(tbl.Fields, "json_time_key") delete(tbl.Fields, "data_type") delete(tbl.Fields, "collectd_auth_file") delete(tbl.Fields, "collectd_security_level")