18

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.

Dmitry Buzdin
  • 1,233
  • 1
  • 9
  • 15

1 Answers1

15

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?

fracz
  • 20,536
  • 18
  • 103
  • 149
erbdex
  • 1,899
  • 3
  • 22
  • 40
  • Thank you for response! I am really lazy and currently writing few hundred lines of code to create a wrapper, so I was wondering if someone did it before. – Dmitry Buzdin Nov 19 '13 at 14:24
  • 1
    There are some very interesting functions that can save a lot of your time and/or arithmetic. For example, target=groupByNode(Application.timers.production.machinerole.*.*.*.message.time,6,"averageSeries") will group and average the entire subtrees about the 6th depth. – erbdex Nov 19 '13 at 14:29
  • @erbdex: I have a question: is there a way to return all the targets (all paths / metrics) that are available in Graphite? – Cosmin Ioniță Jul 30 '18 at 15:56