Contents
Hosted Graphite supports an HTTP API which allows you to fetch, create, and update your primary dashboards.
Create dashboard
POST
/api/v2/grafana/dashboards
200: OK HTTP/1.1 200 Content-Type: application/json { "slug": "production-overview", "status": "success", "version": 1 } 400: Bad Request Invalid JSON 409: Conflict Dashboard already exists
Curl example:
Copy curl -X POST https://YOUR-API-KEY@api.hostedgraphite.com/api/v2/grafana/dashboards/ \
-d @dashboard.json
Example dashboard.json file:
Copy {
"title" : "Production Overview" ,
"tags" : [ "templated" ] ,
"timezone" : "browser" ,
"panels" : [
{
}
] ,
"schemaVersion" : 6 ,
"version" : 0
}
This example creates a dashboard with the name “Production Overview” in accordance with the title field above.
Update dashboard
PUT
/api/v2/grafana/dashboards
200: OK HTTP/1.1 200 Content-Type: application/json { "slug": "production-overview", "status": "success", "version": 2 } 400: Bad Request Invalid JSON
Curl example:
Copy curl -X PUT https://YOUR-API-KEY@api.hostedgraphite.com/api/v2/grafana/dashboards/ \
-d @dashboard.json
Example dashboard:
Copy {
"id" : 1
"title" : "Production Overview" ,
"tags" : [ "templated" , "prod" ] ,
"timezone" : "browser" ,
"panels" : [
{
}
] ,
"schemaVersion" : 6 ,
"message" : "version control message" // this is optional
}
Get dashboard
GET
/api/v2/grafana/dashboards/:slug
Returns a dashboard given the dashboard slug, a url friendly version of the dashboard title.
200: OK HTTP/1.1 200 Content-Type: application/json { "meta": { "isStarred": false, "slug": "production-overview" }, "model": { "id": null, "title": "Production Overview", "tags": [ "templated" ], "timezone": "browser", "panels": [ { } ] "schemaVersion": 6, "version": 0 }, } 400: Bad Request No dashboard specified 404: Not Found Dashboard not found
Curl examples:
Copy curl -X GET https://YOUR-API-KEY@api.hostedgraphite.com/api/v2/grafana/search \?
Returns all dashboard/folder information
Copy curl -X GET https://YOUR-API-KEY@api.hostedgraphite.com/api/v2/grafana/dashboards/production-overview
Returns the JSON model of a dashboard with the title of 'production overview'
Delete dashboard
DELETE
/api/v2/grafana/dashboards/:slug
Deletes a dashboard given the dashboard slug.
200: OK HTTP/1.1 200 Content-Type: application/json {"title": "Production Overview"} 400: Bad Request No dashboard specified 404: Not Found Dashboard not found
Curl example:
Copy curl -X DELETE https://YOUR-API-KEY@api.hostedgraphite.com/api/v2/grafana/dashboards/production-overview
List dashboard tags
GET
/api/v2/grafana/tags
200: OK HTTP/1.1 200 Content-Type: application/json [ { "term":"templated", "count":1 }, { "term":"production", "count":4 } ]
Curl example:
Copy curl -X GET https://YOUR-API-KEY@api.hostedgraphite.com/api/v2/grafana/tags
Search dashboards
GET
/api/v2/grafana/search
Returns a list of dashboards given a search query.
200: OK HTTP/1.1 200 Content-Type: application/json [ { "id":1, "title":"Production Overview", "uri":"db/production-overview", "type":"dash-db", "tags":[ templated, production ], "isStarred":true }, { "id":4, "title":"Production Webservers", "uri":"db/production-webservers", "type":"dash-db", "tags":[ production ], "isStarred":true } ] 400: Bad Request Invalid form data
Curl example:
Copy curl -i -X GET https://YOUR-API-KEY@api.hostedgraphite.com/api/v2/grafana/search?query=prod
Curl Example to Return all Dashboards:
Copy curl -i -X GET https://YOUR-API-KEY@api.hostedgraphite.com/api/v2/grafana/search \? query \= %
Render dashboard png
GET
/api/v2/grafana/render/?target=
Returns a link to a publicly accessible PNG image of a dashboard panel. To display any data on the graph you must include a ‘target’, you can append multiple targets to the request as follows: ?target=foo.bar.A&target=foo.bar.B
Path Parameters
200: OK HTTP/1.1 200 Content-Type: application/json http://i.mfhg.io/render-api/<user-id>/<filename>.png 400: Bad Request Invalid form data
Curl Example:
Copy curl -i -X GET "https://<api-key>@api.hostedgraphite.com/api/v2/grafana/render/?target=foo.bar"
Time Queries:
You can access additional dashboard/folder details using the Grafana HTTP API , just make sure to create a new Grafana API Key that you can use for the Authorization Header in your requests:
Example curl request to create a new Folder using the Grafana API:
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer " <grafana-api-key>" https://www.hostedgraphite.com/<UID>/grafana/api/folders -d '{"title": "Test Folder"}'
Last updated 13 hours ago