influxdb做prometheus永久存储

一、安装influxdb

1、下载rpm包

#  wget https://dl.influxdata.com/influxdb/releases/influxdb-1.8.1.x86_64.rpm

2、yum安装

#  yum  localinstall influxdb-1.8.1.x86_64.rpm

3、修改配置文件 /etc/influxdb/influxdb.conf

[meta]
  dir = "/var/lib/influxdb/meta"    #存放最终存储的数据,文件以.tsm结尾

[data]
  dir = "/var/lib/influxdb/data"       #存放数据库元数据
  wal-dir = "/var/lib/influxdb/wal"  #存放预写日志文件

[http]
  log-enabled = false   #关闭网页登陆
  access-log-path = "/var/lib/influxdb/influxdb.log"

4、启动influxdb

# systemctl start influex
# systemctl status influex
# systemctl enable influex

5、创建数据库和授权用户

[root@localhost influxdb]# influx
Connected to http://localhost:8086 version 1.8.1
InfluxDB shell version: 1.8.1
> show databases;
name: databases
name
----
_internal
> create database promethes;
> show databases;
name: databases
name
----
_internal
prometheus
> create user "admin" with password 'Admin123' with all privileges;

6、编辑prometheus.yml文件

remote_write:
  - url: "http://localhost:8086/api/v1/prom/write?db=prometheus"
    basic_auth:
      username: admin
      password: Admin123

remote_read:
  - url: "http://localhost:8086/api/v1/prom/read?db=prometheus"
    basic_auth:
      username: admin
      password: Admin123

重启prometheus

7、验证数据

[root@localhost ~]# influx
Connected to http://localhost:8086 version 1.8.1
InfluxDB shell version: 1.8.1
> use prometheus;
Using database prometheus
> show measurements;
name: measurements
name
----
go_gc_duration_seconds
go_gc_duration_seconds_count
go_gc_duration_seconds_sum
go_goroutines
go_info
go_memstats_alloc_bytes
go_memstats_alloc_bytes_total
go_memstats_buck_hash_sys_bytes
go_memstats_frees_total
go_memstats_gc_cpu_fraction
go_memstats_gc_sys_bytes
....................................

> select * from up limit 10;
name: up
time                __name__ instance           job           value
----                -------- --------           ---           -----
1600421728016000000 up       172.16.68.169:9308 kafka         0
1600421729540000000 up       172.16.68.169:9100 centos7-benji 0
1600421731123000000 up       localhost:9090     prometheus    1
1600421733845000000 up       172.16.68.169:9091 cpu-memory    0
1600421743017000000 up       172.16.68.169:9308 kafka         0
1600421744540000000 up       172.16.68.169:9100 centos7-benji 0
1600421746123000000 up       localhost:9090     prometheus    1
1600421748846000000 up       172.16.68.169:9091 cpu-memory    0
1600421758018000000 up       172.16.68.169:9308 kafka         0
1600421759540000000 up       172.16.68.169:9100 centos7-benji 0

 

posted @ 2020-09-23 16:26  灰蓝色的白云梦想  阅读(793)  评论(0编辑  收藏  举报