Fix parsing and documentation for json_string_fields (#4656)

This commit is contained in:
Daniel Nelson 2018-09-10 11:55:08 -07:00 committed by GitHub
parent 4ef058c120
commit 1ca17652cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 8 deletions

View File

@ -108,11 +108,11 @@ but can be overridden using the `name_override` config option.
#### JSON Configuration: #### JSON Configuration:
The JSON data format supports specifying "tag_keys", "string_keys", and "json_query". The JSON data format supports specifying "tag_keys", "json_string_fields", and "json_query".
If specified, keys in "tag_keys" and "string_keys" will be searched for in the root-level 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. 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 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 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 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 ## 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 ## 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 ## 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"] tag_keys = ["first"]
## List of field names to extract from JSON and add as string fields ## 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 ## 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 ## the above configuration. If not specified, the whole file will be parsed

View File

@ -1563,11 +1563,11 @@ func buildParser(name string, tbl *ast.Table) (parsers.Parser, error) {
delete(tbl.Fields, "separator") delete(tbl.Fields, "separator")
delete(tbl.Fields, "templates") delete(tbl.Fields, "templates")
delete(tbl.Fields, "tag_keys") 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_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_format")
delete(tbl.Fields, "json_time_key")
delete(tbl.Fields, "data_type") delete(tbl.Fields, "data_type")
delete(tbl.Fields, "collectd_auth_file") delete(tbl.Fields, "collectd_auth_file")
delete(tbl.Fields, "collectd_security_level") delete(tbl.Fields, "collectd_security_level")