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 not able parse the json array #15940

Open
thrinathadevops opened this issue Sep 26, 2024 · 0 comments
Open

Json_v2 not able parse the json array #15940

thrinathadevops opened this issue Sep 26, 2024 · 0 comments
Labels
bug unexpected problem or unintended behavior

Comments

@thrinathadevops
Copy link

thrinathadevops commented Sep 26, 2024

Relevant telegraf.conf

I am using v1.21 
I am getting the data from NATS server and pusing data to influxdb using telegraf Below is my config. 

[[inputs.nats_consumer]]
  servers = ["nats://localhost:4222"]
  subjects = ["nats.subject.requestsraw"]
  data_format = "json_v2"
  name_override = "requestsRaw"
  json_time_key = ""
  json_time_format = ""

  # Handling first type of JSON object (requestsRaw)
  [[inputs.nats_consumer.json_v2]]
  [[inputs.nats_consumer.json_v2.object]]
    path = "@this"
    disable_prepend_keys = true
    tags = ["runId", "testName", "nodeName", "ObjectType","errorMessage","errorResponseBody","requestName","responseCode","result","samplerType"]

    # Field mappings (convert fields to correct types)
    [inputs.nats_consumer.json_v2.object.fields]
      connectTime = "integer"
      count = "integer"
      errorCount = "integer"
      latency = "integer"
      processingTime = "integer"
      receivedBytes = "integer"
      sentBytes = "integer"
below is my json file.
 [{"runId":"R_20240924-1249","testName":"Test","nodeName":"Test-Node","errorMessage":"noData","errorResponseBody":"noData","requestName":"WebSocket request-response Sampler","responseCode":"200","result":"pass","samplerType":"transaction","connectTime":0,"count":1,"errorCount":0,"latency":0,"processingTime":0,"receivedBytes":59275,"sentBytes":1467,"responseTime":2,"timeStamp":1727162557148,"time":1727162557159000000,"ObjectType":"requestsRaw"}, 
{"runId":"R_20240924-1249","testName":"Test","nodeName":"Test-Node","errorMessage":"noData","errorResponseBody":"noData","requestName":"WebSocket request-response Sampler","responseCode":"200","result":"pass","samplerType":"transaction","connectTime":0,"count":1,"errorCount":0,"latency":0,"processingTime":0,"receivedBytes":59275,"sentBytes":1467,"responseTime":1,"timeStamp":1727162557150,"time":1727162557159000000,"ObjectType":"requestsRaw"}, 
{"runId":"R_20240924-1249","testName":"Test","nodeName":"Test-Node","errorMessage":"noData","errorResponseBody":"noData","requestName":"WebSocket request-response Sampler","responseCode":"200","result":"pass","samplerType":"transaction","connectTime":0,"count":1,"errorCount":0,"latency":0,"processingTime":0,"receivedBytes":59275,"sentBytes":1467,"responseTime":1,"timeStamp":1727162557150,"time":1727162557159000000,"ObjectType":"requestsRaw"}]

Logs from Telegraf

jmeterusr@server-3:/etc/telegraf$ sudo journalctl -u telegraf.service -f
Sep 26 10:27:52 server-3 telegraf[152497]: 2024-09-26T10:27:52Z D! [outputs.influxdb_v2] Buffer fullness: 0 / 10000 metrics
Sep 26 10:28:02 server-3 telegraf[152497]: 2024-09-26T10:28:02Z D! [outputs.influxdb_v2] Buffer fullness: 0 / 10000 metrics
Sep 26 10:28:12 server-3 telegraf[152497]: 2024-09-26T10:28:12Z D! [outputs.influxdb_v2] Buffer fullness: 0 / 10000 metrics
Sep 26 10:28:22 server-3 telegraf[152497]: 2024-09-26T10:28:22Z D! [outputs.influxdb_v2] Buffer fullness: 0 / 10000 metrics
Sep 26 10:28:32 server-3 telegraf[152497]: 2024-09-26T10:28:32Z D! [outputs.influxdb_v2] Buffer fullness: 0 / 10000 metrics

System info

Telegraf 1.21

Docker

No response

Steps to reproduce

install the nats and pass data through natsserver

Expected behavior

It is expected read all messages inside the array

Actual behavior

it is reading array as a single message

Additional info

No response

@thrinathadevops thrinathadevops added the bug unexpected problem or unintended behavior label Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

1 participant