普罗米修斯监控入门

安装普罗米修斯 

https://prometheus.io/download/下载相应版本安装包

 tar zxf prometheus-2.29.2.linux-amd64.tar.gz -C /usr/local/

 mv /usr/local/prometheus-2.29.2.linux-amd64/ /usr/local/prometheus

 cd /usr/local/prometheus

./prometheus --version     #验证安装

 cat prometheus.yml         #主配置文件,其中包含大多数标准配置及prometheus的自检控配置,默认配置文件如下

# my global config
global:
  scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.#默认抓取间隔, 15秒向目标抓取一次数据。
  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"]

./prometheus --config.file='/usr/local/prometheus/prometheus.yml' &     #启动服务

验证Prometheus是否启动成功

  • 访问自带的web界面

Prometheus自带一个比较简单的Web,可以查看表达式搜索结果、报警配置、prometheus配置,exporter状态等。自带Web默认在http://ip:9090

 安装node_exportor软件

上面用Prometheus本身的数据简单演示了监控数据的查询,这里我们用一个监控服务器状态的例子来更加直观说明。

为监控服务器CPU、内存、磁盘、I/O等信息,首先需要安装node_exporter。node_exporter的作用是用于机器系统数据收集。

  • 安装node_exporter

tar zxf node_exporter-1.2.2.linux-amd64.tar.gz -C /usr/local/

mv node_exporter-1.2.2.linux-amd64/ node_exporter

nohup /usr/local/node_exporter/node_exporter &       #启动服务,放在后台运行

ss -tnalp | grep 9100 

通过浏览器http://被监控段ip:9100/metrics就可以查看node_exporter在被监控段收集的监控信息

  •  让普罗米修斯监控可以拉取node节点信息

vim prometheus.yml   #在普罗米修斯的服务器的配置文件里添加被监控机器的配置

  • 重新启动普罗米修斯监控系统

 pkill prometheus

 ./prometheus --config.file='/usr/local/prometheus/prometheus.yml' &

lsof -i:9090

  • 回到web界面可以看到多了一台监控目标agent

 使用Prometheus Web来验证Node Exporter的数据已经被正确的采集。

a)查看当前主机cpu负载

 Prometheus监控远程mysql

  • 安装mysqld_exporter组件

tar zxf mysqld_exporter-0.13.0.linux-amd64.tar.gz -C /usr/local/

mv mysqld_exporter-0.13.0.linux-amd64/ mysqld_exporter

  • 安装mysql

给Prometheus添加一个强大的仪表盘

Grafana是用于可视化大型测量数据的开源程序,它提供了强大和优雅的方式去创建、共享、浏览数据。Dashboard中显示了你不同metric数据源中的数据。

Grafana最常用于因特网基础设施和应用分析,但在其他领域也有用到,比如:工业传感器、家庭自动化、过程控制等等。Grafana支持热插拔控制面板和可扩展的数据源,目前已经支持Graphite、InfluxDB、OpenTSDB、Elasticsearch、Prometheus等。

  • 安装grafana

https://grafana.com/grafana/download

wget https://dl.grafana.com/enterprise/release/grafana-enterprise-8.1.2-1.x86_64.rpm

yum install grafana-enterprise-8.1.2-1.x86_64.rpm 

systemctl start grafana-server

  •  访问grafana

 http://ip:3000,默认用户名和密码都为admin,登陆后需要修改默认密码

  •  添加普罗米修斯数据源

 

  • 访问dashboard

保存

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值