Prometheus
GreptimeDB 可以作为 Prometheus 的长期存储解决方案,提供无缝集成体验。
配置 Remote Write
Prometheus 配置文件
要将 GreptimeDB 集成到 Prometheus 中,
请按照以下步骤更新你的 Prometheus 配置文件(prometheus.yml
):
remote_write:
- url: http://localhost:4000/v1/prometheus/write?db=public
# 如果启用了身份验证,请取消注释并设置鉴权信息
# basic_auth:
# username: greptime_user
# password: greptime_pwd
remote_read:
- url: http://localhost:4000/v1/prometheus/read?db=public
# 如果启用了身份验证,请取消注释并设置鉴权信息
# basic_auth:
# username: greptime_user
# password: greptime_pwd
- URL 中的 host 和 port 表示 GreptimeDB 服务器。在此示例中,服务器运行在
localhost:4000
上。你可以将其替换为你自己的服务器地址。有关 GreptimeDB 中 HTTP 协议的配置,请参阅 协议选项。 - URL 中的
db
参数表示要写入的数据库。它是可选的。默认情况下,数据库设置为public
。 basic_auth
是身份鉴权配置。如果 GreptimeDB 启用了鉴权,请填写用户名和密码。请参阅 鉴权认证文档。
Grafana Alloy 配置文件
如果你使用 Grafana Alloy,请在 Alloy 配置文件(config.alloy
)中配置 Remote Write。有关更多信息,请参阅 Alloy 文档。
Vector 配置文件
如果你使用 Vector ,请在 Vector 配置文件 (vector.toml
)中配置 Remote Write。有关更多信息,请参阅 Vector 文档.
数据模型
在 GreptimeDB 的数据模型中,数据被组织成具有 tag、time index 和 field 的表。 GreptimeDB 可以被视为多值数据模型,自动将多个 Prometheus 指标分组到相应的表中。 这样可以实现高效的数据管理和查询。
当指标通过远程写入端点写入 GreptimeDB 时,它们将被转换为以下形式:
Sample Metrics | In GreptimeDB | GreptimeDB Data Types |
---|---|---|
Name | Table (Auto-created) Name | String |
Value | Column (Field) | Double |
Timestamp | Column (Time Index) | Timestamp |
Label | Column (Tag) | String |
例如,以下 Prometheus 指标:
prometheus_remote_storage_samples_total{instance="localhost:9090", job="prometheus",
remote_name="648f0c", url="http://localhost:4000/v1/prometheus/write"} 500
将被转换为表 prometheus_remote_storage_samples_total
中的一行:
Column | Value | Column Data Type |
---|---|---|
instance | localhost:9090 | String |
job | prometheus | String |
remote_name | 648f0c | String |
url | http://localhost:4000/v1/prometheus/write | String |
greptime_value | 500 | Double |
greptime_timestamp | The sample's unix timestamp | Timestamp |