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
相关推荐
Dotrust东信创智2 小时前
面向SDV的在环测试深度解析——仿真中间件SIL KIT应用篇
网络·中间件·汽车
田一一一2 小时前
Android framework 中间件开发(三)
android·中间件·framework·jni
残花月伴3 小时前
springCloud/Alibaba常用中间件之Seata分布式事务
分布式·spring cloud·中间件
noravinsc7 小时前
国产化中间件 替换 nginx
运维·nginx·中间件
田一一一7 小时前
Android framework 中间件开发(二)
android·中间件·framework
Clown9511 小时前
go-zero(十九)使用Prometheus监控ES指标
elasticsearch·golang·prometheus
奔跑中的小象12 小时前
基于 nvitop+Prometheus+Grafana 的物理资源与 VLLM 引擎服务监控方案
grafana·prometheus·vllm·nvitop
小黑_深呼吸16 小时前
Prometheus实战教程:k8s平台-Mysql监控案例
运维·学习·kubernetes·prometheus
残花月伴1 天前
springCloud/Alibaba常用中间件之Setinel实现熔断降级
spring·spring cloud·中间件
zhujilisa1 天前
中间件-MQ常见问题
中间件