Promethus(普罗米修斯)监控随笔
promethus安装
下载安装包:
[bravo@tcontrol src]$ sudo wget https://github.com/prometheus/prometheus/releases/download/v2.21.0-rc.0/prometheus-2.21.0-rc.0.linux-amd64.tar.gz
2020-09-01 14:29:45 (25.2 KB/s) - 已保存 “prometheus-2.21.0-rc.0.linux-amd64.tar.gz” [64405384/64405384])
[bravo@tcontrol src]$ ls
nginx-1.14.2 nginx-1.14.2.tar.gz nginx-module-vts prometheus-2.21.0-rc.0.linux-amd64.tar.gz
[bravo@tcontrol src]$ sudo tar zxvf prometheus-2.21.0-rc.0.linux-amd64.tar.gz
[bravo@tcontrol src]$ cp -r prometheus-2.21.0-rc.0.linux-amd64/* /apps/svr/prometheus/
创建普罗米修斯配置文件目录及数据目录
[bravo@tcontrol conf]$ mkdir -p /apps/conf/prometheus/rules/
[bravo@tcontrol prometheus]$ cp -r /apps/svr/prometheus/console_libraries /apps/conf/prometheus/
[bravo@tcontrol prometheus]$ cp -r /apps/svr/prometheus/consoles /apps/conf/prometheus/
[bravo@tcontrol conf]$ mkdir -p /apps/data/prometheus
配置配置文件
[bravo@tcontrol conf]$ vi /apps/conf/prometheus/prometheus.yml
global:
evaluation_interval: 15s
scrape_interval: 15s
scrape_timeout: 10s
external_labels:
environment: loaclhost
rule_files:
- /apps/conf/prometheus/rules/*.rules
scrape_configs:
- job_name: prometheus
metrics_path: /metrics
static_configs:
- targets:
- 172.16.96.24:9090
alerting:
alertmanagers:
- static_configs:
- targets: ["localhost:9093"]
创建systemctl启动文件
[bravo@tcontrol conf]$ sudo vi /etc/systemd/system/prometheus.service
[Unit]
Description=Prometheus
After=network-online.target
[Service]
Type=simple
Environment="GOMAXPROCS=2"
User=bravo
Group=bravo
ExecReload=/bin/kill -HUP $MAINPID
ExecStart=/apps/svr/prometheus/prometheus \
--config.file=/apps/conf/prometheus/prometheus.yml \
--storage.tsdb.path=/apps/data/prometheus \
--storage.tsdb.retention.time=30d \
--storage.tsdb.retention.size=0 \
--web.console.libraries=/apps/conf/prometheus/console_libraries \
--web.console.templates=/apps/conf/prometheus/consoles \
--web.listen-address=0.0.0.0:9090 \
--web.external-url=
PrivateTmp=true
PrivateDevices=true
ProtectHome=true
NoNewPrivileges=true
LimitNOFILE=infinity
ReadWriteDirectories=/apps/data/prometheus
ProtectSystem=full
SyslogIdentifier=prometheus
Restart=always
[Install]
WantedBy=multi-user.target
启动普罗米修斯
[bravo@tcontrol conf]$ sudo systemctl daemon-reload
[bravo@tcontrol conf]$ sudo systemctl enable prometheus
Created symlink from /etc/systemd/system/multi-user.target.wants/prometheus.service to /etc/systemd/system/prometheus.service.
[bravo@tcontrol conf]$ sudo systemctl start prometheus
[bravo@tcontrol conf]$ sudo systemctl status prometheus
● prometheus.service - Prometheus
Loaded: loaded (/etc/systemd/system/prometheus.service; enabled; vendor preset: disabled)
Active: active (running) since 二 2020-09-01 15:05:27 CST; 4s ago
Main PID: 26667 (prometheus)
Tasks: 7
Memory: 24.7M
CGroup: /system.slice/prometheus.service
└─26667 /apps/svr/prometheus/prometheus --config.file=/apps/conf/prometheus/prometheus.yml --storage.tsdb.path=/apps/data/prometheus --storage.tsdb.retention.time=30d --storage.tsdb.retention.size=0 --web.console.libraries=...
9月 01 15:05:27 tcontrol prometheus[26667]: level=info ts=2020-09-01T07:05:27.550Z caller=head.go:644 component=tsdb msg="Replaying on-disk memory mappable chunks if any"
9月 01 15:05:27 tcontrol prometheus[26667]: level=info ts=2020-09-01T07:05:27.550Z caller=head.go:658 component=tsdb msg="On-disk memory mappable chunks replay completed" duration=3.518µs
9月 01 15:05:27 tcontrol prometheus[26667]: level=info ts=2020-09-01T07:05:27.550Z caller=head.go:664 component=tsdb msg="Replaying WAL, this may take a while"
9月 01 15:05:27 tcontrol prometheus[26667]: level=info ts=2020-09-01T07:05:27.551Z caller=head.go:716 component=tsdb msg="WAL segment loaded" segment=0 maxSegment=0
9月 01 15:05:27 tcontrol prometheus[26667]: level=info ts=2020-09-01T07:05:27.551Z caller=head.go:719 component=tsdb msg="WAL replay completed" checkpoint_replay_duration=24.469µs wal_replay_duration=928.191µs total_…_duration=979.447µs
9月 01 15:05:27 tcontrol prometheus[26667]: level=info ts=2020-09-01T07:05:27.553Z caller=main.go:721 fs_type=XFS_SUPER_MAGIC
9月 01 15:05:27 tcontrol prometheus[26667]: level=info ts=2020-09-01T07:05:27.553Z caller=main.go:724 msg="TSDB started"
9月 01 15:05:27 tcontrol prometheus[26667]: level=info ts=2020-09-01T07:05:27.553Z caller=main.go:850 msg="Loading configuration file" filename=/apps/conf/prometheus/prometheus.yml
9月 01 15:05:27 tcontrol prometheus[26667]: level=info ts=2020-09-01T07:05:27.633Z caller=main.go:881 msg="Completed loading of configuration file" filename=/apps/conf/prometheus/prometheus.yml totalDuration=80.704923ms remote_storag…µs
9月 01 15:05:27 tcontrol prometheus[26667]: level=info ts=2020-09-01T07:05:27.633Z caller=main.go:673 msg="Server is ready to receive web requests."
Hint: Some lines were ellipsized, use -l to show in full.
访问普罗米修斯
http://172.16.96.24:9090/graph
安装consul用于普罗米修斯监控端注册服务统一监控
consul简单的docker安装
[bravo@tcontrol conf]$ sudo docker run --name consul -d -p 8500:8500 consul
Unable to find image 'consul:latest' locally
Trying to pull repository docker.io/library/consul ...
latest: Pulling from docker.io/library/consul
df20fa9351a1: Pull complete
01486d8d789a: Pull complete
f05331c059db: Pull complete
8c63443219bd: Pull complete
3b49373c72e6: Pull complete
df210b14cefb: Pull complete
Digest: sha256:4fe8d3dd56b5d1274f025c30a42d8b6ad0b49e7a598e587193bc95b7d46d5e1e
Status: Downloaded newer image for docker.io/consul:latest
0e3dfb1dca16ad2cee7e234839ac6d6dc9d111b48e8f1713da3eabd65edf1e63
[bravo