JSON ingestion from an API


#1

Hi there,

I just quickly want to confirm influxdb is the “right tool for the job”.

My goal is to plot data from a JSON API in Grafana. https://community.grafana.com/t/ingesting-hourly-data-from-a-json-api/15176?u=hendry

So in my case, assuming I get influxdb up and running via Docker or something, I would write a shell script to post the JSON data retrieved from curl -X GET "https://api.data.gov.sg/v1/environment/pm25?date=$DAY" -H "accept: application/json where DAY is YYYY-MM-DD going back to 2016-02-10?

Kind regards,


#2

The first thing I would do is make sure the data is time series data. That’s the most important factor when deciding to use Influx.

After that, you have two options to get data from a JSON API to InfluxDB. The first is to change the data to line protocol manually so you can write it to the database. [quote=“katy, post:2, topic:8966, full:true”]
The first thing I would do is make sure the data is time series data. That’s the most important factor when deciding to use Influx.

After that, you have two options to get data from a JSON API to InfluxDB. The first is to change the data to line protocol manually so you can write it to the database. The second is to use Telegraf and its JSON plugin to help format the data.
[/quote]

CORRECTION: You can’t use a straight JSON plugin for Telegraf. You can change the data format that Telegraf uses to JSON, which is demonstrated in the link above. You could use something like this multifile input plugin for Telegraf that would suit your needs better.