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

json_v2 fails if input data contains null values #10358

Closed
igomura opened this issue Dec 30, 2021 · 1 comment
Closed

json_v2 fails if input data contains null values #10358

igomura opened this issue Dec 30, 2021 · 1 comment
Labels
area/redis bug unexpected problem or unintended behavior

Comments

@igomura
Copy link
Contributor

igomura commented Dec 30, 2021

Relevent telegraf.conf

[[inputs.file]]
  files = ["config.json"]
  data_format = "json_v2"

  [[inputs.file.json_v2]]
    measurement_name = "info.config"
    [[inputs.file.json_v2.object]]
      path = "config"

Logs from Telegraf

2021-12-30T21:56:57Z E! [inputs.file] Error in plugin: unknown format '' for field 'storage_redis_caCertificates'

System info

telegraf-1.19.0-0.1.x86_64, CentOS 7

Docker

No response

Steps to reproduce

Input data file:
{ "config": { "apikey": "*", "ipAddressEnabled": true, "initialization": { "timeoutMS": 10000, "forceFreshStartup": false }, "storage": { "type": "redis", "redis": { "host": "localhost", "port": 6379, "tlsServerName": "", "caCertificates": null, "tlsSkipNameValidation": false, "tlsClientCertificate": "", "tlsClientKey": "" } } } }

Expected behavior

parsed data

Actual behavior

the plugin fail to read data when one of json attributes has a value null
In my example this is "caCertificates": null

Additional info

No response

@igomura igomura added the bug unexpected problem or unintended behavior label Dec 30, 2021
@powersj
Copy link
Contributor

powersj commented Jan 4, 2022

This looks like a fix for null in json_v2 parser was in #9368 which did go out in https://github.com/influxdata/telegraf/releases/tag/v1.19.0

Are you sure you are running 1.19.0?

I was unable to reproduce this with master:

❯ ./telegraf --config config.toml 
2022-01-04T16:12:13Z I! Starting Telegraf 1.22.0-aee26768
2022-01-04T16:12:13Z I! Loaded inputs: file
2022-01-04T16:12:13Z I! Loaded aggregators: 
2022-01-04T16:12:13Z I! Loaded processors: 
2022-01-04T16:12:13Z I! Loaded outputs: file
2022-01-04T16:12:13Z I! Tags enabled: host=ryzen
2022-01-04T16:12:13Z I! [agent] Config: Interval:10s, Quiet:false, Hostname:"ryzen", Flush Interval:10s
info.config,host=ryzen apikey="*",ipAddressEnabled=true,initialization_timeoutMS=10000,initialization_forceFreshStartup=false,storage_type="redis",storage_redis_host="localhost",storage_redis_port=6379,storage_redis_tlsServerName="",storage_redis_tlsSkipNameValidation=false,storage_redis_tlsClientCertificate="",storage_redis_tlsClientKey="" 1641312740000000000

So I am going to go ahead and close this as I think getting a newer version of Telegraf is your best bet.

@powersj powersj closed this as completed Jan 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/redis bug unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants