Support for rendering in different formats

Asked by Chris Boulton

Would anyone be interested in having support for different renderers in Graphite?

In to our copy, I've just hacked in experimental support for passing a renderer parameter to /render/, which allows the data to be output in different formats:
- standard image (default)
- raw text (same as &rawData=1)
- Pickle (same as &pickle=1)
- JSON (and JSON-P)

I'm also tossing up adding in native support for formats for outputting in formats that amCharts (XML) and Flot (JS) can understand/import directly.

I've not finished testing and cleaning everything up, but I should have a patch available by the end of the week if it's something we can look at being pushed in to the next release.

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
Chris Boulton (chris.boulton) said :
#1

Oh - I did forget to mention, adding support for a new renderer means just dropping a file in to webapp/graphite/render/renderers/, like so:

---

from graphite.render.renderers.base import BaseRenderer

from django.http import HttpResponse
from graphite.util import json
import pprint

class Renderer(BaseRenderer):
  def render(self, data):
    seriesInfo = [series.getInfo() for series in data]
    jsonData = json.dumps(seriesInfo)
    if self.requestOptions['jsonCallback']:
      jsonData = ''.join([self.requestOptions['jsonCallback'], '(', jsonData, ');'])

    response = HttpResponse(jsonData, mimetype='application/json')
    return response

The renderer is then accessible at /render?renderer=json&.....

Revision history for this message
chrismd (chrismd) said :
#2

Sorry I've been way behind on my Graphite stuff lately (partly because of... other Graphite stuff). Yes I think this is a great idea, if you've got a branch with this code please create a merge proposal. It may not make it in the next release, as I've got that queued up for about 2 weeks from now, but if it isn't a massive change (and I doubt it would be) then it will probably make it in the following release.

Thanks for working on Graphite!

Revision history for this message
Jason Dixon (jason-dixongroup) said :
#3

Chris Boulton-

Do you have this patch set available anywhere for testing? I'd love to try out the json renderer. :)

Thanks,
Jason

Can you help with this problem?

Provide an answer of your own, or ask Chris Boulton for more information if necessary.

To post a message you must log in.