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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM