prometheus Error on ingesting samples that are too old or a re too far into the future

发布时间 2023-11-03 17:22:08作者: liwenchao1995

prometheus Error on ingesting samples that are too old or a re too far into the future

之前在自己服务器上用docker部署过一个prometheus,今天更新到最新版本,结果发现在peometheus上检索我之前node-exporter的数据是没有的

查看prometheus日志发现

ts=2023-11-03T09:01:03.617Z caller=scrape.go:1741 level=warn component="scrape manager" scrape_pool=centos-40.132 target=http://192.168.40.132:9100/metrics msg="Error on ingesting samples that are too old or a
re too far into the future" num_dropped=708ts=2023-11-03T09:01:03.617Z caller=scrape.go:1350 level=warn component="scrape manager" scrape_pool=centos-40.132 target=http://192.168.40.132:9100/metrics msg="Appending scrape report failed" err="out of boun
ds"

自己的日志和其他exporter采集的数据都被丢弃了,所以开始排查,以下为排查思路
开始排查前记得备份数据,避免数据丢失

磁盘问题

检查prometheus所在机器磁盘是否写满,100%会导致prometheus数据采集失败

时间问题

因为docker部署,所以检查了宿主机和docker内部的时间,发现时间不一样,于是重新部署prometheus和exporter的时候尽量将本地时间挂载到docker内部 ,docker run的时候加上

-v /etc/localtime:/etc/localtime:ro

外面宿主机进行时间同步

ntpdate cn.pool.ntp.org   # 同步机器时间

版本问题

更新exporter版本到与prometheus相同或相近的版本

历史prometheus旧数据

因为我之前部署的旧的prometheus数据 data是挂载到宿主机的,这次部署的时候,还是用的这个旧的文件夹作为prometheus的数据文件夹,导致新的promethues用了旧的数据出现了问题,因为我这是测试环境,我直接删掉了,

删掉后重新部署,发现日志没哟爆错,在prometheus的查询页面也可以看到node的一些信息了。
对于data数据比较重视的,可以自行再找找迁移prometheus旧版本数据到新版本数据的方法,我这里没有涉及