Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: export metrics #762

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions docs/v0.5/en/user-guide/operations/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,42 @@ append_stdout = true

How to use distributed tracing, please reference [Tracing](./tracing.md)

### Export metrics options

`frontend`, `metasrv`, `datanode` and `standalone` support collecting metrics generated by themselves and sending the collected metrics to [Prometheus RemoteWrite protocol](https://prometheus.io/docs/concepts/remote_write_spec/) compatible receiver, such as sending to `greptimedb` itself. **Note: Export metrics has nothing to do with using Prometheus to scape metrics generated by `greptimedb`. Export metrics is only used as a way for `greptimedb` to export the metrics generated by itself.** Users can configure related export parameters through the `[export_metrics]` section.
Taylor-lagrange marked this conversation as resolved.
Show resolved Hide resolved

There are two ways to export metrics data:
Taylor-lagrange marked this conversation as resolved.
Show resolved Hide resolved
1. `remote_write` method: All components can be exported using this method. The user specifies a URL that supports the Prometheus RemoteWrite protocol through the relevant configuration under `[export_metrics.remote_write]`, and sends the metrics to the receiver through the URL.
Taylor-lagrange marked this conversation as resolved.
Show resolved Hide resolved
2. `self_import` method: Only `frontend` and `standalone` support exporting metrics using `self_import` method. Choosing the `self_import` method means that the user specifies that the collected metrics will be sent back to `greptimedb` itself. Users can export metrics by specifying the database name to which the metrics is exported through the relevant configuration under `[export_metrics.self_import]`.

A configuration file exported using `remote_write` method:

```toml
[export_metrics]
# Whether to enable export_metrics
enable=true
# Export time interval
write_interval = "30s"
[export_metrics.remote_write]
# URL specified by Prometheus RemoteWrite protocol
url = "http://127.0.0.1:4000/v1/prometheus/write?db=information_schema"
# Some optional HTTP parameters, such as authentication information
headers = { Authorization = "Basic Z3JlcHRpbWVfdXNlcjpncmVwdGltZV9wd2Q=" }
```

A configuration file exported using `self_import`:

```toml
[export_metrics]
# Whether to enable export_metrics
enable=true
# Export time interval
write_interval = "30s"
[export_metrics.self_import]
#Select the imported database name
db = "information_schema"
```

## Environment variable

Every item in the configuration file can be mapped into environment variables. For example, if we want to set the configuration item `max_inflight_tasks` of datanode by environment variable:
Expand Down
37 changes: 37 additions & 0 deletions docs/v0.5/zh/user-guide/operations/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,43 @@ append_stdout = true

如何使用分布式追踪,请参考 [Tracing](./tracing.md)

### Export metrics 选项

`frontend`、`metasrv`、`datanode` 和 `standalone` 支持收集自身产生的 metrics 数据,并将采集到的 metrics 数据发送到[Prometheus RemoteWrite 协议](https://prometheus.io/docs/concepts/remote_write_spec/)兼容的接收端,比如发送到 `greptimedb` 自身。**注意:该功能和使用 Prometheus 收集 `greptimedb` 产生的 metrics 没有关系,该功能仅作为 `greptimedb` 导出自身产生 metrics 的一种方式。** 用户可以通过 `[export_metrics]` 部分配置相关导出参数。

总共有两种方式用于导出 metrics 数据:
1. `remote_write` 方式:所有组件均可使用该方式导出。用户通过 `[export_metrics.remote_write]` 下的相关配置,指定一个支持 Prometheus RemoteWrite 协议的 URL,将产生的数据通过 URL 发送到接收端。
2. `self_import` 方式:只有 `frontend`、`standalone` 支持使用 `self_import` 方式导出数据。选择 `self_import` 方式意味着用户指定了将收集到的 metrics 数据又送回到 `greptimedb` 自身。用户通过 `[export_metrics.self_import]` 下的相关配置,指定数据导出到的数据库库名,即可将数据导出到自身。

一份使用 `remote_write` 方式导出的配置文件:

```toml
[export_metrics]
# 是否启用 export_metrics
enable = true
# 导出时间间隔
write_interval = "30s"
[export_metrics.remote_write]
# Prometheus RemoteWrite 协议规定的 URL
url = "http://127.0.0.1:4000/v1/prometheus/write?db=information_schema"
# 一些可选的 HTTP 参数,如鉴权信息
headers = { Authorization = "Basic Z3JlcHRpbWVfdXNlcjpncmVwdGltZV9wd2Q=" }
```


一份使用 `self_import` 方式导出的配置文件:

```toml
[export_metrics]
# 是否启用 export_metrics
enable = true
# 导出时间间隔
write_interval = "30s"
[export_metrics.self_import]
# 选择导入的数据库库名
db = "information_schema"
```

## 环境变量配置

配置文件中的每一项都可以映射到环境变量。例如,如果我们想通过环境变量设置 datanode 的配置项 `data_home`:
Expand Down
Loading