Consume API Endpoints in Grafana


With Grafana you can create, explore, and share flexible dashboards over the data you expose in the API Endpoints you create with Tinybird thanks to the JSON API plugin.
JSON API is an open source data source plugin for Grafana that lets you visualize data from any URL that returns JSON, such as REST APIs or static file servers.

Install the JSON API plugin

Follow the steps in

Create a Grafana Data Source

Create a new Data Source with the plugin. Fill —or the URL where your Tinybird Workspace is hosted— in the HTTP URL field.

JSON API Data Source with in the HTTP URL

Edit the Query

Create a new Dashboard, edit the suggested Panel, and use the Data Source you just created.

We will consume the endpoint shown in this documentation page.

Tinybird endpoint documentation page

So, the Path in the Query editor is /v0/pipes/api_grafana_guide.json.

Query Path

We need to add the mandatory Params: token, start_ts, and end_ts.

You can use Grafana’s global variables $__from and $__to defined with the time range selector.

Query Params

Note we are using the following format ${__from:date} and they can be converted to DateTime in your nodes with parseDateTimeBestEffort().

   ts BETWEEN parseDateTimeBestEffort({{String(start_ts)}})
   AND parseDateTimeBestEffort({{String(end_ts)}})

Lastly, let’s extract the information from the respose Fields using the JSONPaths.

Query Fields

Dashboard Variables

You can also query Tinybird endpoints to define Dashboard Variables

Adding a Variable

That will make it interactive

Adding a Variable

Final notes

More details on how to deal with Query editor and Variables in the plugin documentation

Although we love JSON API plugin, we noticed it doesn’t support alerting. If alerts are requirement, you might want to check Infinity plugin, that works in a very similar way.