Obtaining available metrics

Asked by Daniel Cooper

Hello,
Firstly Graphite is quite cool. Thanks for the great work!

We're using collectd to write to carbon/whisper which a large amount of success. We are in the process of rolling our own UI and we would like to know how can we obtain the list of available metrics.

For example, collectd grabs all of the interface stats off our routers and switches. They are stored as:
hostname.if_octets.*.rx where * is the interface name.
Each of our network elements have a different set of interface names, so we would like to be able to query carbon/whisper to obtain the names of all of the network interfaces, so we can then pass them into a for loop elsewhere to render what we are after.

How can we go about doing that?

Thanks again for your help.
Daniel Cooper
Sydney, Australia

Question information

Language:
English Edit question
Status:
Answered
For:
Graphite Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Brian Dorsey (brian-dorseys) said :
#1

It looks like you can get a list of metrics by using the URL-API and setting the format to JSON instead of a graph image. For example, this works for me:

http://graphite_server/render/?target=carbon.agents.metrics-*.cache.*&format=json&from=-1minute

(I set 'from' to a short value here, to just get the list of metrics without much extra data, but if you know what graphs you want to draw, you could get the list of metrics and the data in one call.)

URL-API docs:
http://readthedocs.org/docs/graphite/en/latest/url-api.html

Take care,
-Brian

Revision history for this message
Daniel Lawrence (dannyla) said :
#2

If you want just a list of graphs tat are available have you tired using the url-api and the /metrics/find/ method.

eg. the following url query will give you a list of all the graphs inside the b/bambi/file_handles directory in json format
http://localhost:8000/metrics/find/?_dc=1327193701014&format=treejson&query=*.b.bambi.file_handles.*&node=*.b.bambi.file_handles

[{"text": "*", "expandable": 0, "leaf": 1, "id": "*.b.bambi.file_handles.*", "allowChildren": 0}, {"leaf": 1, "context": {}, "text": "allocated", "expandable": 0, "id": "*.b.bambi.file_handles.allocated", "allowChildren": 0}, {"leaf": 1, "context": {}, "text": "free", "expandable": 0, "id": "*.b.bambi.file_handles.free", "allowChildren": 0}, {"leaf": 1, "context": {}, "text": "total", "expandable": 0, "id": "*.b.bambi.file_handles.total", "allowChildren": 0}]

Should be easy to parse to get all the graph names, or in your case interface names.

Revision history for this message
Daniel Cooper (daniel-cooper-o) said :
#3

Thank you both for the update. We've been stuck focusing on other non-OSS projects lately, so we've not yet had a chance to look into your suggestions. I'll get back to you as soon as we have had a chance to look into this again.

Daniel

Can you help with this problem?

Provide an answer of your own, or ask Daniel Cooper for more information if necessary.

To post a message you must log in.