【TiDB 使用环境】生产环境
【TiDB 版本】v8.4.5
在调整告警阈值时,意外发现源代码中有如下写法:
- alert: TiKV_scheduler_command_duration_seconds
expr: histogram_quantile(0.99, sum(rate(tikv_scheduler_command_duration_seconds_bucket[1m])) by (le, instance, type) / 1000) > 1
for: 1m
labels:
env: ENV_LABELS_ENV
level: warning
expr: histogram_quantile(0.99, sum(rate(tikv_scheduler_command_duration_seconds_bucket[1m])) by (le, instance, type) / 1000) > 1
annotations:
description: 'cluster: ENV_LABELS_ENV, instance: {{ $labels.instance }}, values:{{ $value }}'
value: '{{ $value }}'
summary: TiKV scheduler command duration seconds more than 1s
注意expr里有个/ 1000
起初以为这个 / 1000是毫秒到秒的转换,后来实际上手查询后发现并非如此:原始的tikv_scheduler_command_duration_seconds_bucket的le单位就是秒。经过询问AI,最后确定这个/1000的作用是直方图缩放(见下图),理论上不会实质性影响Pxx的结果。
现在有两个问题:
- 上述对 / 1000作用的描述是否准确?
- 若准确,为何要写这个/ 1000?
