为了使我的 Graphite 图表更具可定制性和交互性,我正在从 Graphiti 切换到获取原始数据并使用 Javascript 库 (flot) 绘制它。我大约每 10 秒从 Graphite 获取页面上每个图表的原始 JSON 数据,但我想在单个 GET 请求中获取所有数据。我可以要求多个目标,但我还没有找到组织它们的方法。理想情况下,我想找到一种方法将与每个图相关的目标嵌套到它们自己的 JSON 对象中。我试图避免必须解析所有目标名称并将它们分类到它们的透视图中。
示例:如果我这样做:
mysite.com/graphite/render/?format=json&from=-1minute&target=aliasByNode(stats.production.api.response_codes.*,6)&target=aliasByNode(stats.production.app.*.CPUUtilization.Average,3)
我得到这样的东西:
[ {"target": "400", "datapoints": [...]},
{"target": "500", "datapoints": [...]},
{"target": "cpu.5", "datapoints": [...]},
{"target": "cpu.1", "datapoints": [...]},
{"target": "cpu.2", "datapoints": [...]},
{"target": "cpu.3", "datapoints": [...]},
{"target": "cpu.4", "datapoints": [...]},
{"target": "cpu.5", "datapoints": [...]} ]
我想找回这样的东西:
[ {"api_errors": {
{"target": "400", "datapoints": [...]},
{"target": "500", "datapoints": [...]} },
{"cpu_utilization": {
{"target": "cpu.5", "datapoints": [...]},
{"target": "cpu.1", "datapoints": [...]},
{"target": "cpu.2", "datapoints": [...]},
{"target": "cpu.3", "datapoints": [...]},
{"target": "cpu.4", "datapoints": [...]},
{"target": "cpu.5", "datapoints": [...]} }
} ]
有没有人有任何想法?