VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > 网络工程 > Linux 教程 >
  • 二进制安装Prometheus

二进制安装Prometheus

 

下载源

1
2
3
4
5
https://prometheus.io/download/
https://github.com/prometheus/prometheus/releases/download/v2.28.1/prometheus-2.28.1.linux-amd64.tar.gz
https://github.com/prometheus/prometheus/releases/download/v2.28.1/prometheus-2.28.1.windows-amd64.zip
https://github.com/prometheus/alertmanager/releases/download/v0.22.2/alertmanager-0.22.2.linux-amd64.tar.gz
https://github.com/prometheus/alertmanager/releases/download/v0.22.2/alertmanager-0.22.2.windows-amd64.zip

 

一、监控系统的基本概念术语

job:唯一标识每个接入的业务方,可以在每个job下面添加多个监控任务
task:表示一个具体的监控任务,包含访问数据地址,采集数据周期等
metric:表示监控项,描述要监控内容的含义,相当于map里面的key
tag:表示标签,用于给metric打标记分类,方便后期绘图和配置报警

二、数据采集方式
·insight直接采集(强烈推荐)
·推送数据到中间件,insight间接采集
·直接推送数据到insight数据库(不推荐)

1、安装rz和wget

1
yum -y install lrzsz wget

2、下载二进制tar包

1
wget https://github.com/prometheus/prometheus/releases/download/v2.28.1/prometheus-2.28.1.linux-amd64.tar.gz

3、解压到指定目录,解压改名

1
2
3
4
5
6
tar -zxvf prometheus-2.28.1.linux-amd64.tar.gz -C /usr/local/
cd /usr/local/
mv prometheus-2.28.1.linux-amd64 prometheus
cd prometheus/
查看版本
./prometheus --version

4、编辑启动配置文件

1
2
3
4
5
6
7
8
9
10
11
[root@localhost ~]# cat /usr/local/prometheus/prometheus.yml | grep -Ev "^$|#"
global:
alerting:
  alertmanagers:
  - static_configs:
    - targets:
rule_files:
scrape_configs:
  - job_name: 'prometheus'
    static_configs:
    - targets: ['192.168.35.130:1919']

5、关闭防火墙或者开放对应端口

1
2
systemctl stop firewalld
setenforce 0

6、启动服务,创建用户、组和存储数据地址

1
2
3
4
5
6
./prometheus
groupadd prometheus
useradd -g prometheus -s /sbin/nologin prometheus
chown -R prometheus:prometheus /usr/local/prometheus/
mkdir -p /home/prometheus/prometheus-data
chown -R prometheus:prometheus /home/prometheus/prometheus-data/

7、编辑自启动文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[root@localhost ~]# cat /usr/lib/systemd/system/prometheus.service
[Unit]
Description=Prometheus
Documentation=https://prometheus.io/
After=network.target
[Service]
# Type设置为notify时,服务会不断重启
Type=simple
User=prometheus
# --storage.tsdb.path是可选项,默认数据目录在运行目录的./dada目录中
#ExecStart=/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml --storage.tsdb.path=/home/prometheus/prometheus-date
ExecStart=/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml --storage.tsdb.path=/home/prometheus/prometheus-date --web.listen-address=:1919
Restart=on-failure
[Install]
WantedBy=multi-user.target

 设置自启动查看状态 

1
2
3
systemctl enable prometheus
systemctl start prometheus
systemctl status prometheus

 当前系统状态

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
[root@localhost system]# systemctl daemon-reload  #系统重载  非必要不用
[root@localhost system]# systemctl reset-failed prometheus.service #重建失败服务 非必要不用
[root@localhost system]# systemctl restart prometheus
[root@localhost system]# systemctl status prometheus
● prometheus.service - Prometheus
   Loaded: loaded (/usr/lib/systemd/system/prometheus.service; enabled; vendor preset: disabled)
   Active: active (running) since 二 2021-07-27 11:26:02 CST; 3s ago
     Docs: https://prometheus.io/
 Main PID: 10887 (prometheus)
   CGroup: /system.slice/prometheus.service
           └─10887 /usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml --storage....
 
7月 27 11:26:02 localhost.localdomain prometheus[10887]: level=info ts=2021-07-27T03:26:02.453Z caller=head.g...t=9
7月 27 11:26:02 localhost.localdomain prometheus[10887]: level=info ts=2021-07-27T03:26:02.483Z caller=head.g...t=9
7月 27 11:26:02 localhost.localdomain prometheus[10887]: level=info ts=2021-07-27T03:26:02.495Z caller=head.g...t=9
7月 27 11:26:02 localhost.localdomain prometheus[10887]: level=info ts=2021-07-27T03:26:02.495Z caller=head.g...t=9
7月 27 11:26:02 localhost.localdomain prometheus[10887]: level=info ts=2021-07-27T03:26:02.495Z caller=head.g...4ms
7月 27 11:26:02 localhost.localdomain prometheus[10887]: level=info ts=2021-07-27T03:26:02.497Z caller=main.g...GIC
7月 27 11:26:02 localhost.localdomain prometheus[10887]: level=info ts=2021-07-27T03:26:02.497Z caller=main.g...ed"
7月 27 11:26:02 localhost.localdomain prometheus[10887]: level=info ts=2021-07-27T03:26:02.498Z caller=main.g...yml
7月 27 11:26:02 localhost.localdomain prometheus[10887]: level=info ts=2021-07-27T03:26:02.499Z caller=main.go:1…?s
7月 27 11:26:02 localhost.localdomain prometheus[10887]: level=info ts=2021-07-27T03:26:02.499Z caller=main.g...s."
Hint: Some lines were ellipsized, use -l to show in full.
[root@localhost system]# netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name   
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      7053/sshd          
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      7212/master        
tcp6       0      0 :::22                   :::*                    LISTEN      7053/sshd          
tcp6       0      0 ::1:25                  :::*                    LISTEN      7212/master        
tcp6       0      0 :::1919                 :::*                    LISTEN      10887/prometheus

至此,监控安装完成  prometheus_target_interval_length_seconds{quantile="0.99"}

 

出处:https://www.cnblogs.com/security-guard/p/15065230.html

 



相关教程