Grafana
Grafana is a powerful visualisation tool that we can use to display graphics of the persisted data.
In order to read data from a CrateDB database for your dashboards in Grafana, you should use the Postgres Datasource. The Postgres Datasource should come preinstalled in the latest Grafana versions.
If you followed the Installation Guide, you have already Grafana running in a Docker container. If deployed locally, it's probably at http://0.0.0.0:3000
You can now follow Crate's recommendations on how to configure the datasource by checking out this post. If you already put some data in your database, you can jump directly to the "Add a Data Source" section. The main parts of such post are convered below.
Configuring the DataSource
Explore your deployed Grafana instance (e.g http://0.0.0.0:3000).
If you didn't change the defaults credentials, use admin
as both user and
password.
Go to Add data source, select PostreSQL
and fill in the required fields,
with the following considerations:
- Name: This is the name you want for the Datasource. Name it
CrateDB
and make it default. - Host: The full url where CrateDB was deployed, but on port
5432
. In the docker-compose example, this should becrate:5432
. - Database: This is the name of the database schema. By default, crate uses
doc
schema, but if you are using multi-tenancy headers, the schema will be defined by the tenant of the entity type. More info in the Multi-tenancy section. - User: Use
crate
user. - SSL Mode:
disable
.
The following image shows an example of how the datasource configuration should look like
Click Save & Test and you should get an OK message.
Using the DataSource in your Graph
Having your datasource setup, you can start using it in the different visualisation widgets.
The following is an example of a simple Graph using a datasource connected to CrateDB. Note the selection of the datasource (called CrateDB in this case), as well as the specification of the table in the from field.
Note table names are prefixed by et
. See the Data Retrieval
section to know how table names are defined, but you should recognise the
entity type.
Note the name of the column used as time index is time_index
, as explained
in the Time Index section.