New repo for Grafana-Jsonnet

I have a fun project about Grafana, and I have the ability to open source it. It is a JSonnet library to create Grafana dashboards.

Find out more about jsonnet:
TL;DR: It is a library for google that aims at easily generate/populate
json files.

In order to get more community involvement, I wonder if it would be
possible to get a repo under the grafana organisation on github.

That repo would be maintained by the community but we would respect
Grafana contributing rules and license.

I am pretty exited by this because it makes dashboards creation a lot
easier :slight_smile:

A small POC is there: (if we merge in an official grafana repo we would
add tests, and more things – current version is already outdated):

Side note: I contributing to many OS projects - I actually already made
small patches to grafana back in 2014.

Thanks! :slight_smile:

Good timing with this - we have been discussing how to include something like this with Grafana. I’ll get the team to test it out and we’ll get back to you later this week.

Hello Daniel,
I enjoyed your talk at percona live :slight_smile:

So… the project in its current state will not be helpful for your team – What I hope to do is to see if Grafana is interested to host it so we can bootstrap a community effort. I do not think it is worth it to do in in my own github namespace.

Exemple of datshboard definition:

local grafana = import "grafana-jsonnet/grafana.libsonnet";
local dashboard = grafana.dashboard;
local row = grafana.row;
local title = grafana.panels.titlePanel;
local target =;
local template = grafana.template;
local tp = grafana.timepicker;"Apache Overview")
+ dashboard.addTemplate("env", "Environment", "label_values(x_http_requests_duration_microseconds_sum, environment)", "environment", "Prometheus")
+ dashboard.addTemplate(
+ dashboard.addRow("25px")
    + row.addPanel("Apache Traffic on $env")
    + row.equalizePanels(),

Then it is compiled in a nice json dashboard.

This is still rude – but I do think we can make it really awesome!

1 Like

Please note that it is not about adding native support for jsonnet into grafana – for the moment the goal is to compile to JSON then upload to grafana

This looks pretty cool. There is already Wizzy and grafanalib which we are also considering. This looks closer to something we could bundle with Grafana, I think.

I am aware of them. Jsonnet is still my prefered choice because it is quite close to JSON, and it gives you the full flexibility of JSON out of the box.

e.g. include «raw» JSON:

+ dashboard.addTemplate("instance", "instance", "label_values(up, instance)", "instance", "Prometheus")
    + {
        includeAll: true,
        multi: true,
        current: {
            tags: [],
            text: "All",
            value: [
1 Like

hello @daniellee

I have started writing tests:

Please tell me if that can work out or not :slight_smile:

The repo could be

Sorry, for the delay. We had a busy week with the Grafana 4.6 release. I have shown it to the other members of the team but haven’t had a discussion about how we want to generate dashboards and if jsonnet is the way to go. We will sit down and discuss this next week.

@roidelapluie Finally got round to talking about this with the rest of the Grafana team (we first watched this and then we tried generating a dashboard with the docker project and with the go version of jsonnet). We are very enthusiastic about taking this further. The whole idea behind jsonnet is very appealing, especially that it is a superset of json and that it would be easy to generate json using Go - this means we can potentially integrate it with Grafana.

I have created an empty repo and given you write access:

I suppose the first steps are to start creating a domain language? We are in the middle of working on Grafana 5.0 so we can’t help out too much right now but we can give feedback and help with testing.

P.S. in the next major version of Grafana (in a month or so), there will be a new grid system (using react-grid) where the concept of rows will be much less important. There will still be rows for collapsing areas and repeat rows but there will be no rows per default. So grafonnet-lib might need to support both the old and new dashboard formats for a while.

1 Like

Awesome! Thank you. I will start working.