I’m using the following to POST to my Grafana server:
{
"dashboard": {
"id": 315,
"tags": [
"templated"
],
"timezone": "browser",
"title": "Kubernetes Monitoring"
},
"overwrite": false
}
Unfortunately I’m getting the response back:
{"message":"Dashboard not found","status":"not-found"}
I’m trying to “import” this Grafana.com dashboard using the API: https://grafana.com/dashboards/315
I was thinking I could just put 315
as the dashboard ID in my POST but it doesn’t seem like that’s the correct approach. Do I have to download the dashboard and then manually insert it into the HTTP request? Is that the hand-waving the Grafana browser portal does?
Thanks in advance!
See README https://github.com/monitoringartist/grafana-aws-cloudwatch-dashboards there is example bash script. For the record:
#!/bin/bash
### Please edit grafana_* variables to match your Grafana setup:
grafana_host="http://grafana.staged-by-discourse.com"
grafana_cred="admin:admin"
grafana_datasource="cloudwatch"
ds=(1516 677 139 674 590 659 758 623 617 551 653 969 650 644 607 593 707 575 1519 581 584 2969);
for d in "${ds[@]}"; do
echo -n "Processing $d: "
j=$(curl -s -k -u "$grafana_cred" $grafana_host/api/gnet/dashboards/$d | jq .json)
curl -s -k -u "$grafana_cred" -XPOST -H "Accept: application/json" \
-H "Content-Type: application/json" \
-d "{\"dashboard\":$j,\"overwrite\":true, \
\"inputs\":[{\"name\":\"DS_CLOUDWATCH\",\"type\":\"datasource\", \
\"pluginId\":\"cloudwatch\",\"value\":\"$grafana_datasource\"}]}" \
$grafana_host/api/dashboards/import; echo ""
done
If it is a new dashboard then the id field should be left out. Otherwise you are trying to update dashboard 315 which in your case does not exist. The id 315 on Grafana.com has nothing to do with your internal dashboard ids.
Hello Daniellee,
May i know what is DS values are?
When you export a dashboard, Grafana removes the name for the data source and replaces it with the type. In this case, it is a data source of type Cloudwatch. Basically it turns the exported dashboard into a template.
So when somebody else imports the dashboard, they get this dialog in Grafana:
From the docs, an explanation about __inputs
: