Prometheus+Grafana多方位监控

2024-04-30 11:36

本文主要是介绍Prometheus+Grafana多方位监控,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

Prometheus+Grafana多方位监控

契机

基础

docker安装

#grafana安装+挂载data
mkdir /x/grafana-storage
chmod 777  /x/grafana-storage
docker run -d \
-p 3000:3000 \
--name=grafana \
-v /x/grafana-storage:/var/lib/grafana \
grafana/grafana#promethes安装+挂载yml
mkdir /x/prometheus
#配置文件在下面
vim /x/prometheus/prometheus.yml
docker run  -d \
-p 9090:9090 \
--privileged=true \
--restart always \
--name=prometheus \
-v /x/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml  \
prom/prometheus#进入grafana
http://localhost:3000
默认密码:admin admin
#修改ui和语言
#导入数据源prometheus

prometheus.yml最终配置

#全局配置
global:scrape_interval: 15sevaluation_interval: 15s#抓取配置
scrape_configs:#nginx监控- job_name: 'nginx'metrics_path: '/metrics' static_configs:- targets: ['localhost:9113']#es监控- job_name: "es"metrics_path: "/metrics"static_configs:- targets: [ "localhost:9111" ]#rabbitmq监控- job_name: "rabbitmq"metrics_path: "/metrics"static_configs:- targets: [ "localhost:15692" ]#ECS监控- job_name: nodestatic_configs:- targets: [ 'localhost:9091','localhost1:9091','localhost2:9091']#Java程序监控- job_name: servicemetrics_path: "/actuator/prometheus"static_configs:- targets: ["localhost:8090"]labels:application: applciation1- targets: ["localhost:9999"]labels:application: applciation2

ECS监控

安装

如果选用的火山云的服务器直接参考,如果不是火山云需要参考文档安装

https://www.volcengine.com/docs/6731/1195154
https://www.volcengine.com/docs/6408/69457

#查看监控状态
systemctl status cloud-monitor-agent
#查看9091端口监听
ss -naltp | grep 9091
#返回如下信息时,表示监控组件工作正常,9091 端口已开启。
LISTEN     0      128       [::]:9091                  [::]:*                   users:(("cloud-monitor-a",pid=1661,fd=3))
#老火山服务器升级组件
sed -i 's/Prometheus: false/Prometheus: true/' /usr/local/cloud-monitor-agent/config.yaml && systemctl restart cloud-monitor-agent
#查看端口是否正常访问
curl 127.0.0.1:9091/metrics

监控配置

#抓取配置
scrape_configs:#ECS监控- job_name: nodestatic_configs:- targets: [ 'localhost:9091','localhost1:9091','localhost2:9091']

监控大盘

https://www.volcengine.com/docs/6731/1195154
拉到最下面就有一个监控大盘

效果演示

请添加图片描述

Nginx监控

安装


#查看nginx是否安装stub模块
nginx -V 2>&1 | grep -o with-http_stub_status_module#没安装的话需要参考其他教程安装#修改nginx.conf
server {listen 9088; listen [::]:9088; server_name localhost; location = /stub_status { stub_status;}
}#nginx配置刷新
nginx -t
nginx -s reload#校验
curl http://localhost:9088/stub_status#安装exporter
mkdir -p /home/prometheus_exporter/{nginx,es}
cd /home/prometheus_exporter/nginx
#这里要根据系统版本选择
wget https://github.com/nginxinc/nginx-prometheus-exporter/releases/download/v1.1.0/nginx-prometheus-exporter_1.1.0_linux_amd64.tar.gz
tar -xvf nginx-prometheus-exporter_1.1.0_linux_amd64.tar.gz
nohup /home/prometheus_exporter/nginx/nginx-prometheus-exporter -nginx.scrape-uri=http://localhost:9088/stub_status >> /dev/null 2>&1 &

监控配置

#抓取配置
scrape_configs:#nginx监控- job_name: 'nginx'metrics_path: '/metrics' static_configs:- targets: ['localhost:9113']

监控大盘

登陆grafana新建看板导入

https://grafana.com/grafana/dashboards/11199-nginx/

效果演示

请添加图片描述

ElasticSearch监控

安装

#安装exporter
cd /home/prometheus_exporter/es
#这里要根据系统来选择
wget https://github.com/prometheus-community/elasticsearch_exporter/releases/download/v1.7.0/elasticsearch_exporter-1.7.0.linux-amd64.tar.gz
tar -xvf elasticsearch_exporter-1.7.0.linux-amd64.tar.gz
nohup /home/prometheus_exporter/es/elasticsearch_exporter-1.7.0.linux-amd64/elasticsearch_exporter  --web.listen-address :9111 --es.uri http://user:psw@localhost:9200 >> /dev/null 2>&1 &

监控配置

#抓取配置
scrape_configs:#es监控- job_name: "es"metrics_path: "/metrics"static_configs:- targets: [ "localhost:9111" ]

监控大盘

登陆grafana新建看板导入

https://grafana.com/grafana/dashboards/14191-elasticsearch-overview/

效果演示

请添加图片描述

RabbitMQ监控

安装

#主要就会是暴露15692
docker run -d \
--privileged \
-p 5672:5672 -p 15672:15672 -p 15692:15692 \
--name rabbitmq \
--restart=always \
-v /home/docker/rabbitmq/data:/var/lib/rabbitmq \
rabbitmq:3.9.0-management#进入容器,启用插件
rabbitmq-plugins enable rabbitmq_prometheus

监控配置

#抓取配置
scrape_configs:#mq监控- job_name: "rabbitmq"metrics_path: "/metrics"static_configs:- targets: [ "localhost:15692" ]

监控大盘

登陆grafana新建看板导入

https://grafana.com/grafana/dashboards/10991-rabbitmq-overview/

效果演示

请添加图片描述

Redis监控

安装

#在grafana管理页面
#连接#数据源
#添加redis数据源即可
#无需监控配置

监控大盘

登陆grafana新建看板导入

https://grafana.com/grafana/dashboards/11835-redis-dashboard-for-prometheus-redis-exporter-helm-stable-redis-ha/

效果演示

请添加图片描述

Java应用监控

安装

#pom导入
<dependency><groupId>io.micrometer</groupId><artifactId>micrometer-registry-prometheus</artifactId>
</dependency>#yml配置
management:endpoints:web:exposure:include: "*"endpoint:health:show-details: ALWAYS

监控配置

#抓取配置
scrape_configs:#Java程序监控- job_name: servicemetrics_path: "/actuator/prometheus"static_configs:- targets: ["localhost:8090"]labels:application: applciation1- targets: ["localhost:9999"]labels:application: applciation2

监控大盘

登陆grafana新建看板导入

https://grafana.com/grafana/dashboards/4701-jvm-micrometer/

https://grafana.com/grafana/dashboards/12900-springboot-apm-dashboard/

效果演示

请添加图片描述

请添加图片描述

写到最后

欢迎访问:https://bothsavage.github.io
请添加图片描述

这篇关于Prometheus+Grafana多方位监控的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!


原文地址:
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.chinasem.cn/article/948768

相关文章

JVisualVM之Java性能监控与调优利器详解

《JVisualVM之Java性能监控与调优利器详解》本文将详细介绍JVisualVM的使用方法,并结合实际案例展示如何利用它进行性能调优,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全... 目录1. JVisualVM简介2. JVisualVM的安装与启动2.1 启动JVisualVM2

使用Python实现实时金价监控并自动提醒功能

《使用Python实现实时金价监控并自动提醒功能》在日常投资中,很多朋友喜欢在一些平台买点黄金,低买高卖赚点小差价,但黄金价格实时波动频繁,总是盯着手机太累了,于是我用Python写了一个实时金价监控... 目录工具能干啥?手把手教你用1、先装好这些"食材"2、代码实现讲解1. 用户输入参数2. 设置无头浏

使用Python实现IP地址和端口状态检测与监控

《使用Python实现IP地址和端口状态检测与监控》在网络运维和服务器管理中,IP地址和端口的可用性监控是保障业务连续性的基础需求,本文将带你用Python从零打造一个高可用IP监控系统,感兴趣的小伙... 目录概述:为什么需要IP监控系统使用步骤说明1. 环境准备2. 系统部署3. 核心功能配置系统效果展

AJAX请求上传下载进度监控实现方式

《AJAX请求上传下载进度监控实现方式》在日常Web开发中,AJAX(AsynchronousJavaScriptandXML)被广泛用于异步请求数据,而无需刷新整个页面,:本文主要介绍AJAX请... 目录1. 前言2. 基于XMLHttpRequest的进度监控2.1 基础版文件上传监控2.2 增强版多

golang获取prometheus数据(prometheus/client_golang包)

《golang获取prometheus数据(prometheus/client_golang包)》本文主要介绍了使用Go语言的prometheus/client_golang包来获取Prometheu... 目录1. 创建链接1.1 语法1.2 完整示例2. 简单查询2.1 语法2.2 完整示例3. 范围值

Linux使用nload监控网络流量的方法

《Linux使用nload监控网络流量的方法》Linux中的nload命令是一个用于实时监控网络流量的工具,它提供了传入和传出流量的可视化表示,帮助用户一目了然地了解网络活动,本文给大家介绍了Linu... 目录简介安装示例用法基础用法指定网络接口限制显示特定流量类型指定刷新率设置流量速率的显示单位监控多个

通过prometheus监控Tomcat运行状态的操作流程

《通过prometheus监控Tomcat运行状态的操作流程》文章介绍了如何安装和配置Tomcat,并使用Prometheus和TomcatExporter来监控Tomcat的运行状态,文章详细讲解了... 目录Tomcat安装配置以及prometheus监控Tomcat一. 安装并配置tomcat1、安装

C#实现系统信息监控与获取功能

《C#实现系统信息监控与获取功能》在C#开发的众多应用场景中,获取系统信息以及监控用户操作有着广泛的用途,比如在系统性能优化工具中,需要实时读取CPU、GPU资源信息,本文将详细介绍如何使用C#来实现... 目录前言一、C# 监控键盘1. 原理与实现思路2. 代码实现二、读取 CPU、GPU 资源信息1.

使用zabbix进行监控网络设备流量

《使用zabbix进行监控网络设备流量》这篇文章主要为大家详细介绍了如何使用zabbix进行监控网络设备流量,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录安装zabbix配置ENSP环境配置zabbix实行监控交换机测试一台liunx服务器,这里使用的为Ubuntu22.04(

springboot健康检查监控全过程

《springboot健康检查监控全过程》文章介绍了SpringBoot如何使用Actuator和Micrometer进行健康检查和监控,通过配置和自定义健康指示器,开发者可以实时监控应用组件的状态,... 目录1. 引言重要性2. 配置Spring Boot ActuatorSpring Boot Act