I’ve used Grafana for several years. Ever since the first time I used it, I have wanted to sit down and write a server which would provide metrics to it through the Simple JSON datasource plugin. I’m happy to announce that I have finally gotten around to doing just that. The tool is called PyGraf and will be opened sourced in the very near future!
In the meantime, I’d like to share my findings as there’s not a lot of documentation on the topic.
The Simple JSON docs tells us that our backend must support the following endpoints:
- / should return 200 ok. Used for “Test connection” on the datasource config page.
- /search used by the find metric options on the query tab in panels.
- /query should return metrics based on input.
- /annotations should return annotations.
That’s great to know, but how do we go about testing them? Let’s run through that now.