Prometheus 将数据远程写入 InfluxDB 存储
InfluxDB 2.0 使用 Prometheus 架构图
InfluxDB 2.0 不使用 Prometheus 架构图
InfluxDB 2.0 与 Telegraf 如何结合配置
version: '3'
services:
influxdb:
image: 'influxdb:1.8'
container_name: influxdb
network_mode: host
volumes:
- './influxdb:/var/lib/influxdb'
#ports:
# - '8086:8086'
mysql:
image: mysql:8.0
restart: always
container_name: mysql
network_mode: host
environment:
TZ: Asia/Shanghai
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: grafana
MYSQL_USER: grafana
MYSQL_PASSWORD: grafana
MYSQL_ROOT_HOST: '%'
MYSQL_DEFAULT_AUTHENTICATION_PLUGIN: mysql_native_password # 设置使用 MySQL 5.7 的加密算法
volumes:
- ./mysql:/var/lib/mysql
#ports:
# - "3306:3306
prometheus:
image: prom/prometheus
container_name: prometheus
network_mode: host
environment:
TZ: Asia/Shanghai
#ports:
# - "9090:9090"
volumes:
#- ./prometheus/k8s.token:/etc/prometheus/k8s.token
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
command:
- '--config.file=/etc/prometheus/prometheus.yml'
grafana:
image: grafana/grafana
#image: grafana/grafana:8.5.27
container_name: grafana
network_mode: host
volumes:
- ./grafana/grafana.ini:/etc/grafana/grafana.ini
depends_on:
- mysql
#ports:
# - "53000:3000"
[root@worker1 aaa]# cat prometheus/prometheus.yml
global:
scrape_interval: 15s
remote_write:
- url: "http://<influxdb>:8086/api/v1/prom/write?db=prometheus"
remote_read:
- url: "http://<influxdb>:8086/api/v1/prom/read?db=prometheus"
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
- job_name: 'test'
static_configs:
- targets: ['8.8.8.8:9100']
[root@worker1 aaa]# cat grafana/grafana.ini
......略
[database]
type = mysql
host = you_mysql_adderss:3306
name = grafana
user = grafana
password = grafana
[paths]
data = mysql
http://xxxx:3000
admin/admin
测试: 启动,收集一点数据,再卸载容器,再启动容器,查看刚刚收集的数据是否存在,存在就说明持久化成功