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
相关推荐
鱼饼6号1 小时前
Prometheus 上手指南
linux·运维·centos·prometheus
问道飞鱼1 小时前
分布式中间件-Pika一个高效的分布式缓存组件
分布式·缓存·中间件
懒洋洋的华3698 小时前
消息队列-Kafka(概念篇)
分布式·中间件·kafka
Alone80461 天前
prometheus概念
prometheus
happycao1231 天前
kafka 一步步探究消费者组与分区分配策略
中间件·kafka
问道飞鱼2 天前
分布式中间件-redis相关概念介绍
redis·分布式·中间件
苹果酱05672 天前
使用 React Testing Library 测试自定义 React Hooks
java·开发语言·spring boot·后端·中间件
没有名字的小羊2 天前
fastjson漏洞
运维·网络·web安全·中间件
竹等寒2 天前
中间件常见漏洞
android·web安全·网络安全·中间件
problc2 天前
零拷贝技术在现代编程语言和中间件中的应用
中间件