docker安装prometheus/grafana
prometheus
安装prometheus
1.拉取镜像
docker pull prom/prometheus
2.创建prometheus目录,新增prometheus.yml文件,用于指定设置docker地址
mkdir -p /opt/prometheus、vi /opt/prometheus/prometheus.yml
3.创建prometheus容器,指定端口、名称、挂载目录、设置时区
docker run -itd --name prometheus -p 9090:9090 -v /opt/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml -v /etc/localtime:/etc/localtime:ro prom/prometheus
4.访问页面
192.168.0.52:9090
prometheus配置文件
# 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"]
- job_name: 'http_status'
metrics_path: /probe
params:
module: [http_2xx]
static_configs:
- targets: ['https://baidu.com']
labels:
instance: baidu.com
group: web
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- target_label: __address__
replacement: 192.168.0.100:9115
组件
安装Blackbox组件
docker pull prom/blackbox-exporter
docker run --name blackbox -p 9115:9115 -itd prom/blackbox-exporter
安装node-exporter组件
主题:11074
docker pull prom/node-exporter
docker run -d -p 9100:9100 prom/node-exporter
安装启动grafana
docker run -d --name=grafana -p 3000:3000 -v /data:/var/lib/grafana grafana/grafana-enterprise:8.5.1-ubuntu
选择了IT,必定终身学习