Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(parser/json): continue parsing JSON after invalid object in array, with an option of strict to enforce validity of all objects #6536

Merged
merged 1 commit into from
Oct 23, 2019

Conversation

rawkode
Copy link
Contributor

@rawkode rawkode commented Oct 17, 2019

closes #6532

Required for all PRs:

  • Signed CLA.
  • Associated README.md updated.
  • Has appropriate unit tests.

@rawkode
Copy link
Contributor Author

rawkode commented Oct 17, 2019

Closes #6532

plugins/parsers/json/README.md Show resolved Hide resolved
@@ -73,7 +76,14 @@ func (p *Parser) parseArray(data []interface{}) ([]telegraf.Metric, error) {
case map[string]interface{}:
metrics, err := p.parseObject(v)
if err != nil {
return nil, err
log.Printf("E! [parsers.json] Invalid JSON object: %v", v)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this log message since we are returning the error.

plugins/parsers/json/parser.go Outdated Show resolved Hide resolved
plugins/parsers/json/parser_test.go Outdated Show resolved Hide resolved
@danielnelson danielnelson added this to the 1.13.0 milestone Oct 21, 2019
@danielnelson danielnelson added the feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin label Oct 21, 2019
…y, with an option of strict to enforce validity of all objects
@rawkode rawkode requested a review from danielnelson October 22, 2019 11:21
@danielnelson danielnelson merged commit a9a0d40 into influxdata:master Oct 23, 2019
@rawkode rawkode deleted the feature/allow-continue-invalid-json-objects branch October 23, 2019 21:15
@VitaliyBreslavskyi
Copy link

Hi @rawkode,

Could it be that there is some error in this feature or description?

I'm getting weird error when trying to use example configuration for JSON:
telegraf_1 | 2020-01-15T13:28:05Z I! Starting Telegraf 1.13.0
telegraf_1 | 2020-01-15T13:28:05Z I! Using config file: /etc/telegraf/telegraf.conf
telegraf_1 | 2020-01-15T13:28:05Z E! [telegraf] Error running agent: Error parsing /etc/telegraf/telegraf.d/input_json.conf, line 37: field corresponding to `json_strict' is not defined in file.File

@rawkode
Copy link
Contributor Author

rawkode commented Jan 15, 2020

@VitaliyBreslavskyi Can you open a new issue and provide your configuration file, please?

Thanks

@VitaliyBreslavskyi
Copy link

@VitaliyBreslavskyi Can you open a new issue and provide your configuration file, please?

Thanks

Sure, in progress...

athoune pushed a commit to bearstech/telegraf that referenced this pull request Apr 17, 2020
idohalevi pushed a commit to idohalevi/telegraf that referenced this pull request Sep 29, 2020
arstercz pushed a commit to arstercz/telegraf that referenced this pull request Mar 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JSON parser: how to handle data with missing time keys
3 participants