Consume API Endpoints in Grafana

Grafana is an awesome open source analytics & monitoring tool. In this guide, you'll learn how to create Grafana dashboards consuming Tinybird API Endpoints.

With Grafana you can create, explore, and share flexible dashboards over the data you expose in your Tinybird API Endpoints thanks to the JSON API plugin.

Prerequisites

This guide assumes you have a Tinybird Workspace with an active Data Source, Pipes, and at least one API Endpoint. You'll also need a Grafana account.

1. Install the JSON API plugin

Follow the steps in Grafana <> JSON API plugin installation.

2. Create a Grafana data source

Create a new Data Source with the plugin. In the HTTP > URL field, use https://api.tinybird.co/ (or the region-correct URL where your Tinybird Workspace is hosted).

3. Edit the query

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

You'll consume the endpoint shown in this documentation page.

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

You'll 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.

Note this guide uses the following format ${__from:date}. This can be converted to DateTime in your Nodes with parseDateTimeBestEffort().

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

Lastly, extract the information from the response Fields using JSONPaths.

Dashboard variables

You can also query Tinybird Endpoints to define dashboard variables:

That will make it interactive:

Next steps

  • Learn more about the query editor and variables in the plugin documentation.
  • JSON API plugin is awesome but doesn't support alerting. If alerts are requirement, check out the Infinity plugin, which works in a very similar way.