# Snapshot using http api does nothing

**URL:** <https://community.grafana.com/t/snapshot-using-http-api-does-nothing/8834>\
**Category:** General\
**Tags:** api\
**Created:** [July 16, 2018, 1:36pm UTC](https://community.grafana.com/t/snapshot-using-http-api-does-nothing/8834 "2018-07-16T13:36:07Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![theob](https://avatars.discourse-cdn.com/v4/letter/t/c68b51/32.png) [@theob](https://community.grafana.com/u/theob)\
**Post date:** [July 16, 2018, 1:36pm UTC](https://community.grafana.com/t/snapshot-using-http-api-does-nothing/8834/1 "2018-07-16T13:36:07Z")

</div>

Hi

I updated the defaults.ini to send snapshow to our new snapshot server. Using this json document I wanted to send the dashboard to the new server. However nothing happens.  
{  
“expires” : 3600,  
“dashboard” : {  
“version” : 14,  
“tags” : [],  
“schemaVersion” : 14,  
“links” : [],  
“refresh” : “5m”,  
“timepicker” : {  
“refresh\_intervals” : [  
“5s”,  
“10s”,  
“30s”,  
“1m”,  
“5m”,  
“15m”,  
“30m”,  
“1h”,  
“2h”,  
“1d”  
],  
“time\_options” : [  
“5m”,  
“15m”,  
“1h”,  
“6h”,  
“12h”,  
“24h”,  
“2d”,  
“7d”,  
“30d”  
]  
},  
“timezone” : “browser”,  
“snapshot” : {  
“timestamp” : “2018-06-07T11:14:45:051Z”  
},  
“rows” : [  
{  
“repeat” : null,  
“panels” : [  
{  
“mode” : “html”,  
“type” : “text”,  
“span” : 11,  
“links” : [],  
“id” : 38,  
“height” : “400”,  
“title” : “”,  
“content” : “

# TEST
”,  
“transparent” : false  
}  
],  
“repeatIteration” : null,  
“title” : “Dashboard”,  
“repeatRowId” : null,  
“titleSize” : “h6”,  
“height” : 94,  
“collapse” : false,  
“showTitle” : false  
}  
],  
“templating” : {  
“list” : []  
},  
“hideControls” : false,  
“editable” : true,  
“style” : “dark”,  
“time” : {  
“to” : “now/M”,  
“from” : “now/M”  
},  
“uid” : “000000231”,  
“annotations” : {  
“list” : [  
{  
“hide” : true,  
“iconColor” : “rgba(0, 211, 255, 1)”,  
“builtIn” : 1,  
“name” : “Annotations & Alerts”,  
“datasource” : “-- Grafana --”,  
“type” : “dashboard”,  
“enable” : true  
}  
]  
},  
“graphTooltip” : 0,  
“id” : 231,  
“gnetId” : null,  
“title” : “TEST-THEO”,  
“originalTitle” : “TEST-THEO”  
},  
“key” : “1CFFBB14-88FB-11E8-B019-BC5695913E38”,  
“name” : “Master-Defined”,  
“external” : true,  
“deleteKey” : “1CFFB114-88FB-11E8-B019-BC5695913E38”  
}

I call the url [http://127.0.0.1:3000/api/snapshots](http://127.0.0.1:3000/api/snapshots)

/Theo

---

<div class="post-metadata">

**Author:** ![anon34853223](https://avatars.discourse-cdn.com/v4/letter/a/71c47a/32.png) [@anon34853223](https://community.grafana.com/u/anon34853223)\
**Post date:** [July 31, 2018, 5:15pm UTC](https://community.grafana.com/t/snapshot-using-http-api-does-nothing/8834/2 "2018-07-31T17:15:38Z")

</div>

Please check grafana server log for details when you create your snapshot and include here if not clear what’s wrong.

---

<div class="post-metadata">

**Author:** ![theob](https://avatars.discourse-cdn.com/v4/letter/t/c68b51/32.png) [@theob](https://community.grafana.com/u/theob)\
**Post date:** [August 23, 2018, 10:11am UTC](https://community.grafana.com/t/snapshot-using-http-api-does-nothing/8834/3 "2018-08-23T10:11:27Z")

</div>

Hi

Sorry for not answering for so long. Just got back from vacation.  
Nothing came in the logs even though the log level is set to debug.

/Theo

---

<div class="post-metadata">

**Author:** ![anon34853223](https://avatars.discourse-cdn.com/v4/letter/a/71c47a/32.png) [@anon34853223](https://community.grafana.com/u/anon34853223)\
**Post date:** [August 23, 2018, 12:03pm UTC](https://community.grafana.com/t/snapshot-using-http-api-does-nothing/8834/4 "2018-08-23T12:03:08Z")

</div>

What happens if you create a snapshot thru UI?

---

<div class="post-metadata">

**Author:** ![theob](https://avatars.discourse-cdn.com/v4/letter/t/c68b51/32.png) [@theob](https://community.grafana.com/u/theob)\
**Post date:** [August 23, 2018, 12:38pm UTC](https://community.grafana.com/t/snapshot-using-http-api-does-nothing/8834/5 "2018-08-23T12:38:17Z")

</div>

Hi

I tried, clicking the button to send the snapshot to the server I configured, but the server running the webbrowser is not permitted (fw restrictions) to contact the server that should receive the snapshot and it didn’t work. Also nothing here in the logs.

/Theo

---

<div class="post-metadata">

**Author:** ![anon34853223](https://avatars.discourse-cdn.com/v4/letter/a/71c47a/32.png) [@anon34853223](https://community.grafana.com/u/anon34853223)\
**Post date:** [August 23, 2018, 12:42pm UTC](https://community.grafana.com/t/snapshot-using-http-api-does-nothing/8834/6 "2018-08-23T12:42:34Z")

</div>

> [@Can't publish snapshots to a custom external server](https://community.grafana.com/t/cant-publish-snapshots-to-a-custom-external-server/5609):
>
> I have configured a Grafana server to publish snapshots to an external Grafana server by setting the following in grafana.ini: external\_enabled = true external\_snapshot\_url = [http://www.xyz.com:3000](http://www.xyz.com:3000) When I try to publish a snapshot to the external server I get an “Unexpected error” in the UI. After further investigations it seems that the first OPTIONS request to api/snapshots returns a 404 with body {“message”:“Not found”}. I can successfully publish local snapshots on both Grafana servers.…

---

<div class="post-metadata">

**Author:** ![theob](https://avatars.discourse-cdn.com/v4/letter/t/c68b51/32.png) [@theob](https://community.grafana.com/u/theob)\
**Post date:** [August 27, 2018, 10:32am UTC](https://community.grafana.com/t/snapshot-using-http-api-does-nothing/8834/7 "2018-08-27T10:32:33Z")

</div>

Hi

My responsecode is 200 with a body:  
{“deleteKey”:“388FDCA2-A9E3-11E8-B084-15685F20F290”,“deleteUrl”:“[http://grafana.staged-by-discourse.com/api/snapshots-delete/388FDCA2-A9E3-11E8-B084-15685F20F290",“key”:“388FF55C-A9E3-11E8-B084-15685F20F290”,“url”:"http://grafana.staged-by-discourse.com/dashboard/snapshot/388FF55C-A9E3-11E8-B084-15685F20F290](http://grafana.staged-by-discourse.com/api/snapshots-delete/388FDCA2-A9E3-11E8-B084-15685F20F290%22,%22key%22:%22388FF55C-A9E3-11E8-B084-15685F20F290%22,%22url%22:%22http://grafana.staged-by-discourse.com/dashboard/snapshot/388FF55C-A9E3-11E8-B084-15685F20F290)”}

So something does happen internally, only I don’t know what and it is not logged. And a packet sniffer does not show any packet being transferred to the target server.

/Theo

---

<div class="post-metadata">

**Author:** ![anon34853223](https://avatars.discourse-cdn.com/v4/letter/a/71c47a/32.png) [@anon34853223](https://community.grafana.com/u/anon34853223)\
**Post date:** [August 27, 2018, 10:45am UTC](https://community.grafana.com/t/snapshot-using-http-api-does-nothing/8834/8 "2018-08-27T10:45:52Z")

</div>

You’ll need to send the request to your snapshot server when using the api.

---

<div class="post-metadata">

**Author:** ![theob](https://avatars.discourse-cdn.com/v4/letter/t/c68b51/32.png) [@theob](https://community.grafana.com/u/theob)\
**Post date:** [August 27, 2018, 11:03am UTC](https://community.grafana.com/t/snapshot-using-http-api-does-nothing/8834/9 "2018-08-27T11:03:13Z")

</div>

Do you mean by snapshot server, the machine that receives the snapshot? If so, where in my request do I configure the source of the data?

/Theo

---

<div class="post-metadata">

**Author:** ![anon34853223](https://avatars.discourse-cdn.com/v4/letter/a/71c47a/32.png) [@anon34853223](https://community.grafana.com/u/anon34853223)\
**Post date:** [August 27, 2018, 12:24pm UTC](https://community.grafana.com/t/snapshot-using-http-api-does-nothing/8834/10 "2018-08-27T12:24:44Z")

</div>

Well, when you create a snapshot through API you must provide the data - Grafana will not automatically query the data when you create a snapshot.

For example, I created a snapshot of the following [dashboard](https://play.grafana.org/d/000000003/big-dashboard?orgId=1) (removed all panels except one before creating snapshot) and publishing it to [snapshot.raintank.io](http://snapshot.raintank.io).

Using chrome dev tools this is what happens in browser when creating a snapshot and publishing it to [snapshot.raintank.io](http://snapshot.raintank.io) from Grafana UI:

1. When sending HTTP POST to [https://snapshots-origin.raintank.io/api/snapshots](https://snapshots-origin.raintank.io/api/snapshots) the browser will first automatically send a HTTP OPTIONS request to [https://snapshots-origin.raintank.io/api/snapshots](https://snapshots-origin.raintank.io/api/snapshots) to negotiate CORS.
2. The HTTP OPTIONS response returns the following headers which tells the browser that a HTTP POST request is allowed to be made from any origin (browser)  
Access-Control-Allow-Headers: Content-Type, Origin, Accept, User-Agent, Cache-Control, Keep-Alive  
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS  
Access-Control-Allow-Origin: \*
3. The actual HTTP POST is sent to [https://snapshots-origin.raintank.io/api/snapshots](https://snapshots-origin.raintank.io/api/snapshots) (see request/response below). As you can see the actual data is included in snapshotData properties in the body.

> **Request body**
>
> ```json
> {
> "dashboard": {
> "annotations": {
> "enable": false,
> "list": [
> {
> "name": "Annotations & Alerts",
> "enable": true,
> "iconColor": "rgba(0, 211, 255, 1)",
> "snapshotData": [],
> "type": "dashboard",
> "builtIn": 1,
> "hide": true
> }
> ]
> },
> "editable": true,
> "gnetId": null,
> "graphTooltip": 1,
> "id": 3,
> "links": [],
> "panels": [
> {
> "aliasColors": {
> "web_server_01": "#badff4",
> "web_server_02": "#5195ce",
> "web_server_03": "#1f78c1",
> "web_server_04": "#0a437c"
> },
> "annotate": { "enable": false },
> "bars": false,
> "dashLength": 10,
> "dashes": false,
> "datasource": null,
> "editable": true,
> "fill": 6,
> "grid": { "max": null, "min": 0 },
> "gridPos": { "h": 11, "w": 16, "x": 0, "y": 0 },
> "id": 2,
> "interactive": true,
> "legend": {
> "alignAsTable": false,
> "avg": false,
> "current": false,
> "max": false,
> "min": false,
> "rightSide": false,
> "show": true,
> "total": false,
> "values": false
> },
> "legend_counts": true,
> "lines": true,
> "linewidth": 1,
> "nullPointMode": "connected",
> "options": false,
> "percentage": false,
> "pointradius": 5,
> "points": false,
> "renderer": "flot",
> "resolution": 100,
> "scale": 1,
> "seriesOverrides": [],
> "snapshotData": [
> {
> "datapoints": [
> [27.650000000000002, 1535370450000],
> [28.950000000000003, 1535370460000],
> [29, 1535370470000],
> [27.9, 1535370480000],
> [28.200000000000003, 1535370490000],
> [27.900000000000002, 1535370500000],
> [27.450000000000003, 1535370510000],
> [28.5, 1535370520000],
> [28.55, 1535370530000],
> [25.55, 1535370540000],
> [26.3, 1535370550000],
> [28.700000000000003, 1535370560000],
> [27.450000000000003, 1535370570000],
> [27.15, 1535370580000],
> [27.05, 1535370590000],
> [25.85, 1535370600000],
> [26.85, 1535370610000],
> [27.35, 1535370620000],
> [29.1, 1535370630000],
> [30.900000000000002, 1535370640000],
> [29.300000000000004, 1535370650000],
> [27.5, 1535370660000],
> [25.950000000000003, 1535370670000],
> [25.35, 1535370680000],
> [25.150000000000002, 1535370690000],
> [25.6, 1535370700000],
> [27.6, 1535370710000],
> [27.75, 1535370720000],
> [28.35, 1535370730000],
> [30.75, 1535370740000]
> ],
> "target": "web_server_01"
> },
> {
> "datapoints": [
> [26.85, 1535370450000],
> [28.6, 1535370460000],
> [28.950000000000003, 1535370470000],
> [28.65, 1535370480000],
> [28.75, 1535370490000],
> [29.050000000000004, 1535370500000],
> [28.6, 1535370510000],
> [26.4, 1535370520000],
> [26.450000000000003, 1535370530000],
> [25.550000000000004, 1535370540000],
> [26.200000000000003, 1535370550000],
> [29.6, 1535370560000],
> [29.15, 1535370570000],
> [27.05, 1535370580000],
> [26.450000000000003, 1535370590000],
> [25.200000000000003, 1535370600000],
> [25.5, 1535370610000],
> [27.6, 1535370620000],
> [31.25, 1535370630000],
> [31.200000000000003, 1535370640000],
> [27.400000000000002, 1535370650000],
> [27.050000000000004, 1535370660000],
> [27, 1535370670000],
> [25.5, 1535370680000],
> [26.200000000000003, 1535370690000],
> [26.5, 1535370700000],
> [25.700000000000003, 1535370710000],
> [28.150000000000002, 1535370720000],
> [29.6, 1535370730000],
> [29.75, 1535370740000]
> ],
> "target": "web_server_02"
> },
> {
> "datapoints": [
> [28.75, 1535370450000],
> [29.8, 1535370460000],
> [28.9, 1535370470000],
> [28.450000000000003, 1535370480000],
> [28.05, 1535370490000],
> [28.35, 1535370500000],
> [29.300000000000004, 1535370510000],
> [26.550000000000004, 1535370520000],
> [25.400000000000002, 1535370530000],
> [25.3, 1535370540000],
> [26.200000000000003, 1535370550000],
> [26.900000000000002, 1535370560000],
> [26.85, 1535370570000],
> [28.55, 1535370580000],
> [28.55, 1535370590000],
> [25.4, 1535370600000],
> [25.200000000000003, 1535370610000],
> [27, 1535370620000],
> [29.05, 1535370630000],
> [30.55, 1535370640000],
> [27.700000000000003, 1535370650000],
> [28.1, 1535370660000],
> [28, 1535370670000],
> [25.700000000000003, 1535370680000],
> [25.05, 1535370690000],
> [25.8, 1535370700000],
> [26.9, 1535370710000],
> [26.9, 1535370720000],
> [29.9, 1535370730000],
> [31.1, 1535370740000]
> ],
> "target": "web_server_03"
> },
> {
> "datapoints": [
> [25.950000000000003, 1535370450000],
> [26.6, 1535370460000],
> [27.300000000000004, 1535370470000],
> [28.25, 1535370480000],
> [30.3, 1535370490000],
> [31.200000000000003, 1535370500000],
> [30.200000000000003, 1535370510000],
> [28.5, 1535370520000],
> [28.6, 1535370530000],
> [29.450000000000003, 1535370540000],
> [27.6, 1535370550000],
> [27.4, 1535370560000],
> [27.700000000000003, 1535370570000],
> [28.75, 1535370580000],
> [29.450000000000003, 1535370590000],
> [28.200000000000003, 1535370600000],
> [28.550000000000004, 1535370610000],
> [27.150000000000002, 1535370620000],
> [25.6, 1535370630000],
> [27.450000000000003, 1535370640000],
> [26.9, 1535370650000],
> [26.05, 1535370660000],
> [26.450000000000003, 1535370670000],
> [25.75, 1535370680000],
> [26.700000000000003, 1535370690000],
> [28.35, 1535370700000],
> [27.35, 1535370710000],
> [26.25, 1535370720000],
> [28.05, 1535370730000],
> [30.950000000000003, 1535370740000]
> ],
> "target": "web_server_04"
> }
> ],
> "spaceLength": 10,
> "spyable": true,
> "stack": true,
> "steppedLine": false,
> "targets": [],
> "thresholds": [],
> "timeFrom": null,
> "timeShift": null,
> "timezone": "browser",
> "title": "server requests",
> "tooltip": {
> "msResolution": false,
> "query_as_alias": true,
> "shared": true,
> "sort": 0,
> "value_type": "cumulative"
> },
> "type": "graph",
> "xaxis": { "buckets": null, "mode": "time", "name": null, "show": true, "values": [] },
> "yaxes": [
> { "format": "short", "logBase": 1, "max": null, "min": null, "show": true },
> { "format": "short", "logBase": 1, "max": null, "min": null, "show": true }
> ],
> "yaxis": { "align": false, "alignLevel": null },
> "zerofill": true,
> "links": []
> }
> ],
> "refresh": false,
> "schemaVersion": 16,
> "snapshot": { "timestamp": "2018-08-27T11:52:22.450Z" },
> "style": "dark",
> "tags": ["demo"],
> "templating": { "list": [] },
> "time": {
> "from": "2018-08-27T11:47:26.458Z",
> "to": "2018-08-27T11:52:26.459Z",
> "raw": { "from": "now-5m", "to": "now" }
> },
> "timepicker": {
> "collapse": false,
> "enable": true,
> "notice": false,
> "now": true,
> "refresh_intervals": ["5s", "10s", "30s", "1m", "5m", "15m", "30m", "1h", "2h", "1d"],
> "status": "Stable",
> "time_options": ["5m", "15m", "1h", "2h", " 6h", "12h", "24h", "2d", "7d", "30d"],
> "type": "timepicker"
> },
> "timezone": "browser",
> "title": "Big Dashboard",
> "uid": "000000003",
> "version": 16
> },
> "name": "Big Dashboard",
> "expires": 0
> }
> 
> ```

> **Response body**
>
> ```json
> {
> "deleteKey": "<delete key>",
> "deleteUrl": "https://snapshot.raintank.io/api/snapshots-delete/<delete key>",
> "key": "<access key>",
> "url": "https://snapshot.raintank.io/dashboard/snapshot/<access key>"
> }
> 
> ```

1. Another HTTP POST is sent to [https://play.grafana.org/api/snapshots/](https://play.grafana.org/api/snapshots/) (see request/response below).

> **Request body**
>
> ```json
> {
> "dashboard": {
> "annotations": {
> "enable": false,
> "list": [
> {
> "name": "Annotations & Alerts",
> "enable": true,
> "iconColor": "rgba(0, 211, 255, 1)",
> "snapshotData": [],
> "type": "dashboard",
> "builtIn": 1,
> "hide": true
> }
> ]
> },
> "editable": true,
> "gnetId": null,
> "graphTooltip": 1,
> "id": 3,
> "links": [],
> "panels": [
> {
> "aliasColors": {
> "web_server_01": "#badff4",
> "web_server_02": "#5195ce",
> "web_server_03": "#1f78c1",
> "web_server_04": "#0a437c"
> },
> "annotate": { "enable": false },
> "bars": false,
> "dashLength": 10,
> "dashes": false,
> "datasource": null,
> "editable": true,
> "fill": 6,
> "grid": { "max": null, "min": 0 },
> "gridPos": { "h": 11, "w": 16, "x": 0, "y": 0 },
> "id": 2,
> "interactive": true,
> "legend": {
> "alignAsTable": false,
> "avg": false,
> "current": false,
> "max": false,
> "min": false,
> "rightSide": false,
> "show": true,
> "total": false,
> "values": false
> },
> "legend_counts": true,
> "lines": true,
> "linewidth": 1,
> "nullPointMode": "connected",
> "options": false,
> "percentage": false,
> "pointradius": 5,
> "points": false,
> "renderer": "flot",
> "resolution": 100,
> "scale": 1,
> "seriesOverrides": [],
> "snapshotData": [
> {
> "datapoints": [
> [27.650000000000002, 1535370450000],
> [28.950000000000003, 1535370460000],
> [29, 1535370470000],
> [27.9, 1535370480000],
> [28.200000000000003, 1535370490000],
> [27.900000000000002, 1535370500000],
> [27.450000000000003, 1535370510000],
> [28.5, 1535370520000],
> [28.55, 1535370530000],
> [25.55, 1535370540000],
> [26.3, 1535370550000],
> [28.700000000000003, 1535370560000],
> [27.450000000000003, 1535370570000],
> [27.15, 1535370580000],
> [27.05, 1535370590000],
> [25.85, 1535370600000],
> [26.85, 1535370610000],
> [27.35, 1535370620000],
> [29.1, 1535370630000],
> [30.900000000000002, 1535370640000],
> [29.300000000000004, 1535370650000],
> [27.5, 1535370660000],
> [25.950000000000003, 1535370670000],
> [25.35, 1535370680000],
> [25.150000000000002, 1535370690000],
> [25.6, 1535370700000],
> [27.6, 1535370710000],
> [27.75, 1535370720000],
> [28.35, 1535370730000],
> [30.75, 1535370740000]
> ],
> "target": "web_server_01"
> },
> {
> "datapoints": [
> [26.85, 1535370450000],
> [28.6, 1535370460000],
> [28.950000000000003, 1535370470000],
> [28.65, 1535370480000],
> [28.75, 1535370490000],
> [29.050000000000004, 1535370500000],
> [28.6, 1535370510000],
> [26.4, 1535370520000],
> [26.450000000000003, 1535370530000],
> [25.550000000000004, 1535370540000],
> [26.200000000000003, 1535370550000],
> [29.6, 1535370560000],
> [29.15, 1535370570000],
> [27.05, 1535370580000],
> [26.450000000000003, 1535370590000],
> [25.200000000000003, 1535370600000],
> [25.5, 1535370610000],
> [27.6, 1535370620000],
> [31.25, 1535370630000],
> [31.200000000000003, 1535370640000],
> [27.400000000000002, 1535370650000],
> [27.050000000000004, 1535370660000],
> [27, 1535370670000],
> [25.5, 1535370680000],
> [26.200000000000003, 1535370690000],
> [26.5, 1535370700000],
> [25.700000000000003, 1535370710000],
> [28.150000000000002, 1535370720000],
> [29.6, 1535370730000],
> [29.75, 1535370740000]
> ],
> "target": "web_server_02"
> },
> {
> "datapoints": [
> [28.75, 1535370450000],
> [29.8, 1535370460000],
> [28.9, 1535370470000],
> [28.450000000000003, 1535370480000],
> [28.05, 1535370490000],
> [28.35, 1535370500000],
> [29.300000000000004, 1535370510000],
> [26.550000000000004, 1535370520000],
> [25.400000000000002, 1535370530000],
> [25.3, 1535370540000],
> [26.200000000000003, 1535370550000],
> [26.900000000000002, 1535370560000],
> [26.85, 1535370570000],
> [28.55, 1535370580000],
> [28.55, 1535370590000],
> [25.4, 1535370600000],
> [25.200000000000003, 1535370610000],
> [27, 1535370620000],
> [29.05, 1535370630000],
> [30.55, 1535370640000],
> [27.700000000000003, 1535370650000],
> [28.1, 1535370660000],
> [28, 1535370670000],
> [25.700000000000003, 1535370680000],
> [25.05, 1535370690000],
> [25.8, 1535370700000],
> [26.9, 1535370710000],
> [26.9, 1535370720000],
> [29.9, 1535370730000],
> [31.1, 1535370740000]
> ],
> "target": "web_server_03"
> },
> {
> "datapoints": [
> [25.950000000000003, 1535370450000],
> [26.6, 1535370460000],
> [27.300000000000004, 1535370470000],
> [28.25, 1535370480000],
> [30.3, 1535370490000],
> [31.200000000000003, 1535370500000],
> [30.200000000000003, 1535370510000],
> [28.5, 1535370520000],
> [28.6, 1535370530000],
> [29.450000000000003, 1535370540000],
> [27.6, 1535370550000],
> [27.4, 1535370560000],
> [27.700000000000003, 1535370570000],
> [28.75, 1535370580000],
> [29.450000000000003, 1535370590000],
> [28.200000000000003, 1535370600000],
> [28.550000000000004, 1535370610000],
> [27.150000000000002, 1535370620000],
> [25.6, 1535370630000],
> [27.450000000000003, 1535370640000],
> [26.9, 1535370650000],
> [26.05, 1535370660000],
> [26.450000000000003, 1535370670000],
> [25.75, 1535370680000],
> [26.700000000000003, 1535370690000],
> [28.35, 1535370700000],
> [27.35, 1535370710000],
> [26.25, 1535370720000],
> [28.05, 1535370730000],
> [30.950000000000003, 1535370740000]
> ],
> "target": "web_server_04"
> }
> ],
> "spaceLength": 10,
> "spyable": true,
> "stack": true,
> "steppedLine": false,
> "targets": [],
> "thresholds": [],
> "timeFrom": null,
> "timeShift": null,
> "timezone": "browser",
> "title": "server requests",
> "tooltip": {
> "msResolution": false,
> "query_as_alias": true,
> "shared": true,
> "sort": 0,
> "value_type": "cumulative"
> },
> "type": "graph",
> "xaxis": { "buckets": null, "mode": "time", "name": null, "show": true, "values": [] },
> "yaxes": [
> { "format": "short", "logBase": 1, "max": null, "min": null, "show": true },
> { "format": "short", "logBase": 1, "max": null, "min": null, "show": true }
> ],
> "yaxis": { "align": false, "alignLevel": null },
> "zerofill": true,
> "links": []
> }
> ],
> "refresh": false,
> "schemaVersion": 16,
> "snapshot": { "timestamp": "2018-08-27T11:52:22.450Z" },
> "style": "dark",
> "tags": ["demo"],
> "templating": { "list": [] },
> "time": {
> "from": "2018-08-27T11:47:26.458Z",
> "to": "2018-08-27T11:52:26.459Z",
> "raw": { "from": "now-5m", "to": "now" }
> },
> "timepicker": {
> "collapse": false,
> "enable": true,
> "notice": false,
> "now": true,
> "refresh_intervals": ["5s", "10s", "30s", "1m", "5m", "15m", "30m", "1h", "2h", "1d"],
> "status": "Stable",
> "time_options": ["5m", "15m", "1h", "2h", " 6h", "12h", "24h", "2d", "7d", "30d"],
> "type": "timepicker"
> },
> "timezone": "browser",
> "title": "Big Dashboard",
> "uid": "000000003",
> "version": 16
> },
> "deleteKey": "<delete key>",
> "expires": 0,
> "external":true,
> "key": "<access key>",
> "name": "Big Dashboard"
> }
> 
> ```

> **Response body**
>
> ```json
> {
> "deleteKey": "<delete key>",
> "deleteUrl": "https://play.grafana.org/api/snapshots-delete/<delete key>",
> "key": "<access key>",
> "url": "https://play.grafana.org/dashboard/snapshot/<access key>"
> }
> 
> ```

For you to be able to create an external snapshot using the HTTP API you’ll need to do at least step 3) using url of your Grafana snapshot server. The tricky part is how you’re going to generate the snapshotData - You basically needs to extract all queries in dashboard and for each use the [datasource proxy call api](http://docs.grafana.org/http_api/data_source/#data-source-proxy-calls). It’s possible, but not at all trivial.

We hope that Grafana in the future could have http api for generating snapshot and automatically fetching the data needed.

---

<div class="post-metadata">

**Author:** ![theob](https://avatars.discourse-cdn.com/v4/letter/t/c68b51/32.png) [@theob](https://community.grafana.com/u/theob)\
**Post date:** [August 28, 2018, 12:07pm UTC](https://community.grafana.com/t/snapshot-using-http-api-does-nothing/8834/11 "2018-08-28T12:07:24Z")

</div>

Hi,

This entirely changes my perspective on snapshots. I’ll try to write some code to create a snapshot.  
Automatically fetching the data would indeed be a GREAT improvement to Grafana.

Thanks

/Theo

---

<div class="post-metadata">

**Author:** ![svetb](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/svetb/32/3307_2.png) [@svetb](https://community.grafana.com/u/svetb)\
**Post date:** [August 29, 2018, 9:37am UTC](https://community.grafana.com/t/snapshot-using-http-api-does-nothing/8834/12 "2018-08-29T09:37:32Z")

</div>

I’m also using - or rather attempting to use - the API to programmatically create a local snapshot of a dashboard. The end objective is to generate a PDF export. I’ve got most of the steps worked out; documented at [https://gist.github.com/svet-b/772f88b92eee88db7da5cefe8d3d4edb](https://gist.github.com/svet-b/772f88b92eee88db7da5cefe8d3d4edb).

But I get stuck on actually populating data in the dashboard’s panels. That works fine if I either:

- generate the snapshot using the Grafana UI, in which case the data is part of the snapshot
- generate the snapshot via the API, and then load it as an authenticated user (without authentication I get “datasource not found” errors, since the data isn’t there)

This behavior is in line with @anon34853223’s comment above, regarding the fact that creating a snapshot via an API call essentially creates a snapshot that is devoid of data.

Based on that comment, I take it that in this programmatic scenario the data needs to be populated via a separate mechanism, but it’s not clear to me what that actually looks like. @anon34853223 is it a matter of picking out the queries from the dashboard JSON and manually running them against the datasource, then re-inserting them in the JSON? I’m asking because I feel that my case is a bit simpler than what’s discussed here (local snapshot), and I’m not totally clear on which parts are still relevant vs not.

At the moment the workaround I’m thinking of is the following. This is in the context of obtaining a PDF of the dashboard using [puppeteer](https://github.com/GoogleChrome/puppeteer/) - which basically emulates the browser loading the dashboard using headless Chromium, and then printing it to a PDF - but it can probably be modified so that the full snapshot JSON (including data) is obtained, again through puppeteer.

1. Set up a reverse proxy for Grafana (with appropriate IP access restrictions)
2. Make that proxy automatically add an Authorization header with a valid API key to all requests to the Grafana instance in question
3. When running puppeteer point it to that reverse proxy, so that requests to the datasource are processed.

Is there a more straightforward way that I’m missing?

---

<div class="post-metadata">

**Author:** ![anon34853223](https://avatars.discourse-cdn.com/v4/letter/a/71c47a/32.png) [@anon34853223](https://community.grafana.com/u/anon34853223)\
**Post date:** [August 29, 2018, 12:32pm UTC](https://community.grafana.com/t/snapshot-using-http-api-does-nothing/8834/13 "2018-08-29T12:32:26Z")

</div>

> [@svetb](#):
>
> is it a matter of picking out the queries from the dashboard JSON and manually running them against the datasource, then re-inserting them in the JSON?

Yes, either you run them direct against the datasource or you use datasource proxy call api (see link above). Basically if you create a snapshot in Grafana UI and looking at chrome dev tools network tab you’ll see that requests will be made to fetch data of each metric query in each panel. Depending on if your datasource are using server or browser access mode the requests will look different - server access mode are using the Grafana datasource proxy call api to fetch data and browser access mode makes fetches data directly from datasource in browser without going through Grafana backend.

But as I wrote earlier it can be very tricky to get this to work as expected. If you can I would suggest you to use puppeteer directly against a dashboard instead to get rid of the extra snapshot step. Or maybe it’s possible to use puppeteer to actually create the snapshot from Grafana UI.

---

<div class="post-metadata">

**Author:** ![svetb](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/svetb/32/3307_2.png) [@svetb](https://community.grafana.com/u/svetb)\
**Post date:** [August 29, 2018, 1:56pm UTC](https://community.grafana.com/t/snapshot-using-http-api-does-nothing/8834/14 "2018-08-29T13:56:02Z")

</div>

Right, makes sense. Thanks for the quick response! Looks like the datasource proxy API would indeed require a fair bit of extra scripting to get everything into place.

And yes, it also occurred to me that if I’m using puppeteer with authentication to load the data for the snapshots, I could just get it to do the dashboard itself in the first place, and skip the snapshot stage.

---

<div class="post-metadata">

**Author:** ![theob](https://avatars.discourse-cdn.com/v4/letter/t/c68b51/32.png) [@theob](https://community.grafana.com/u/theob)\
**Post date:** [September 5, 2018, 12:39pm UTC](https://community.grafana.com/t/snapshot-using-http-api-does-nothing/8834/15 "2018-09-05T12:39:03Z")

</div>

Marcus,

I was able to create a remote snapshot using a perl script. The snapshot on the remote server showed everything including the value except for the lines.

/Theo

{  
“expires” : 0,  
“dashboard” : {  
“title” : “Report Amsterdam - 5 min samples”,  
“gnetId” : null,  
“graphTooltip” : 1,  
“links” : [],  
“annotations” : {  
“enable” : false,  
“list” : [  
{  
“hide” : true,  
“iconColor” : “rgba(0,211,255,1)”,  
“builtIn” : 1,  
“type” : “dashboard”,  
“snapshotData” : [],  
“name” : “Annotations & Alerts”,  
“enable” : true  
}  
]  
},  
“expires” : 0,  
“editable” : true,  
“timezone” : “browser”,  
“panels” : [  
{  
“minSpan” : 24,  
“gridPos” : {  
“y” : 0,  
“h” : 3,  
“w” : 24,  
“x” : 0  
},  
“scopedVars” : {  
“host” : {  
“text” : “AMSNODE”,  
“selected” : true,  
“value” : “AMSNODE”  
}  
},  
“links” : [],  
“content” : “\<font size=“20”\>\n

Node: AMSNODE

\n”,  
“title” : “”,  
“type” : “text”,  
“height” : 20,  
“mode” : “html”  
},  
{  
“height” : 400,  
“dashLength” : 10,  
“fill” : 2,  
“timeShift” : null,  
“percentage” : false,  
“title” : “AMSNODE - Interface 1/1/4”,  
“gridPos” : {  
“w” : 24,  
“x” : 0,  
“y” : 15,  
“h” : 10  
},  
“steppedLine” : false,  
“minSpan” : 12,  
“interval” : “5m”,  
“legend” : {  
“show” : true,  
“avg” : false,  
“alignAsTable” : true,  
“values” : true,  
“total” : false,  
“min” : false,  
“current” : false,  
“max” : true,  
“rightSide” : false  
},  
“thresholds” : [],  
“points” : false,  
“xaxis” : {  
“name” : null,  
“buckets” : null,  
“show” : true,  
“values” : [],  
“mode” : “time”  
},  
“description” : “”,  
“lines” : true,  
“snapshotData” : [  
{  
“datapoints” : [  
[  
null,  
1536148800000  
],  
[  
357748685.333333,  
1536149100000  
],  
[  
308412081.093333,  
1536149400000  
],  
[  
329165577.066667,  
1536149700000  
],  
[  
330257478.346667,  
1536150000000  
],  
[  
327029906.933333,  
1536150300000  
],  
[  
null,  
1536150600000  
]  
],  
“target” : “ifHCInOctets”  
},  
{  
“datapoints” : [  
[  
null,  
1536148800000  
],  
[  
3473425.73333333,  
1536149100000  
],  
[  
2836452.05333333,  
1536149400000  
],  
[  
2647752.34666667,  
1536149700000  
],  
[  
2891803.06666667,  
1536150000000  
],  
[  
2534119.81333333,  
1536150300000  
],  
[  
null,  
1536150600000  
]  
],  
“target” : “ifHCOutOctets”  
}  
],  
“stack” : false,  
“spaceLength” : 10,  
“dashes” : false,  
“yaxes” : [  
{  
“logBase” : 1,  
“show” : true,  
“label” : “Throughput”,  
“max” : 0,  
“format” : “bps”  
},  
{  
“label” : “”,  
“max” : null,  
“format” : “short”,  
“logBase” : 1,  
“show” : false  
}  
],  
“nullPointMode” : null,  
“scopedVars” : {  
“host” : {  
“value” : “AMSNODE”,  
“text” : “AMSNODE”,  
“selected” : true  
}  
},  
“links” : [],  
“pointradius” : 5,  
“aliasColors” : {},  
“datasource” : null,  
“bars” : false,  
“span” : 12,  
“repeat” : false,  
“type” : “graph”,  
“seriesOverrides” : [],  
“tooltip” : {  
“value\_type” : “cumulative”,  
“sort” : 0,  
“shared” : true  
},  
“renderer” : “flot”,  
“timeFrom” : null,  
“linewidth” : 1  
}  
],  
“id” : 3  
},  
“name” : “Report Amsterdam - 5 min samples”  
}

---

<div class="post-metadata">

**Author:** ![mdspidle](https://avatars.discourse-cdn.com/v4/letter/m/9dc877/32.png) [@mdspidle](https://community.grafana.com/u/mdspidle)\
**Post date:** [November 27, 2018, 6:24pm UTC](https://community.grafana.com/t/snapshot-using-http-api-does-nothing/8834/16 "2018-11-27T18:24:26Z")

</div>

Theo, could you possibly share your perl code that worked for you?

---

<div class="post-metadata">

**Author:** ![tombeeno](https://avatars.discourse-cdn.com/v4/letter/t/df705f/32.png) [@tombeeno](https://community.grafana.com/u/tombeeno)\
**Post date:** [January 11, 2019, 5:55pm UTC](https://community.grafana.com/t/snapshot-using-http-api-does-nothing/8834/17 "2019-01-11T17:55:46Z")

</div>

What’s the point of the Snapshot in the API then? Seems like it’s up to me to generate all the data and simply using that API to “store” the snapshot, not create it.

Is there any documentation for the Data Source Proxy API? I notice the link you provided to the docs simply says “Proxies all calls to the actual datasource.”

---

<div class="post-metadata">

**Author:** ![anon34853223](https://avatars.discourse-cdn.com/v4/letter/a/71c47a/32.png) [@anon34853223](https://community.grafana.com/u/anon34853223)\
**Post date:** [January 14, 2019, 4:33pm UTC](https://community.grafana.com/t/snapshot-using-http-api-does-nothing/8834/18 "2019-01-14T16:33:48Z")

</div>

> [@tombeeno](#):
>
> What’s the point of the Snapshot in the API then? Seems like it’s up to me to generate all the data and simply using that API to “store” the snapshot, not create it.

Well the API is built mainly for Grafana UI so that’s the point of the API. Maybe sometime in the future we would have an api that supports creating a snapshot together with generating all required data.

> [@tombeeno](#):
>
> Is there any documentation for the Data Source Proxy API? I notice the link you provided to the docs simply says “Proxies all calls to the actual datasource.”

The easiest way would be to use chrome dev tools and inspect the request/response because it can differ between different datasources.

---

<div class="post-metadata">

**Author:** ![kevinhaefeli](https://avatars.discourse-cdn.com/v4/letter/k/977dab/32.png) [@kevinhaefeli](https://community.grafana.com/u/kevinhaefeli)\
**Post date:** [January 15, 2019, 5:29am UTC](https://community.grafana.com/t/snapshot-using-http-api-does-nothing/8834/19 "2019-01-15T05:29:00Z")

</div>

I’d recommend to add a hint to the snapshot api documentation, that you also need to send the data with the snapshot and it doesn’t generate it automatically. (I was also expecting Grafana to do it automatically and lost much time, because the data source error on the other hand isn’t really clear…)

Using puppeteer to do it feels somehow wrong 🙂 especially if you have an API…  
but for the PDF export workflow it’s probably sufficient

---

<div class="post-metadata">

**Author:** ![anon80964540](https://avatars.discourse-cdn.com/v4/letter/a/bbe5ce/32.png) [@anon80964540](https://community.grafana.com/u/anon80964540)\
**Post date:** [January 13, 2021, 4:40pm UTC](https://community.grafana.com/t/snapshot-using-http-api-does-nothing/8834/20 "2021-01-13T16:40:14Z")

</div>

Closed on January 13, 2021, 4:40pm UTC


