# The exec input of telegraf can not parse json data which is array

**URL:** <https://community.influxdata.com/t/the-exec-input-of-telegraf-can-not-parse-json-data-which-is-array/10637>\
**Category:** Telegraf\
**Tags:** telegraf\
**Created:** [July 23, 2019, 9:01am UTC](https://community.influxdata.com/t/the-exec-input-of-telegraf-can-not-parse-json-data-which-is-array/10637 "2019-07-23T09:01:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![michaelpassion](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/michaelpassion/32/3354_2.png) [@michaelpassion](https://community.influxdata.com/u/michaelpassion)\
**Post date:** [July 23, 2019, 9:01am UTC](https://community.influxdata.com/t/the-exec-input-of-telegraf-can-not-parse-json-data-which-is-array/10637/1 "2019-07-23T09:01:06Z")

</div>

My anget version is Telegraf 1.11.2 and config file likes below

```auto
[agent]
  interval="1s"
  flush_interval="1s"

[[inputs.exec]]
  commands = ["zbs-meta -f json chunk list"]
  data_format = "json"
[[outputs.file]]
  files = ["stdout"]
  data_format = "json"

```

when I type the command in terminal it generate data like this (it is json data):

```auto
[{"Status": "CONNECTED_HEALTHY", "Name": "497c6f82-7cbd-445d-9776-ac80dbbc1740", "Zone": "0", "Provisioned Space": "5.16 TB", "IP": "10.64.38.3", "Total Disk Space": "13.70 TB", "Used Cache Space": "1.41 TB", "Port": "10200", "Used Disk Space": "3.65 TB", "Registerred Date": "2017-01-21 10:57:25", "IPMI": "", "Brick": "0", "Total Cache Space": "1.62 TB", "ID": "1"}, {"Status": "CONNECTED_HEALTHY", "Name": "f1424256-7150-415a-85f5-2731aa6e07ec", "Zone": "0", "Provisioned Space": "5.16 TB", "IP": "10.64.38.2", "Total Disk Space": "13.70 TB", "Used Cache Space": "1.23 TB", "Port": "10200", "Used Disk Space": "3.52 TB", "Registerred Date": "2017-01-21 10:58:10", "IPMI": "", "Brick": "0", "Total Cache Space": "1.62 TB", "ID": "2"}]

```

but the output plugin put out nothing and log says that:

```auto
[root@AZ01HCI01 ~]# telegraf -config test.conf --debug
2019-07-23T08:54:20Z I! Starting Telegraf 1.11.2
2019-07-23T08:54:20Z I! Loaded inputs: exec
2019-07-23T08:54:20Z I! Loaded aggregators: 
2019-07-23T08:54:20Z I! Loaded processors: 
2019-07-23T08:54:20Z I! Loaded outputs: file
2019-07-23T08:54:20Z I! Tags enabled: host=AZ01HCI01.PRI.QINGHAI-ZW
2019-07-23T08:54:20Z I! [agent] Config: Interval:1s, Quiet:false, Hostname:"AZ01HCI01.PRI.QINGHAI-ZW", Flush Interval:1s
2019-07-23T08:54:20Z D! [agent] Connecting outputs
2019-07-23T08:54:20Z D! [agent] Attempting connection to output: file
2019-07-23T08:54:20Z D! [agent] Successfully connected to output: file
2019-07-23T08:54:20Z D! [agent] Starting service inputs
2019-07-23T08:54:22Z D! [outputs.file] buffer fullness: 0 / 10000 metrics. 
2019-07-23T08:54:23Z D! [outputs.file] buffer fullness: 0 / 10000 metrics. 
2019-07-23T08:54:24Z D! [outputs.file] buffer fullness: 0 / 10000 metrics. 

```

Do I use the exec input incorrectly or the json parser doesn’t work well?

---

<div class="post-metadata">

**Author:** ![glinton](https://avatars.discourse-cdn.com/v4/letter/g/b487fb/32.png) [@glinton](https://community.influxdata.com/u/glinton)\
**Post date:** [July 23, 2019, 5:25pm UTC](https://community.influxdata.com/t/the-exec-input-of-telegraf-can-not-parse-json-data-which-is-array/10637/2 "2019-07-23T17:25:09Z")

</div>

You’re quite close, the reason no metrics are being output is because there are no values that are non-string (no fields get created). You’ll have to tell telegraf which you want as a string field with something like the following config:

```auto
  json_string_fields = ["Total Disk Space", "Used Disk Space", "Total Cache Space", "Used Cache Space"]
  tag_keys = ["Status", "Name", "ID"]

```

---

<div class="post-metadata">

**Author:** ![michaelpassion](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/michaelpassion/32/3354_2.png) [@michaelpassion](https://community.influxdata.com/u/michaelpassion)\
**Post date:** [July 24, 2019, 7:13am UTC](https://community.influxdata.com/t/the-exec-input-of-telegraf-can-not-parse-json-data-which-is-array/10637/3 "2019-07-24T07:13:36Z")

</div>

Thanks, problem solved. Your answer helps a lot.
