How to get listing of all available paths

Asked by Andrew Feller

I want to dynamically build graphs but didn't want to keep multiple applications in sync with the paths used, so I am hoping there is some way to poll graphite for all available paths.

Question information

Language:
English Edit question
Status:
Solved
For:
Graphite Edit question
Assignee:
No assignee Edit question
Solved by:
Andrew Feller
Solved:
Last query:
Last reply:
Revision history for this message
Nicholas Leskiw (nleskiw) said :
#1

I'm not aware of a way to get a list of that data directly out of the UI or from a URL request.

Unless Chris tells me I'm wrong, doing a find on the /opt/graphite/storage/whisper directory is the way I'd go.

-Nick

On May 11, 2011, at 9:41 AM, Andrew Feller <email address hidden> wrote:

> New question #157047 on Graphite:
> https://answers.launchpad.net/graphite/+question/157047
>
> I want to dynamically build graphs but didn't want to keep multiple applications in sync with the paths used, so I am hoping there is some way to poll graphite for all available paths.
>
> --
> You received this question notification because you are a member of
> graphite-dev, which is an answer contact for Graphite.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~graphite-dev
> Post to : <email address hidden>
> Unsubscribe : https://launchpad.net/~graphite-dev
> More help : https://help.launchpad.net/ListHelp

Revision history for this message
Jeremy Katz (katzj) said :
#2

You could walk the tree like the UI does. Start at something like
    curl "http://localhost:8000/metrics/find/?query=*&format=treejson"
which will return json and you can then walk through all the leafs of the children.

It does seem like it'd be a nice improvement to add something to recurse and return the entire tree.

Revision history for this message
Andrew Feller (andrew-feller) said :
#3

I will give what Jeremy said a try, but it would be nice for the an api point with graphite / carbon directly rather than relying upon the website being available. I can see two people wanting either 1) tree or 2) list of paths that contain points.

I am curious how others have handled dynamic paths such as a new server coming to track or events tied to a specific thing.

Revision history for this message
Andrew Feller (andrew-feller) said :
#4

Would y'all consider the following path to /opt/graphite/webapp/graphite/metrics/views.py:

111,119d110
< elif format == 'depth':
< result = {
< 'results': sorted(depth_nodes(store, matches))
< }
< response = HttpResponse(json.dumps(result), mimetype='text/json')
< response['Pragma'] = 'no-cache'
< response['Cache-Control'] = 'no-cache'
< return response
<
128,140d118
< def depth_nodes(store, nodes):
< "Provide depth listing of leaf nodes"
< results = set()
< for n in nodes:
< if n.isLeaf():
< results.add(n.metric_path)
<
< else:
< results.update(depth_nodes(store, store.find( n.metric_path + '.*')))
<
< return results
<
<

This simply returns a listing of all leaf nodes within the matching nodes. Sorry but this is my first time writing Python, so please clean up as needed.

Revision history for this message
Andrew Feller (andrew-feller) said :
#5

Bah, I have a patch file but no way to attach here.