关于timestamp指标的解释
prometheus中的指标timestamp有两个:
- prometheus拉取时刻的timestamp,即服务端的timestamp:time.Now();
- exporter的/metrics接口,除了返回metric,value,还返回timestamp;
例如: 指标值后面跟着的是timestamp
# HELP container_cpu_user_seconds_total Cumulative user cpu time consumed in seconds.
# TYPE container_cpu_user_seconds_total counter
container_cpu_user_seconds_total{container="",id="/",image="",name="",namespace="",pod=""} 788250.59 1692241058502
container_cpu_user_seconds_total{container="",id="/kubepods.slice",image="",name="",namespace="",pod=""} 378238.54 1692241058529
prometheus如何使用这两种timestamp
应用honor_timestamps配置拉取指标的timestamp:
默认为 honor_timestamps=true
- honor_timestamps=true时:
应用拉取/metrics时exporter返回的timestamps;
若exporter未返回timestamps,则应用prometheus拉取时刻的timestamps(即服务端的timestamp);
- honor_timestamps=false时:
间接应用prometheus拉取时刻的timestamps(即服务端的timestamp);