将石墨仪表板复制到另一个石墨仪表板

Copy graphite dashboard to another graphite dashboard

我有一个生产石墨仪表板。我在标签 abc 下保存了一些图表,以便您可以使用 http://prod-graphite.com/dashboard/abc.

访问它

我有另一个仪表板用于在不同的服务器上托管。假设 URL 是 http://staging-graphite.com/dashboard/.

我想将 prod /abc 的所有图表复制到 staging,因为我不想再次经历创建 20 个图表的麻烦。我已经尝试了 Graphite 提供的 Copy Dashboard 功能,但它不起作用。当我输入 prod URL 时没有任何反应。有帮助吗?

GET/POST http://your.graphite.host/dashboard/load/YOUR_DASHBOARD_NAME - 为您提供指定仪表板的转储。它 returns json 以 state 作为根对象,包含仪表板的结构。

POST http://your.graphite.host/dashboard/save/NEW_DASHBOARD_NAME - 让您将数据保存为新的仪表板。需要具有仪表板结构的 state 参数。

Oneliner,获取转储,准备正文,保存:

curl -o- http://graphite.host/dashboard/load/DASH_NAME | \
python -c "import json,sys,urllib;o=json.load(sys.stdin);print('state=%s' % urllib.quote(json.dumps(o['state'])));" | \
curl -X POST http://graphite.host/dashboard/save/COPY_OF_DASH_NAME -d @-