Prometheus写入influxDB:中间件remote_storage_adapter

Prometheus写入influxDB:中间件remote_storage_adapter

prometheus默认采用的是本地磁盘做数据存储,本地存储的优势就是运维简单但是缺点就是无法海量的metrics持久化和数据存在丢失的风险,数据写入可能造成wal文件损坏导致采集数据无法再写入的问题。

为了解决单节点存储的限制,prometheus没有自己实现集群存储,而是提供了远程读写的接口,让用户自己选择合适的时序数据库来实现prometheus的扩展性。

Prometheus 提供接口将数据写入到第三方存储系统亦提供接口读取第三方存储系统存储的数据原理如下所示:

接下来我们将node_exporter收集到Prometheus的数据持久化到influxdb数据库中

1.首先我们进入对应网站进行remote_storage_adapte下载:https://download.csdn.net/download/javaee_gao/12451525

2.将下载下来的文件包通过xshell上传到我们需要安装remote_storage_adapte的服务器上,我这里选择的服务器为:

xml 复制代码
[root@localhost Stability]# cat /etc/redhat-release 
CentOS Linux release 7.4.1708 (Core)

把程序包放到一个目录下面:

xml 复制代码
[root@localhost Stability]# pwd
/ftp/Stability
[root@localhost Stability]# ll |grep remote
-rw-r--r-- 1 root root 19878504 Mar 19 15:24 remote_storage_adapter
赋予相应的权限:
[root@localhost Stability]# chmod 777 remote_storage_adapter

2.然后我们启动该程序

xml 复制代码
[root@localhost Stability]# nohup ./remote_storage_adapter --influxdb-url=http://127.0.0.1:8086/ --influxdb.database="prometheus" --influxdb.retention-policy=autogen &

3.然后进入prometheus中prometheus.yml文件,使用vim进行编辑,添加如下内容

xml 复制代码
[root@localhost prometheus]# vi prometheus.yml
增加内容如下:
[root@localhost prometheus]# cat prometheus.yml 
# my global config
global:
  scrape_interval:     15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
  # scrape_timeout is set to the global default (10s).
# 远程写配置
remote_write:
  - url: "http://localhost:9201/write"
  # 配置连接influxdb连接的用户名与密码
    basic_auth:
      username: DGAtest
      password: DGAtest123
# 远程读配置
remote_read:
  - url: "http://localhost:9201/read"
    basic_auth:
      username: DGAtest
      password: DGAtest123

4.重启prometheus服务

xml 复制代码
[root@localhost prometheus]# systemctl restart prometheus

5.查看influxDB中是否有对应的数据信息(实际测试我使用了1.8.4的inflluxdb版本)

xml 复制代码
[root@localhost prometheus]# influx
Connected to http://localhost:8086 version 1.8.4
InfluxDB shell version: 1.8.4
> use prometheus
Using database prometheus
> show measurements
name: measurements
name
----
go_gc_duration_seconds
go_gc_duration_seconds_count
go_gc_duration_seconds_sum
相关推荐
在未来等你1 天前
RabbitMQ面试精讲 Day 5:Virtual Host与权限控制
中间件·面试·消息队列·rabbitmq
软件测试-阿涛2 天前
【性能测试】Jmeter+Grafana+InfluxDB+Prometheus Windows安装部署教程
测试工具·jmeter·性能优化·压力测试·grafana·prometheus
Whoisshutiao2 天前
网安-中间件-Redis未授权访问漏洞
中间件
半新半旧4 天前
FastAPI中间件
中间件·fastapi
lpt1111111114 天前
prometheus + grafana 搭建
java·grafana·prometheus
广目软件5 天前
GM DC Monitor v2.1平台部署手册分享
运维·服务器·zabbix·运维开发·prometheus
技术栈壳5 天前
Prometheus+altermanager搭配钉钉报警
prometheus
c_zyer5 天前
Kafka监控体系搭建:基于Prometheus+JMX+Grafana的全方位性能观测方案
kafka·grafana·prometheus·jmx
文人sec6 天前
性能测试-从0到1搭建性能测试环境Jmeter+Grafana+influxDB+Prometheus+Linux
jmeter·grafana·prometheus
努力找工作的OMArmy6 天前
分布式数据库中间件ShardingSphere
数据库·分布式·中间件