TiDB¶
TiDB のビューには、概要(起動時刻、ストレージ情報、ノード情報など)、cluster(クラスタ関連情報)、TiDB、Etcd、Region などの関連メトリクス情報が表示されます。
インストール設定¶
バージョン対応¶
対応バージョンは TiDB 自体のシステムサポートに依存します
注: 例示の TiDB バージョンは 6.3+
(Linux / Windows 環境は同じ)
TiDB をインストールする場合は、ドキュメント TiDB ローカルテストクラスタのデプロイ を参照してください
以下の収集手順は、すべて TiDB ローカルテストクラスタのデプロイ のデプロイ方法に従って収集します。
メトリクス収集設定¶
TiDB の各コンポーネント(計 4 コンポーネント)はすべて metrics を公開しており、プロトコルは http です
| コンポーネント | metrics ポート |
|---|---|
| TiDB | 10080 |
| pd | 2379 |
| TiKV | 20180 |
| TiFlash | 8234 20292 |
上記は単一ノードクラスタでのコンポーネント配置に対応する metrics ポートです。複数ノードクラスタの場合も、ポートの指定方法は同様です
DataKit コレクタを有効化する¶
-
sample ファイルをコピーする
-
tidb_prom.confを調整する
tidb_prom.conf
[[inputs.prom]]
# Exporter URLs.
# urls = ["http://127.0.0.1:9100/metrics", "http://127.0.0.1:9200/metrics"]
urls = ["http://0.0.0.0:10080/metrics"]
# Unix Domain Socket URL. Using socket to request data when not empty.
uds_path = ""
# Ignore URL request errors.
ignore_req_err = false
## Collector alias.
source = "tidb_prom"
## Metrics type whitelist. Optional: counter, gauge, histogram, summary
# Default only collect 'counter' and 'gauge'.
# Collect all if empty.
metric_types = ["counter", "gauge","histogram"]
## Measurement prefix.
# Add prefix to measurement set name.
measurement_prefix = "tidb_"
## TLS configuration.
tls_open = false
# tls_ca = "/tmp/ca.crt"
# tls_cert = "/tmp/peer.crt"
# tls_key = "/tmp/peer.key"
## Set to 'true' to enable election.
election = true
# Ignore tags. Multi supported.
# The matched tags would be dropped, but the item would still be sent.
# tags_ignore = ["xxxx"]
## Customize authentification. For now support Bearer Token only.
# Filling in 'token' or 'token_file' is acceptable.
# [inputs.prom.auth]
# type = "bearer_token"
# token = "xxxxxxxx"
# token_file = "/tmp/token"
## Customize measurement set name.
# Treat those metrics with prefix as one set.
# Prioritier over 'measurement_name' configuration.
#[[inputs.prom.measurements]]
# prefix = "cpu_"
# name = "cpu"
# [[inputs.prom.measurements]]
# prefix = "mem_"
# name = "mem"
# Not collecting those data when tag matched.
[inputs.prom.ignore_tag_kv_match]
# key1 = [ "val1.*", "val2.*"]
# key2 = [ "val1.*", "val2.*"]
# Add HTTP headers to data pulling.
[inputs.prom.http_headers]
# Root = "passwd"
# Michael = "1234"
# Rename tag key in prom data.
[inputs.prom.tags_rename]
overwrite_exist_tags = false
[inputs.prom.tags_rename.mapping]
# tag1 = "new-name-1"
# tag2 = "new-name-2"
# tag3 = "new-name-3"
# Send collected metrics to center as log.
# When 'service' field is empty, using 'service tag' as measurement set name.
[inputs.prom.as_logging]
enable = false
service = "service_name"
## Customize tags.
[inputs.prom.tags]
tidb_cluster="test"
1. sample ファイルをコピーする
```shell hl_lines="2"
cd /usr/local/datakit/conf.d/samples/
cp prom.conf.sample tidb_pd_prom.conf
```
2. `tidb_pd_prom.conf` を調整する
??? info "`tidb_pd_prom.conf`"
``` toml hl_lines="4 12 21 29 91 92 93 94 95 108"
[[inputs.prom]]
# Exporter URLs.
# urls = ["http://127.0.0.1:9100/metrics", "http://127.0.0.1:9200/metrics"]
urls = ["http://0.0.0.0:2379/metrics"]
# Unix Domain Socket URL. Using socket to request data when not empty.
uds_path = ""
# Ignore URL request errors.
ignore_req_err = false
## Collector alias.
source = "tidb_pd_prom"
## Collect data output.
# Fill this when want to collect the data to local file nor center.
# After filling, could use 'datakit --prom-conf /path/to/this/conf' to debug local storage measurement set.
# Using '--prom-conf' when priority debugging data in 'output' path.
# output = "/abs/path/to/file"
## Collect data upper limit as bytes.
# Only available when set output to local file.
# If collect data exceeded the limit, the data would be dropped.
# Default is 32MB.
# max_file_size = 0
## Metrics type whitelist. Optional: counter, gauge, histogram, summary
# Default only collect 'counter' and 'gauge'.
# Collect all if empty.
metric_types = ["counter", "gauge"]
## Metrics name whitelist.
# Regex supported. Multi supported, conditions met when one matched.
# Collect all if empty.
# metric_name_filter = ["cpu"]
## Measurement prefix.
# Add prefix to measurement set name.
measurement_prefix = "tidb_pd_"
## Measurement name.
# If measurement_name is empty, split metric name by '_', the first field after split as measurement set name, the rest as current metric name.
# If measurement_name is not empty, using this as measurement set name.
# Always add 'measurement_prefix' prefix at last.
# measurement_name = "prom"
## TLS configuration.
tls_open = false
# tls_ca = "/tmp/ca.crt"
# tls_cert = "/tmp/peer.crt"
# tls_key = "/tmp/peer.key"
## Set to 'true' to enable election.
election = true
# Ignore tags. Multi supported.
# The matched tags would be dropped, but the item would still be sent.
# tags_ignore = ["xxxx"]
## Customize authentification. For now support Bearer Token only.
# Filling in 'token' or 'token_file' is acceptable.
# [inputs.prom.auth]
# type = "bearer_token"
# token = "xxxxxxxx"
# token_file = "/tmp/token"
## Customize measurement set name.
# Treat those metrics with prefix as one set.
# Prioritier over 'measurement_name' configuration.
#[[inputs.prom.measurements]]
# prefix = "cpu_"
# name = "cpu"
# [[inputs.prom.measurements]]
# prefix = "mem_"
# name = "mem"
# Not collecting those data when tag matched.
[inputs.prom.ignore_tag_kv_match]
# key1 = [ "val1.*", "val2.*"]
# key2 = [ "val1.*", "val2.*"]
# Add HTTP headers to data pulling.
[inputs.prom.http_headers]
# Root = "passwd"
# Michael = "1234"
# Rename tag key in prom data.
[inputs.prom.tags_rename]
#overwrite_exist_tags = false
overwrite_exist_tags = false
[inputs.prom.tags_rename.mapping]
cluster_version = "version"
server_id = "s_id"
server_version = "version"
server_go_version = "version"
# tag1 = "new-name-1"
# tag2 = "new-name-2"
# tag3 = "new-name-3"
# Send collected metrics to center as log.
# When 'service' field is empty, using 'service tag' as measurement set name.
[inputs.prom.as_logging]
enable = false
service = "service_name"
## Customize tags.
[inputs.prom.tags]
tidb_cluster="test"
```
1. sample ファイルをコピーする
```shell hl_lines="2"
cd /usr/local/datakit/conf.d/samples/
cp prom.conf.sample tidb_tikv_prom.conf
```
2. `tidb_tikv_prom.conf` を調整する
??? info "`tidb_tikv_prom.conf`"
``` toml hl_lines="4 12 29 38 103"
[[inputs.prom]]
# Exporter URLs.
# urls = ["http://127.0.0.1:9100/metrics", "http://127.0.0.1:9200/metrics"]
urls = ["http://0.0.0.0:20180/metrics"]
# Unix Domain Socket URL. Using socket to request data when not empty.
uds_path = ""
# Ignore URL request errors.
ignore_req_err = false
## Collector alias.
source = "tidb_tikv_prom"
## Collect data output.
# Fill this when want to collect the data to local file nor center.
# After filling, could use 'datakit --prom-conf /path/to/this/conf' to debug local storage measurement set.
# Using '--prom-conf' when priority debugging data in 'output' path.
# output = "/abs/path/to/file"
## Collect data upper limit as bytes.
# Only available when set output to local file.
# If collect data exceeded the limit, the data would be dropped.
# Default is 32MB.
# max_file_size = 0
## Metrics type whitelist. Optional: counter, gauge, histogram, summary
# Default only collect 'counter' and 'gauge'.
# Collect all if empty.
metric_types = ["counter", "gauge"]
## Metrics name whitelist.
# Regex supported. Multi supported, conditions met when one matched.
# Collect all if empty.
# metric_name_filter = ["cpu"]
## Measurement prefix.
# Add prefix to measurement set name.
measurement_prefix = "tidb_tikv_"
## Measurement name.
# If measurement_name is empty, split metric name by '_', the first field after split as measurement set name, the rest as current metric name.
# If measurement_name is not empty, using this as measurement set name.
# Always add 'measurement_prefix' prefix at last.
# measurement_name = "prom"
## TLS configuration.
tls_open = false
# tls_ca = "/tmp/ca.crt"
# tls_cert = "/tmp/peer.crt"
# tls_key = "/tmp/peer.key"
## Set to 'true' to enable election.
election = true
# Ignore tags. Multi supported.
# The matched tags would be dropped, but the item would still be sent.
# tags_ignore = ["xxxx"]
## Customize authentification. For now support Bearer Token only.
# Filling in 'token' or 'token_file' is acceptable.
# [inputs.prom.auth]
# type = "bearer_token"
# token = "xxxxxxxx"
# token_file = "/tmp/token"
## Customize measurement set name.
# Treat those metrics with prefix as one set.
# Prioritier over 'measurement_name' configuration.
#[[inputs.prom.measurements]]
# prefix = "cpu_"
# name = "cpu"
# [[inputs.prom.measurements]]
# prefix = "mem_"
# name = "mem"
# Not collecting those data when tag matched.
[inputs.prom.ignore_tag_kv_match]
# key1 = [ "val1.*", "val2.*"]
# key2 = [ "val1.*", "val2.*"]
# Add HTTP headers to data pulling.
[inputs.prom.http_headers]
# Root = "passwd"
# Michael = "1234"
# Rename tag key in prom data.
[inputs.prom.tags_rename]
overwrite_exist_tags = false
[inputs.prom.tags_rename.mapping]
# tag1 = "new-name-1"
# tag2 = "new-name-2"
# tag3 = "new-name-3"
# Send collected metrics to center as log.
# When 'service' field is empty, using 'service tag' as measurement set name.
[inputs.prom.as_logging]
enable = false
service = "service_name"
## Customize tags.
[inputs.prom.tags]
tidb_cluster="test"
```
1. sample ファイルをコピーする
```shell hl_lines="2"
cd /usr/local/datakit/conf.d/samples/
cp prom.conf.sample tidb_tiflash_prom.conf
```
2. `tidb_tiflash_prom.conf` を調整する
??? info "`tidb_tiflash_prom.conf`"
``` toml hl_lines="4 12 29 38 103"
[[inputs.prom]]
# Exporter URLs.
# urls = ["http://127.0.0.1:9100/metrics", "http://127.0.0.1:9200/metrics"]
urls = ["http://0.0.0.0:8234/metrics","http://0.0.0.0:20292/metrics"]
# Unix Domain Socket URL. Using socket to request data when not empty.
uds_path = ""
# Ignore URL request errors.
ignore_req_err = false
## Collector alias.
source = "tidb_tiflash"
## Collect data output.
# Fill this when want to collect the data to local file nor center.
# After filling, could use 'datakit --prom-conf /path/to/this/conf' to debug local storage measurement set.
# Using '--prom-conf' when priority debugging data in 'output' path.
# output = "/abs/path/to/file"
## Collect data upper limit as bytes.
# Only available when set output to local file.
# If collect data exceeded the limit, the data would be dropped.
# Default is 32MB.
# max_file_size = 0
## Metrics type whitelist. Optional: counter, gauge, histogram, summary
# Default only collect 'counter' and 'gauge'.
# Collect all if empty.
metric_types = ["counter", "gauge"]
## Metrics name whitelist.
# Regex supported. Multi supported, conditions met when one matched.
# Collect all if empty.
# metric_name_filter = ["cpu"]
## Measurement prefix.
# Add prefix to measurement set name.
measurement_prefix = "tidb_tiflash_"
## Measurement name.
# If measurement_name is empty, split metric name by '_', the first field after split as measurement set name, the rest as current metric name.
# If measurement_name is not empty, using this as measurement set name.
# Always add 'measurement_prefix' prefix at last.
# measurement_name = "prom"
## TLS configuration.
tls_open = false
# tls_ca = "/tmp/ca.crt"
# tls_cert = "/tmp/peer.crt"
# tls_key = "/tmp/peer.key"
## Set to 'true' to enable election.
election = true
# Ignore tags. Multi supported.
# The matched tags would be dropped, but the item would still be sent.
# tags_ignore = ["xxxx"]
## Customize authentification. For now support Bearer Token only.
# Filling in 'token' or 'token_file' is acceptable.
# [inputs.prom.auth]
# type = "bearer_token"
# token = "xxxxxxxx"
# token_file = "/tmp/token"
## Customize measurement set name.
# Treat those metrics with prefix as one set.
# Prioritier over 'measurement_name' configuration.
#[[inputs.prom.measurements]]
# prefix = "cpu_"
# name = "cpu"
# [[inputs.prom.measurements]]
# prefix = "mem_"
# name = "mem"
# Not collecting those data when tag matched.
[inputs.prom.ignore_tag_kv_match]
# key1 = [ "val1.*", "val2.*"]
# key2 = [ "val1.*", "val2.*"]
# Add HTTP headers to data pulling.
[inputs.prom.http_headers]
# Root = "passwd"
# Michael = "1234"
# Rename tag key in prom data.
[inputs.prom.tags_rename]
overwrite_exist_tags = false
[inputs.prom.tags_rename.mapping]
# tag1 = "new-name-1"
# tag2 = "new-name-2"
# tag3 = "new-name-3"
# Send collected metrics to center as log.
# When 'service' field is empty, using 'service tag' as measurement set name.
[inputs.prom.as_logging]
enable = false
service = "service_name"
## Customize tags.
[inputs.prom.tags]
tidb_cluster="test"
```
マークした箇所を調整する必要があります
主なパラメータの説明:
- urls:
prometheusメトリクスのアドレス。ここには対応コンポーネントが公開しているメトリクス URL を記入します - source:コレクタの別名。識別できるように分けることを推奨します
- interval:収集間隔
- measurement_prefix: メトリクスセットのプレフィックス。管理と分類をしやすくします
- tls_open:TLS 設定
- metric_types:メトリクス種別。未指定ならすべてのメトリクスを収集します。タイムラインに関わるため、必要に応じて設定することを推奨します
- tags_ignore:不要な tag を無視します
- [inputs.prom.tags_rename.mapping]:tag の名前を変更します。tag と field の名前が重複する場合は tag をリネームする必要があります。そうしないとメトリクス全体を収集できません。
- [inputs.prom.tags] :tag を設定します。現在の metrics のすべてのメトリクスに適用されます