mirror of
https://github.com/grafana/grafana.git
synced 2025-07-29 09:02:24 +08:00

* Use relative aliases for all non-current Grafana aliases Prevents non-latest documentation "stealing" the page away from latest and through permanent redirects for latest pages that no longer exist. The redirected pages are indexed by search engines but our robots.txt forbids them crawling the non-latest page. Signed-off-by: Jack Baldry <jack.baldry@grafana.com> * Remove aliases from shared pages Signed-off-by: Jack Baldry <jack.baldry@grafana.com> * Rewrite all current latest aliases to be next Signed-off-by: Jack Baldry <jack.baldry@grafana.com> * Fix typo in latest alias Signed-off-by: Jack Baldry <jack.baldry@grafana.com> * Remove all current page aliases find docs/sources -type f -name '*.md' -exec sed -z -i 's#\n *- /docs/grafana/next/[^\n]*\n#\n#' {} \; find docs/sources -type f -name '*.md' -exec sed -Ez -i 's#\n((aliases:\n *-)|aliases:\n)#\n\2#' {} \; Signed-off-by: Jack Baldry <jack.baldry@grafana.com> * Prettier Signed-off-by: Jack Baldry <jack.baldry@grafana.com> Signed-off-by: Jack Baldry <jack.baldry@grafana.com>
226 lines
4.4 KiB
Markdown
226 lines
4.4 KiB
Markdown
---
|
||
aliases:
|
||
- ../../http_api/snapshot/
|
||
description: Grafana HTTP API
|
||
keywords:
|
||
- grafana
|
||
- http
|
||
- documentation
|
||
- api
|
||
- snapshot
|
||
title: 'HTTP Snapshot API '
|
||
---
|
||
|
||
# Snapshot API
|
||
|
||
## Create new snapshot
|
||
|
||
`POST /api/snapshots`
|
||
|
||
**Example Request**:
|
||
|
||
```http
|
||
POST /api/snapshots HTTP/1.1
|
||
Accept: application/json
|
||
Content-Type: application/json
|
||
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
|
||
|
||
{
|
||
"dashboard": {
|
||
"editable":false,
|
||
"nav":[
|
||
{
|
||
"enable":false,
|
||
"type":"timepicker"
|
||
}
|
||
],
|
||
"rows": [
|
||
{
|
||
|
||
}
|
||
],
|
||
"style":"dark",
|
||
"tags":[],
|
||
"templating":{
|
||
"list":[
|
||
]
|
||
},
|
||
"time":{
|
||
},
|
||
"timezone":"browser",
|
||
"title":"Home",
|
||
"version":5
|
||
},
|
||
"expires": 3600
|
||
}
|
||
```
|
||
|
||
JSON Body schema:
|
||
|
||
- **dashboard** – Required. The complete dashboard model.
|
||
- **name** – Optional. snapshot name
|
||
- **expires** - Optional. When the snapshot should expire in seconds. 3600 is 1 hour, 86400 is 1 day. Default is never to expire.
|
||
- **external** - Optional. Save the snapshot on an external server rather than locally. Default is `false`.
|
||
- **key** - Optional. Define the unique key. Required if **external** is `true`.
|
||
- **deleteKey** - Optional. Unique key used to delete the snapshot. It is different from the **key** so that only the creator can delete the snapshot. Required if **external** is `true`.
|
||
|
||
> **Note:** When creating a snapshot using the API, you have to provide the full dashboard payload including the snapshot data. This endpoint is designed for the Grafana UI.
|
||
|
||
**Example Response**:
|
||
|
||
```http
|
||
HTTP/1.1 200
|
||
Content-Type: application/json
|
||
{
|
||
"deleteKey":"XXXXXXX",
|
||
"deleteUrl":"myurl/api/snapshots-delete/XXXXXXX",
|
||
"key":"YYYYYYY",
|
||
"url":"myurl/dashboard/snapshot/YYYYYYY",
|
||
"id": 1
|
||
}
|
||
```
|
||
|
||
Keys:
|
||
|
||
- **deleteKey** – Key generated to delete the snapshot
|
||
- **key** – Key generated to share the dashboard
|
||
|
||
## Get list of Snapshots
|
||
|
||
`GET /api/dashboard/snapshots`
|
||
|
||
Query parameters:
|
||
|
||
- **query** – Search Query
|
||
- **limit** – Limit the number of returned results
|
||
|
||
**Example Request**:
|
||
|
||
```http
|
||
GET /api/dashboard/snapshots HTTP/1.1
|
||
Accept: application/json
|
||
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
|
||
```
|
||
|
||
**Example Response**:
|
||
|
||
```http
|
||
HTTP/1.1 200
|
||
Content-Type: application/json
|
||
|
||
```
|
||
|
||
## Get Snapshot by Key
|
||
|
||
`GET /api/snapshots/:key`
|
||
|
||
**Example Request**:
|
||
|
||
```http
|
||
GET /api/snapshots/YYYYYYY HTTP/1.1
|
||
Accept: application/json
|
||
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
|
||
```
|
||
|
||
**Example Response**:
|
||
|
||
```http
|
||
HTTP/1.1 200
|
||
Content-Type: application/json
|
||
|
||
```
|
||
|
||
## Delete Snapshot by Key
|
||
|
||
`DELETE /api/snapshots/:key`
|
||
|
||
**Example Request**:
|
||
|
||
```http
|
||
DELETE /api/snapshots/YYYYYYY HTTP/1.1
|
||
Accept: application/json
|
||
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk
|
||
```
|
||
|
||
**Example Response**:
|
||
|
||
```http
|
||
HTTP/1.1 200
|
||
Content-Type: application/json
|
||
|
||
```
|
||
|
||
## Delete Snapshot by deleteKey
|
||
|
||
This API call can be used without authentication by using the secret delete key for the snapshot.
|
||
|
||
`GET /api/snapshots-delete/:deleteKey`
|
||
|
||
**Example Request**:
|
||
|
||
```http
|
||
GET /api/snapshots-delete/XXXXXXX HTTP/1.1
|
||
Accept: application/json
|
||
```
|
||
|
||
**Example Response**:
|
||
|
||
```http
|
||
HTTP/1.1 200
|
||
Content-Type: application/json
|
||
|
||
```
|