Skip to main content
Version: 0.6

Prometheus

GreptimeDB can be used as long-term storage for Prometheus. Using GreptimeDB as a Prometheus backend is a seamless experience. Since Prometheus has built-in support for setting up basic authentication information during the configuration of remote write and read, all you need to do is add your configured username and password to the config YAML file and you're good to go!

First of all, create a database through your favourite SQL client:

CREATE DATABASE prometheus;

Then please follow the settings in Prometheus configuration (prometheus.yml):

remote_write:
- url: http://localhost:4000/v1/prometheus/write?db=prometheus
# basic_auth:
# username: greptime_user
# password: greptime_pwd

remote_read:
- url: http://localhost:4000/v1/prometheus/read?db=prometheus
# basic_auth:
# username: greptime_user
# password: greptime_pwd

Note: Be sure to uncomment basic_auth section and replace greptime_user(username), greptime_pwd(password) with your own username and password when you enable database authentication. Please refer to client authentication.

The db parameter in url represents the database that we want to write, it's public if not present.

Show tables in Prometheus when writing successfully:

use prometheus;
show tables;
+---------------------------------------------------------------+
| Tables |
+---------------------------------------------------------------+
| go_memstats_heap_inuse_bytes |
| go_memstats_last_gc_time_seconds |
| net_conntrack_listener_conn_closed_total |
| prometheus_remote_storage_enqueue_retries_total |
| prometheus_remote_storage_exemplars_pending |
| prometheus_remote_storage_read_request_duration_seconds_count |
| prometheus_rule_group_duration_seconds |
| prometheus_rule_group_duration_seconds_count |
| ...... |
+---------------------------------------------------------------+

Prometheus Metrics in GreptimeDB

When the metrics are written into GreptimeDB by remote write endpoint, they will be transformed as follows:

Sample MetricsIn GreptimeDBGreptimeDB Data Types
NameTable (Auto-created) NameString
ValueColumn (greptime_value)Double
TimestampColumn (greptime_timestamp)Timestamp
LabelColumnString

A primary key with all label columns will be created automatically. When a new label is added, it will be added into primary key automatically too.

Example: Prometheus metrics in GreptimeDB Table

prometheus_remote_storage_samples_total{instance="localhost:9090", job="prometheus",
remote_name="648f0c", url="http://localhost:4000/v1/prometheus/write"} 500

This example will be transformed as a row in the table prometheus_remote_storage_samples_total

ColumnValueColumn Data Type
instancelocalhost:9090String
jobprometheusString
remote_name648f0cString
urlhttp://localhost:4000/v1/prometheus/writeString
greptime_value500Double
greptime_timestampThe sample's unix timestampTimestamp