Input data formats [JSON] to InfluxDB issue

Hi,

I need to monitor the components/ version and status with Telegraf + InfluxDB for the below components exposed with Spring Boot /health metrics.
The Developer write the code on Spring Boot and exposed metrics on: localhost:8081/health

Telegraf
telegraf-1.5.3-1.x86_64
influxdb-1.5.0-1.x86_64

Telegraf.conf
[[inputs.exec]]
commands = [“curl -s localhost:8081/health”]
name_suffix = “_connector_components”
data_format = “json”

JSON metrics
[root@server1 ~]# curl -s localhost:8081/health
{“status”:“UP”,“doMqtt”:{“status”:“UP”},“ouMqtt”:{“status”:“UP”},“diskSpace”:{“status”:“UP”,“total”:53674864640,“free”:50545221632,“threshold”:10485760},“rabbit”:{“status”:“UP”,“version”:“3.6.12”},“redis”:{“status”:“UP”,“jedisConnectionFactory”:{“status”:“UP”,“version”:“3.2.10”},“redisCacheConnectionFactory”:{“status”:“UP”,“version”:“3.2.10”}}}

[root@server1 ~]# curl -s localhost:8081/health | jq
{
“status”: “UP”,
“doMqtt”: {
“status”: “UP”
},
“ouMqtt”: {
“status”: “UP”
},
“diskSpace”: {
“status”: “UP”,
“total”: 53674864640,
“free”: 50545229824,
“threshold”: 10485760
},
“rabbit”: {
“status”: “UP”,
“version”: “3.6.12”
},
“redis”: {
“status”: “UP”,
“jedisConnectionFactory”: {
“status”: “UP”,
“version”: “3.2.10”
},
“redisCacheConnectionFactory”: {
“status”: “UP”,
“version”: “3.2.10”
}
}
}

What I want to achive:
Ex: Redis (to be able in Grafana to have a query for Status/ Version in case of Redis).
Redis Status -> UP
Redis version -> 3.2.10
etc…

I’ve read about tags on: https://docs.influxdata.com/telegraf/v1.5/concepts/data_formats_input/#json didn’t workd for me.
I’ve read also on Spring Boot: https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-metrics.html#production-ready-metrics-export-influx --> It is better to ask the Developer to send direct the data, in fact he developed to export metrics for Prometheus at 1st time because use Spring 1.5.x for the moment and this is available on Spring 2.x.
Founded also some scripts to send data from json to InfluxDB but didn’t managed them as expected.

Let me know what do you think.
Kind Regards,

The JSON would need reformatted in order for Telegraf to be able to parse it, but it seems best to use the InfluxDB exporter to send either direct to InfluxDB or through Telegraf with the http_listener input.

1 Like

Thank you for the details and support.

You are referring to:

https://github.com/prometheus/influxdb_exporter
https://github.com/influxdata/telegraf/tree/master/plugins/inputs/http_listener

I’ve didn’t used till now, if this is the best solution I’ll go with it.

I didn’t find any example to use with InfluxDB, could you help me?

I never ran Sprint Boot, but it looks like you can use the InfluxDB exporter built in to sprint-boot and then send to the http_listener, which behaves like the InfluxDB http service.

1 Like

Thank you Daniel.
I’ll try with my colleague to implement this in Spring Boot 1.5, in Spring Boot 2 already are there implemented many approaches. I hope will upgrade in few days.

Kind Regards,