Вопрос

I would like to view all graphite tree structure in json format. 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]]

using GET/metrics/index.json gives required 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=*

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.*

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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top