Prometheus系列(一)安装

1 安装 Prometheus Server

官网:https://prometheus.io/

下载:https://prometheus.io/download/

手册:https://prometheus.io/docs/introduction/overview/

Prometheus 基于 Golang 编写,编译后的软件包,不依赖于任何的第三方依赖。只需要下载对应平台的二进制包,解压并且添加基本的配置即可正常启动 Prometheus Server。

1.1 下载安装包之后上传到服务器

在这里插入图片描述

1.2 解压安装包 prometheus-2.40.1.linux-amd64.tar.gz

[root@localserver /root/prometheus]# tar zxvf prometheus-2.40.1.linux-amd64.tar.gz 
[root@localserver /root/prometheus]# mv prometheus-2.40.1.linux-amd64 /usr/local/prometheus-2.40.1
[root@localserver /root/prometheus]# cd /usr/local/prometheus-2.40.1

[root@localserver /usr/local/prometheus-2.40.1]# ll
total 215448
drwxr-xr-x. 2 1001 121        38 Nov  9 22:52 console_libraries
drwxr-xr-x. 2 1001 121       173 Nov  9 22:52 consoles
-rw-r--r--. 1 1001 121     11357 Nov  9 22:52 LICENSE
-rw-r--r--. 1 1001 121      3773 Nov  9 22:52 NOTICE
-rwxr-xr-x. 1 1001 121 114465160 Nov  9 22:34 prometheus
-rw-r--r--. 1 1001 121       934 Nov  9 22:52 prometheus.yml
-rwxr-xr-x. 1 1001 121 106127759 Nov  9 22:36 promtool

1.3 修改配置文件 prometheus.yml

scrape_configs:
  - job_name: "prometheus"
    static_configs:
      - targets: ["localserver:9090"]
      
  - job_name: 'pushgateway'
    static_configs:
      - targets: ['localserver:9091']
        labels:
          instance: pushgateway
          
  - job_name: 'node exporter'
    static_configs:
      - targets: ['localserver:9100', 'ubuntu18:9100']

注:这里的 localserver 写为本地的 IP 也可以,或者使用 localhost 代替均可。

配置说明:

global 配置块:此片段指定的是 prometheus 的全局配置, 比如采集间隔,抓取超时时间等。

➢ scrape_interval:拉取数据的时间间隔,默认为 1 分钟默认继承 global 值。

scrape_timeout: 抓取超时时间,默认继承 global 值。

➢ evaluation_interval:规则验证(生成 alert)的时间间隔,默认为 1 分钟。

rule_files 配置块:此片段指定报警规则文件, prometheus 根据这些规则信息,会推送报警信息到alertmanager 中。

scrape_configs 配置块:配置采集目标相关, prometheus 监视的目标

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值