4.4 REST APIs for System Insight
You can also use REST API for System Insight when using InfluxDB and/or Grafana.
See the REST API examples below.
Examples of REST API for InfluxDB
Use the following command to show measurement names in InfluxDB:
curl -XPOST -u <user>:<password> 'http://influxdb.url:<port>/query?db=mz' --data-urlencode "q=SHOW MEASUREMENTS"
Use the following command to show databases:
curl -XPOST -u <user>:<password> 'http://influxdb.url:<port>/query?' --data-urlencode "q=SHOW DATABASES"
Use the following command to query a measurement for the latest 10 rows:
curl -XPOST -u <user>:<password> 'http://influxdb.url:<port>/query?db=mz' --data-urlencode "q=select * from \"measurement.name\" order by time desc limit 10"
For further information on REST API for InfluxDB, seeĀ https://docs.influxdata.com/influxdb/v1.2/guides/.
Examples of REST APIs for Grafana
Use the following REST API to add an InfluxDB data resource to Grafana:
curl -XPOST -H "Content-Type: application/json" -u <user>:<password> http://grafana.url:<port>/api/datasources --data-binary @<name_of_datasource>.json
Use the following REST API to add a dashboard from a file:
curl -XPOST -u <user>:<password> http://grafana_url:<port>/api/dashboards/db --data-binary @<dashboard_name>.json -H "Content-Type: application/json"
Use the following REST API to export a dashboard to file:
curl -u <user>:<password> http://grafana.url:<port>/api/dashboards/db/<name_of_dashboard> <dasboard_name>.json
For further information on REST API for Grafana, seeĀ http://docs.grafana.org/http_api/.