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"
-
sample 파일 복사
-
tidb_pd_prom.conf조정
tidb_pd_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: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"
-
sample 파일 복사
-
tidb_tikv_prom.conf조정
tidb_tikv_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: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"
-
sample 파일 복사
-
tidb_tiflash_prom.conf조정
tidb_tiflash_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: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의 모든 지표에 적용됩니다