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
相关推荐
字节全栈_OYI12 小时前
Koa 基础篇(二)—— 路由与中间件
中间件
谢大旭12 小时前
ASP.NET Core 中间件
后端·中间件·c#
开着拖拉机回家3 天前
【Prometheus】jmx_prometheus_javaagent监控java应用
prometheus·javaagent·进程监控·jmx·historyserver
乐维_lwops5 天前
Prometheus+grafana实践:Doris数据库的监控
数据库·grafana·prometheus
大新新大浩浩6 天前
centos操作系统上以service形式运行blackbox_exporter监控网页端口
centos·prometheus
会飞的土拨鼠呀6 天前
Prometheus监控minio对象存储
运维·prometheus
醉の虾7 天前
VUE3 使用路由守卫函数实现类型服务器端中间件效果
前端·vue.js·中间件
hcja6668 天前
CVE-2024-23897-Jenkins任意文件读取漏洞复现
运维·web安全·网络安全·中间件·jenkins
景天科技苑8 天前
【Prometheus】RabbitMQ安装部署,如何通过prometheus监控RabbitMQ
消息队列·rabbitmq·prometheus·rabbitmq安装·rabbitmq配置
一袋米扛几楼988 天前
【运维】什么是Prometheus普罗米修斯?组件式开发
运维·prometheus