Contents
GET
/api/v3/grafana/render/?target=
Returns 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
Parameters
Format: -<num>m|h|d|w|M|Y
default: -6h
Format: now-<num>m|h|d|w|M|Y
default: now
number measured in pixels
default: 1000
number measured in pixels
default: 500
Format: “light” | “dark ”
default: dark
Curl Example:
Copy curl -i -X GET \
"https://<api-key>@api.hostedgraphite.com/api/v3/grafana/render/?target=foo.bar"
Response :
200 400 401
Copy HTTP / 1.1 200
Content-Type : image/png
<image data>
Bad Request Invalid form data
Time Queries:
You can interact with your dashboard instance directly through Grafana's HTTP API
In all examples <UID>
refers to the URL subdomain of your hosted instance, uid
refers to the unique identifier of the related resource.
To use the Grafana API, you will need to create a new Grafana API key within the Grafana UI (Settings => Service Accounts => Add Service Account with Admin role => Generate Service Account Token).
This token will be referred to as <SERVICE-ACCOUNT-TOKEN>
in the examples below.
Below are examples of requests made using the API
POST
/api/dashboards/db
Creates a new dashboard or updates an existing dashboard
Example:
Copy curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <SERVICE-ACCOUNT-TOKEN>" \
"https://<UID>.hostedgraphite.com/api/dashboards/db" \
-d @dashboard.json
200 400 412
Copy HTTP / 1.1 200
Content-Type : application/json
Copy {
"slug" : "production-overview" ,
"status" : "success" ,
"version" : 1
}
Conflict Dashboard already exists
Example dashboard.json file:
Copy {
"dashboard" : {
"title" : "Minimal Dashboard" ,
"panels" : []
} ,
"folderId" : 0 ,
"overwrite" : false
}
GET
/api/dashboards/uid/:uid
Returns a dashboard given the dashboard's uid
Bearer <SERVICE-ACCOUNT-TOKEN>
Curl examples:
Copy curl -X GET \
-H "Authorization: Bearer <SERVICE-ACCOUNT-TOKEN>" \
"https://<UID>.hostedgraphite.com/api/dashboards/uid/<DASHBOARD-UID>"
Response :
200 400 404
Copy HTTP / 1.1 200
Content-Type : application/json
Copy {
"meta" : {
"isStarred" : false ,
"slug" : "production-overview"
} ,
"model" : {
"id" : null ,
"title" : "Production Overview" ,
"tags" : [ "templated" ] ,
"timezone" : "browser" ,
"panels" : [ { } ]
"schemaVersion" : 6 ,
"version" : 0
} ,
}
Bad Request No dashboard specified
Not Found Dashboard not found
DELETE
/api/dashboards/uid/:uid
Deletes a dashboard given the dashboard slug.
Bearer <SERVICE-ACCOUNT-TOKEN>
Example:
Copy curl -X DELETE \
-H "Authorization: Bearer <SERVICE-ACCOUNT-TOKEN>" \
"https://<UID>.hostedgraphite.com/api/dashboards/uid/<DASHBOARD-UID>"
Response :
200 400: 404
Copy HTTP / 1.1 200
Content-Type : application/json
Copy {
"title" : "Example Dash" ,
"message" : "Dashboard Example Dash deleted" ,
"id" : 3
}
Bad Request No dashboard specified
GET
/api/search
Returns a list of dashboards given a search query.
Bearer <SERVICE-ACCOUNT-TOKEN>
Example :
Copy curl -X GET \
-H "Authorization: Bearer <SERVICE-ACCOUNT-TOKEN>" \
"https://<UID>.hostedgraphite.com/api/search"
Response :
200: 400
Copy HTTP / 1.1 200
Content-Type : application/json
Copy [
{
"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
}
...
]
Bad Request Invalid form data
POST
/api/folders
Creates a new folder for dashboard organization.
Headers
Bearer <SERVICE-ACCOUNT-TOKEN>
JSON Schema
Example :
Copy curl -X POST -H "Content-Type: application/json" \
-H "Authorization: Bearer <SERVICE-ACCOUNT-TOKEN>" \
"https://<UID>.hostedgraphite.com/api/folders" -d '{"title": "Test Folder"}'
Response:
200 400 409
Copy HTTP / 1.1 200
Content-Type : application/json
Copy {
"id" : 70 ,
"uid" : "bfc49500-7c2d-4d73-ba43-d8ab677d4836" ,
"title" : "Test Folder" ,
"url" : "/dashboards/f/bfc49500-7c2d-4d73-ba43-d8ab677d4836/test-folder" ,
"hasAcl" : false ,
"canSave" : true ,
"canEdit" : true ,
"canAdmin" : true ,
"canDelete" : true ,
"createdBy" : "Anonymous" ,
"created" : "2024-10-15T13:10:22.922696496Z" ,
"updatedBy" : "Anonymous" ,
"updated" : "2024-10-15T13:10:22.922696646Z" ,
"version" : 1
}
Errors (invalid json, missing or invalid fields, etc
Last updated 2 months ago