首页 > 编程知识 正文

普罗米修斯 系统监控,普罗米修休斯监控

时间:2023-05-05 09:27:49 阅读:195137 作者:962

安装lldhy 

从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 configglobal: 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 configurationalerting: 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在被监控段收集的监控信息

 让lldhy监控可以拉取node节点信息

vim prometheus.yml   #在lldhy的服务器的配置文件里添加被监控机器的配置

重新启动lldhy监控系统

 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,登陆后需要修改默认密码

 添加lldhy数据源

 

访问dashboard

保存

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。