What is the best way to access Graphite data programmatically?

Dmitry Buzdin picture Dmitry Buzdin · Nov 19, 2013 · Viewed 11.1k times · Source

What is the best way to access data from Graphite render API?

https://graphite.readthedocs.org/en/latest/render_api.html#data-display-formats

Is there a JVM compatible client implementation? Or there is a possibility to retrieve this data using some other API?

I do realise that the format is self descriptive and it is not a rocket science, but it would be great to reuse and contribute rather than writing from scratch.

Answer

erbdex picture erbdex · Nov 19, 2013

The render api, as you mentioned, allows the following variables along with the API call-

&format=png
&format=raw
&format=csv
&format=json
&format=svg

For implementations such as , you can make straightforward curl calls like:

curl "http://graphite.com/render/?target=carbon.agents.host.creates&format=json"

The call would return:

[{
    "target": "carbon.agents.ip-10-0-0-111-a.creates", 
    "datapoints": [
        [4.0, 1384870140], 
        [1.0, 1384870200], 
        [18.0, 1384870260], 
        [0.0, 1384870320], 
        [4.0, 1384870380], 
        [12.0, 1384870440], 
        [3.0, 1384870500],
        [7.0, 1384870560], 
        [8.0, 1384870620], 
        [null, 1384870680]
    ]
}]

Since it is this straightforward, therefore it'd be pretty lame to implement something just for making curl calls. What the community has done is that they are using these as fundamental building blocks for custom frontends, querying scripts that alert, nagios plugins etc.

Is there something more specific that you are looking for?