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_query not working in mqtt consumer #6141

Closed
bnjroos opened this issue Jul 19, 2019 · 1 comment
Closed

json_query not working in mqtt consumer #6141

bnjroos opened this issue Jul 19, 2019 · 1 comment
Assignees

Comments

@bnjroos
Copy link

bnjroos commented Jul 19, 2019

Relevant telegraf.conf:

[[inputs.mqtt_consumer]]
  servers = ["tcp://mqtt-broker:1883"]
  qos = 0
  ## Topics to subscribe to
  topics = [
    "meters/#",
  ]

  persistent_session = false
  client_id = ""
  username = ""
  password = ""
  data_format = "json"
  name_override = "energy"
  tag_keys = ["meter"]
  taginclude = ["meter"]
  json_query = "meters"

System info:

Ubuntu telegraf 1.11

Steps to reproduce:

Writting to topic "meters/DB1" the following payload:
'{"meters":[{"meter":"PPAC3_1In","E":144.1158}],"date":"2019-07-19-14:57:54"}'

Expected behavior:

The parser is parsing the subquery:
[{"meter":"PPAC3_1In","E":144.1158}]

Actual behavior:

Getting the following error from Telegraf:
E! [inputs.mqtt_consumer]: Error in plugin: E! Query path must lead to a JSON object or array of objects, but lead to: Null

@danielnelson danielnelson self-assigned this Jul 19, 2019
@danielnelson
Copy link
Contributor

@bnjroos I'm not able to replicate, when I send a message with:

mosquitto_pub -t 'telegraf' -m '{"meters":[{"meter":"PPAC3_1In","E":144.1158}],"date":"2019-07-19-14:57:54"}'

Telegraf produces a metric like:

energy,meter=PPAC3_1In E=144.1158 1563839040675979568

I'm testing with Telegraf 1.11.2 and I don't see this error, but this code does have an upcoming modification for 1.11.3 (#6125). Can you retest with 1.11.2 and the command above and let me know if you still see the error?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants