Note that Prometheus by default uses around 3GB in memory. If you have a smaller machine, you can tune Prometheus to use less memory. For details, see the memory usage documentation.
# HELP prometheus_tsdb_compaction_chunk_range Final time range of chunks on their first compaction
# TYPE prometheus_tsdb_compaction_chunk_range histogram
prometheus_tsdb_compaction_chunk_range_bucket{le="100"} 0# prometheus_tsdb_compaction_chunk_range 小于或等于100的次数
prometheus_tsdb_compaction_chunk_range_bucket{le="400"} 0
prometheus_tsdb_compaction_chunk_range_bucket{le="1600"} 0
prometheus_tsdb_compaction_chunk_range_bucket{le="6400"} 0
prometheus_tsdb_compaction_chunk_range_bucket{le="25600"} 80
prometheus_tsdb_compaction_chunk_range_bucket{le="102400"} 974
prometheus_tsdb_compaction_chunk_range_bucket{le="409600"} 1386
prometheus_tsdb_compaction_chunk_range_bucket{le="1.6384e+06"} 112157
prometheus_tsdb_compaction_chunk_range_bucket{le="6.5536e+06"} 821535
prometheus_tsdb_compaction_chunk_range_bucket{le="2.62144e+07"} 821545
prometheus_tsdb_compaction_chunk_range_bucket{le="+Inf"} 821545
prometheus_tsdb_compaction_chunk_range_sum 1.334532601458e+12
prometheus_tsdb_compaction_chunk_range_count 821545
这个直方图的 X 轴为 le 的值,Y 轴为次数;如果需要得到百分位数,可以使用 histogram_quantile() 函数:
# HELP prometheus_tsdb_head_gc_duration_seconds Runtime of garbage collection in the head block.
# TYPE prometheus_tsdb_head_gc_duration_seconds summary
prometheus_tsdb_head_gc_duration_seconds{quantile="0.5"} 0.03043428
prometheus_tsdb_head_gc_duration_seconds{quantile="0.9"} 0.03043428
prometheus_tsdb_head_gc_duration_seconds{quantile="0.99"} 0.03043428
prometheus_tsdb_head_gc_duration_seconds_sum 0.70902013
prometheus_tsdb_head_gc_duration_seconds_count 11
groups:
- name: example
rules:
- record: job:http_inprogress_requests:sum
expr: sum(http_inprogess_requests) by (job)
计算的频率在 global.evaluation_interval 中定义:
global:
[ evaluation_interval: | default = 1m ]
Prometheus alert rules
ALERT
IF # PromQL 查询的值
[ FOR ]# 触发告警的持续时间
[ LABELS ]
[ ANNOTATIONS ]example:
# Alert for any instance that is unreachable for >5 minutes.
ALERT InstanceDown
IF up == 0
FOR 5m
LABELS { severity = "page" }
ANNOTATIONS {
summary = "Instance {{ $labels.instance }} down",
description = "{{ $labels.instance }} of job {{ $labels.job }} has been down for more than 5 minutes.",
}# Alert for any instance that have a median request latency >1s.
ALERT APIHighRequestLatency
IF api_http_request_latencies_second{quantile="0.5"} > 1
FOR 1m
ANNOTATIONS {
summary = "High request latency on {{ $labels.instance }}",
description = "{{ $labels.instance }} has a median request latency above 1s (current value: {{ $value }}s)",
}
reload
允许通过 Web 的方式:--web.enable-lifecycle
POST /-/reload
参考