prometheus 监控

prometheus 监控

prometheus 架构

在这里插入图片描述

prometheus 简介

Prometheus, a Cloud Native Computing Foundation project, is a systems and service monitoring system. It collects metrics from configured targets at given intervals, evaluates rule expressions, displays the results, and can trigger alerts when specified conditions are observed.

新特性

  1. A multi-dimensional data model (time series defined by metric name and set of key/value dimensions)
  2. PromQL, a powerful and flexible query language to leverage this dimensionality
  3. No dependency on distributed storage; single server nodes are autonomous
  4. An HTTP pull model for time series collection
  5. Pushing time series is supported via an intermediary gateway for batch jobs
  6. Targets are discovered via service discovery or static configuration
  7. Multiple modes of graphing and dashboarding support
  8. Support for hierarchical and horizontal federation

架构说明

pushgateway exporters

prometheus-server

alertmanager PromQL
webUI
grafana

安装

##下载安装包地址

https://prometheus.io/download/

prometheus 配置文件

global: 主要有四个属性

scrape_interval: 拉取 targets 的默认时间间隔。

scrape_timeout: 拉取一个 target 的超时时间。

evaluation_interval: 执行 rules 的时间间隔。

external_labels: 额外的属性,会添加到拉取的数据并存到数据库中。

#配置文件修改
#my global config
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
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”]
  • job_name: “node_exporter”
    static_configs:

    • targets: [‘192.168.1.152:9100’,‘192.168.1.150:9100’]

开机自启配置

vim /usr/lib/systemd/system/prometheus.service

[Unit]
Description=prometheus
Documentation=https://prometheus.io
After=network.target

[Service]
ExecStart=/usr/local/prometheus/promethues-2.40.2/prometheus
–config.file=/usr/local/prometheus/prometheus-2.40.2/prometheus.yml
Restart=on-failure
RestartSec=10
StandardOutput=syslog
StandardError=syslog

[Install]
WantedBy=multi-user.target

执行命令
systemctl enable prometheus
systemctl start prometheus
systemctl status prometheus
在这里插入图片描述
node_exporter 开机自启配置

vim /usr/lib/systemd/system/node_server.service

[Unit]
Description=node_exporter
Documentation=node_exporter
After=network.target

[Service]
ExecStart=/usr/local/prometheus/node_exporter-1.4.0/node_exporter
Restart=on-failure
RestartSec=10
StandardOutput=syslog
StandardError=syslog
[Install]
WantedBy=multi-user.target

执行命令
systemctl daemon-reload
systemctl start node_server
systemctl enable node_server
systemctl status node_server
在这里插入图片描述

grafana 安装

上传安装包到服务器,执行命令
yum -y install grafana-enterprise-9.2.5-1.x86_64.rpm
service grafana-server start

prometheus 控制台查看
在这里插入图片描述
grafana控制台登录

在这里插入图片描述
将使用火狐浏览器登录,显示正常

在这里插入图片描述

在grafana面板添加prometheus DataSource

在这里插入图片描述

在这里插入图片描述

显示DataSource updated内容表示添加成功

在这里插入图片描述

导入Dashboards

在这里插入图片描述

查看监控

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值