1.部署规范目录
mkdir -pv /data/project/prometheus/{conf,data}
cd /data/project/prometheus/
# /data/project/prometheus/conf # 配置文件目录
# /data/project/prometheus/conf # 数据存储目录
2.配置文件
文件: /data/project/prometheus/conf/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).
# 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.
- job_name: 'prometheus'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ['localhost:9090']
3.启动服务
文件: start.sh
#!/bin/bash
#author: linuxhub.cn
configure_file=/data/project/prometheus/conf
prometheus_data=/data/project/prometheus/data
chown -R 65534:65534 ${configure_file}
chown -R 65534:65534 ${prometheus_data}
docker run -d \
--name prometheus \
--restart=always \
-p 9090:9090 \
-v ${configure_file}:/etc/prometheus \
-v ${prometheus_data}:/prometheus/data \
linuxhub/prometheus:v2.11.2 \
--config.file=/etc/prometheus/prometheus.yml \
--storage.tsdb.path=/prometheus/data \
--web.enable-lifecycle
4.停止服务
docker stop prometheus && docker rm prometheus
5.热加载配置文件
curl -X POST http://localhost:9090/-/reload
6.访问验证
http://{ip}:9090
网友评论