prometheus部署

By | 2025 年 4 月 22 日

prometheus docker部署

docker run -d \
--name=prometheus \
-p 9090:9090 \
-v /home/prometheus/config/prometheus.yml:/etc/prometheus/prometheus.yml \
-v /home/prometheus/prometheus:/prometheus \
{harborPath}/prom/prometheus:v3.3.0

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: ["{prometheus.path}"]
       # The label name is added as a label `label_name=<label_value>` to any timeseries scraped from this config.
        labels:
          app: "prometheus"

  - job_name: 'Aserver'
    static_configs:
      - targets: [ '{Aserver.path}' ]
        labels:
          app: "Aserver"
  - job_name: 'Bserver'
    static_configs:
      - targets: [ '{Bserver.path}' ]
        labels:
          app: "Bserver"

  - job_name: '200mysql'
    static_configs:
      - targets: ['{mysql.path}']
        labels:
          instance: "200mysql"
          app: "200mysql"

grafana docker部署

docker run -d \
--name=grafana \
-p 3000:3000 \
-v /home/grafana/grafana:/var/lib/grafana \
-e "GF_SECURITY_ADMIN_PASSWORD={password}" \
{harborPath}/grafana/grafana:11.6.0

服务器监控收集器 docker部署

docker run -d \
--name 200-exporter \
--restart=always \
-p 9100:9100 \
-v /proc:/host/proc:ro \
-v /sys:/host/sys:ro \
-v /:/rootfs:ro \
{harborPath}/prom/node-exporter:241003

mysql监控收集器 docker部署

docker run -d \
-p 9104:9104 \
--name=mysqld-exporter \
-v /home/prometheus/mysql/.my.cnf:/.my.cnf \
{harborPath}/prom/mysqld-exporter:v0.17.2

.my.cnf 配置文件

[client]
user={mysql.user}
password={mysql.password}
host={mysql.host}
port={mysql.port}

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注