使用influxdb支持的稳定协议连接prometheus弃用remote_storage协议

使用influxdb支持的协议连接prometheus

使用remote_storage协议去让prometheus连接influxdb数据库很不稳定,经常出现504数据无法写入influxdb的问题,并且经常无法读取到influxdb数据库的数据,因此我们弃用remote_storage协议,而采用influxdb特定的协议去让prometheus去连接

1.使用influxdb协议的前提条件

influxdb数据库至少要求1.7版本及以上,如果当前系统是1.5版本则还需要升级influxdb

官方配置文档
使用influxdb支持的稳定协议连接prometheus弃用remote_storage协议

influxdb支持的三种prometheus协议

  • /api/v1/prom/read

  • /api/v1/prom/write

  • /metrics

influxdb默认账号密码为root/root

当prometheus连接influxdb成功后,会不断地往里写入数据,随时随地都可以查到

使用了influxdb自身支持的prometheus协议后,就不必再使用remote-storage协议

2.升级influxdb1.8版本

从1.5.2.升级到1.8.1版本

1.下载1.8.1 rpm包
[root@prometheus-10-90 ~]# wget https://dl.influxdata.com/influxdb/releases/influxdb-1.8.1.x86_64.rpm

2.升级influxdb(升级或者权全新安装都是如下命令)
[root@prometheus-10-90 ~]# yum -y localinstall influxdb-1.8.1.x86_64.rpm 

使用influxdb支持的稳定协议连接prometheus弃用remote_storage协议

3.创建数据库http接口用于接收prometheus读写的数据请求

curl -XPOST http://localhost:8086/query --data-urlencode "q=CREATE DATABASE prometheus"
curl -XPOST http://localhost:8086/query --data-urlencode "q=CREATE DATABASE k8s_prometheus"

4.修改prometheus配置文件增加协议配置

1.修改配置文件
[root@prometheus-10-90 ~]# vim /data/prometheus/prometheus.yml
remote_write:
  - url: "http://192.168.10.90:8086/api/v1/prom/write?db=prometheus"
remote_read:
  - url: "http://192.168.10.90:8086/api/v1/prom/read?db=prometheus"

2.重启prometheus
[root@prometheus-10-90 ~]# systemctl restart prometheus

5.使用InfluxDBStudio查看数据

连接influxdb

使用influxdb支持的稳定协议连接prometheus弃用remote_storage协议

查看数据,正真连接好influxdb数据库后,会不停的往里面写入数据

使用influxdb支持的稳定协议连接prometheus弃用remote_storage协议

上一篇:Kubernetes学习日记(三)


下一篇:脚本安装influxdb