graphite-project / graphite-web

A highly scalable real-time graphing system
http://graphite.readthedocs.org/
Apache License 2.0
5.91k stars 1.26k forks source link

how to find all metrics recursively in 1 http request? #26

Closed Dieterbe closed 12 years ago

Dieterbe commented 12 years ago

Hi, I've been looking in webapp/graphite/metrics/views.py trying to find a way to get a listing of all metrics in 1 request. (for example in json) this doesn't seem to be possible yet. I'm a bit confused, it seems that there are multiple functions that do similar things, by different means.: find_view finds metrics by using a Store object from webapp/graphite/storage.py, whereas expand_view does something similar, as does tree_json which uses another mechanism, and then there's search which I haven't figured quite out (it seems to use a textbased index. btw: interestingly on my testing machine the index file does not get created)

please advise how I should proceed.

mleinart commented 12 years ago

You can hit /metrics/index.json to get the entire tree but this will cause the webapp to walk the entire metric directory tree on the filesystem each time it's called which could take longer than you want (or even longer than your webserver's request timeout).

You may instead want to walk the tree as the graphite webapp does: use the /metrics/find endpoint. Start with /metrics/find?query=* and build up from there as needed (/metrics/find?query=carbon.* etc).

Dieterbe commented 12 years ago

thanks that works

supre commented 9 years ago

Is there a way to find out active metrics and not all metrics. We have a lot of metrics which we don't use anymore but they do appear in the list with /metrics/find?query=*. I only want to see the metrics that are being actively used right now.

bmhatfield commented 9 years ago

@supre - I have an alternate approach to this problem. On the Graphite server itself, I run some variation of this command: sudo find /opt/graphite/storage/whisper -type f -name *.wsp -mtime +7 -ls -delete && sudo find /opt/graphite/storage/whisper/ -type d -empty -delete, which will remove all metrics that have not been written to in the past week.

keen99 commented 8 years ago

@supre http://graphite-api.readthedocs.io/en/latest/api.html#the-metrics-api and https://github.com/graphite-project/graphite-web/blob/master/webapp/graphite/metrics/views.py#L87 suggests the from parameter, fwiw.