首页 > 解决方案 > Grafana 通过 API 覆盖现有仪表板

问题描述

我正在尝试通过 API 覆盖现有的 grafana 仪表板,如下所示:

curl -X POST -H "Content-Type: application/json" "https://api_key:xxx/api/dashboards/db" -d @test.json

而且我面临版本控制问题,无法用我的 json 覆盖相同的仪表板:

{"message":"The dashboard has been changed by someone else","status":"version-mismatch"}⏎

有没有办法避免这种情况并强制覆盖?

谢谢 !

标签: grafanagrafana-api

解决方案


这实际上取决于您的test.json文件中的内容。我希望仪表板模型正确,因此您只需在顶层添加一些字段,例如:

"overwrite": true,
"message": "my saved message, which will be available in the version history"

请参阅 API 文档 - https://grafana.com/docs/grafana/latest/http_api/dashboard/#create-update-dashboard


推荐阅读