prometheus存储数据到influxdb中
promethus 简介
Prometheus是一套开源的系统监控报警框架。具有一下特点:
多维度数据
支持强大的存储
出色的可视化
高效存储
操作简单
精确警报
支持多种客户端
使用docker搭建promethus
- 准备配置文件
# 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).
# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
# - alertmanager:9093
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
# - "first_rules.yml"
# - "second_rules.yml"
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- 把监控数据存储到influxdb里
在Prometheus配置文件继续添加添加
remote_write:
- url: "http://192.168.3.3:8086/api/v1/prom/write?db=prometheus"
remote_read:
- url: "http://192.168.3.3:8086/api/v1/prom/read?db=prometheus"
influxdb支持通过HTTP API的方式,读写数据。所以只需填写influxdb的url和数据库名称即可
influxdb默认没有密码认证。如果influxdb开启的密码认证,需要在配置文件添加上用户名和密码
remote_write:
- url: "http://192.168.3.3:8086/api/v1/prom/write?db=prometheus&u=prometheus&p=123456"
remote_read:
- url: "http://192.168.3.3:8086/api/v1/prom/read?db=prometheus&u=prometheus&p=123456"
- 启动docker容器,并把宿主机配置文件映射到容器内部
docker container run --name promethus -p 9090:9090 -v $PWD/etc/prometheus.yml:/etc/prometheus/prometheus.yml -v /etc/localtime:/etc/localtime -d prom/prometheus
这样promethus容器就启动成功了。下次让promethus可以读取Linux主机的监控数据。