简体   繁体   English

如何获取JSON格式的石墨树结构

[英]How to obtain graphite tree structure in JSON format

I would like to view all graphite tree structure in json format. 我想以json格式查看所有石墨树结构。 I am currently using 我目前正在使用

GET /metrics/find/?format=treejson&query=stats.gauges.*

gives: 得到:

[{"leaf": 0, "context": {}, "text": "echo_server", 
     "expandable": 1, "id": "stats.gauges.echo_server", "allowChildren": 1},
 {"leaf": 0, "context": {}, "text": "logstash",
     "expandable": 1, "id": "stats.gauges.logstash", "allowChildren": 1},
 {"leaf": 0, "context": {}, "text": "server0",
     "expandable": 1, "id": "stats.gauges.server0", "allowChildren": 1},
 {"leaf": 0, "context": {}, "text": "server1", 
     "expandable": 1, "id": "stats.gauges.server1", "allowChildren": 1},
 {"leaf": 0, "context": {}, "text": "stats", 
     "expandable": 1, "id": "stats.gauges.stats", "allowChildren": 1},
 {"leaf": 0, "context": {}, "text": "statsd", 
     "expandable": 1, "id": "stats.gauges.statsd", "allowChildren": 1},
 {"leaf": 0, "context": {}, "text": "vamsi", 
     "expandable": 1, "id": "stats.gauges.vamsi", "allowChildren": 1},
 {"leaf": 0, "context": {}, "text": "vamsi-server",
     "expandable": 1, "id": "stats.gauges.vamsi-server", "allowChildren": 1}
]

to obtain immediate children, Ideally i would like to have all the elements. 为了获得直系子女,理想情况下,我希望拥有所有要素。

[[UPDATE]] [[UPDATE]]

using GET/metrics/index.json gives required JSON. 使用GET/metrics/index.json会提供所需的JSON。

So, how do we build the tree view? 那么,我们如何构建树形视图?

I am working on the same thing apparently. 我显然在做同样的事情。 My solution is this: 我的解决方案是这样的:

http://graphite/metrics/find/?format=treejson&query= * http:// graphite / metrics / find /?format = treejson&query = *

returns the first level of the tree nodes. 返回树节点的第一级。 Then for each one you have to do this: 然后,对于每个人,您都必须这样做:

http://graphite/metrics/find/?format=treejson&query=previous_node_levels_with_dots .* http:// graphite / metrics / find /?format = treejson&query = previous_node_levels_with_dots 。*

and get the next level of nodes for that subtree. 并获得该子树的下一层节点。

By doing this recursively until you hit a "leaf=1" node, you can build the whole tree. 通过递归执行此操作,直到您单击“ leaf = 1”节点,即可构建整棵树。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM