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
0e3dfb1dca16ad2cee7e234839ac6d6dc9d111b48
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值