Grafana+Prometheus通过node_exporter监控Linux服务器信息
Grafana+Prometheus通过node_exporter监控Linux服务器信息
相关原文地址:
阿里云:小柒2012:Grafana+Prometheus打造全方位立体监控系统
简书:虫儿飞ZLEI:Prometheus+node_exporter+grafana打造spring boot项目的监控系统
CSDN:宫凯宁:【Prometheus】node_exporter的常用配置项详解
简书:ihujian:docker 安装配置Prometheus+node_exporter+cadvisor
一、Grafana+Prometheus通过node_exporter监控Linux服务器信息
Grafana和Prometheus的安装不再赘述,可参考网上教程或本专栏内的其他文章。
直接讲解node_exporter部分。
1.1node_exporter下载
进入官网node_exporter
https://prometheus.io/download/#node_exporter
进行下载。
1.2解压
tar -zxvf ...node_exporter.tar.gz
1.3启动
解压后,进入到解压目录,启动node_exporter:
./node_exporter
#这种方式启动会将此进程启动到前台,当把当前的命令行关闭,这个进程也会跟着关闭,可以把进程启动到后台运行:
nohup ./node_exporter
nohup ./node_exporter> nodeout.file 2>&1 &
#终端输出存会放在当前目录下的nodeout.file文件中
1.4node_exporter的常用配置项详解
通常,我们使用./node_exporter来启动node_exporter。但是node_exporter其实存在很多内置参数,下面是常用的参数详解。
1.4.1node_exporte基本信息配置
--web.listen-address=":9100"
#node_exporter监听的端口,默认是9100,若需要修改则通过此参数。
--web.telemetry-path="/metrics"
#获取metric信息的url,默认是/metrics,若需要修改则通过此参数
--log.level="info"
#设置日志级别
--log.format="logger:stderr"
#设置打印日志的格式,若有自动化日志提取工具可以使用这个参数规范日志打印的格式
修改node_exporter启动端口:
nohup ./node_exporter> nodeout.file 2>&1 --web.listen-address=":9101" &
1.4.2通过正则表达式来屏蔽或选择某些监控项
--collector.diskstats.ignored-devices="^(ram|loop|fd|(h|s|v|xv)d[a-z]|nvme\\d+n\\d+p)\\d+$"
#通过正则表达式忽略某些磁盘的信息收集
--collector.filesystem.ignored-mount-points="^/(dev|proc|sys|var/lib/docker/.+)($|/)"
#通过正则表达式忽略某些文件系统挂载点的信息收集
--collector.filesystem.ignored-fs-types="^(autofs|binfmt_misc|bpf|cgroup2?|configfs|debugfs|devpts|devtmpfs|fusectl|hugetlbfs|mqueue|nsfs|overlay|proc|procfs|pstore|rpc_pipefs|securityfs|selinuxfs|squashfs|sysfs|tracefs)$"
#通过正则表达式忽略某些文件系统类型的信息收集
--collector.netclass.ignored-devices="^$"
#通过正则表达式忽略某些网络类的信息收集
--collector.netdev.ignored-devices="^$"
#通过正则表达式忽略某些网络设备的信息收集
--collector.netstat.fields="^$"
#通过正则表达式配置需要获取的网络状态信息
--collector.vmstat.fields="^(oom_kill|pgpg|pswp|pg.*fault).*"
#通过正则表达式配置vmstat返回信息中需要收集的选项
1.5将node_exporter配置到Prometheus中
修改Prometheus的配置文件:
vi /prometheus/prometheus.yml
增加一个job,target是node_exporter的9100的地址:
注意是增加一个job,不是覆盖,之前Prometheus的job不动
重新启动Prometheus。
1.6 Docker方式启动node_exporter
创建一个docker 网络,然后将prometheus和node_exporter 加入到这个网络中
docker network create -d bridge my-net
docker run -d -p 9090:9090 --name prometheus --network my-net -v ~/prom/prometheus.yml:/etc/prometheus/prometheus.yml quay.io/prometheus/prometheus
当设置了–net=host时,如果在加-p或者-P,则不会管用。
docker run -d --net="host" --pid="host" --name=node-exporter -v "/:/host:ro,rslave" quay.io/prometheus/node-exporter --path.rootfs /host
修改Prometheus.yml。
global:
scrape_interval: 15s # By default, scrape targets every 15 seconds.
evaluation_interval: 15s # By default, scrape targets every 15 seconds.
rule_files:
- "rules/rule.yml"
scrape_configs:
- job_name: 'prometheus'
scrape_interval: 5s
static_configs:
- targets: ['127.0.0.1:9090']
- job_name: 'node'
scrape_interval: 8s
static_configs:
- targets: ['127.0.0.1:9100']
job_name为node 服务发现的targets应该是机器的外部ip + hostPort
二、Prometheus+node_exporter+grafana打造spring boot项目的监控系统
Prometheus,Grafana安装不再追诉,参照网上教程或本专栏内相关博文,node_exporter参照Title 一。
2.1集成Prometheus到spring boot项目,并利用Prometheus的查询页面查询spring boot项目的监控数据
添加Maven
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
添加配置
management:
endpoints:
web:
exposure:
include: '*'
metrics:
tags:
application: ${spring.application.name}
在spring boot启动类下添加一个bean
public class BaseMainApp {
public static void main(String[] args) {
SpringApplication.run(BaseMainApp.class, args);
}
//看这里
@Bean
MeterRegistryCustomizer<MeterRegistry> configurer(@Value("${spring.application.name}") String applicationName) {
return (registry) -> registry.config().commonTags("application", applicationName);
}
}
配置Prometheus的yml配置文件,添加job
然后重新启动Prometheus。
拦截器的坑
如果你的spring boot设置了拦截器对访问的url进行拦截的话,一定要记得将下面这个地址开放出来,不然虽然采集到了数据,但是这些数据无法访问的话,Prometheus的查询就查询不到。
配置Grafana
Grafana配置同node_exporter。
import dashboard id 4701。
关于dashboard
dashboard的网址https://grafana.com/dashboards
三、搭建相关教程博文
阿里云:小柒2012:Grafana+Prometheus打造全方位立体监控系统
简书:虫儿飞ZLEI:Prometheus+node_exporter+grafana打造spring boot项目的监控系统
Grafana+Prometheus通过node_exporter监控Linux服务器信息的更多相关文章
- Prometheus 监控linux服务器
Prometheus 监控linux服务器 node_exporter:用于*NIX系统监控,使用Go语言编写的收集器. 使用版本 node_exporter 0.17.0 相关文档 使用文档:htt ...
- 监控linux服务器网卡流量
监控linux服务器网卡流量 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 欢迎加入:高级运维工程师之路 598432640 前言:众所周知,我们安装zabbix服务器 ...
- 监控linux服务器工具nmon的使用
做压测时,需要查看服务器中的cpu.内存变化,但由于服务器是linux环境,则需要监控linux服务器的工具,下面用到的工具是nmon. 1.安装nmon.在网上下载nmon安装包,在linux服务器 ...
- JMC监控(Windows上远程连接监控Linux服务器的JVM)
Windows上远程连接监控Linux服务器的JVM:1.Linux服务器上配置:在Tomcat的tomcat-wms/bin/catalina.sh中添加CATALINA_OPTS="-X ...
- 使用 dmidecode 查看Linux服务器信息
使用 dmidecode 查看Linux服务器信息 来源 http://www.laozuo.org/6682.html 对于大部分普通服务器用户来说,我们选择VPS.服务器产品的时候比较关心的是产 ...
- 【开源监控】Prometheus+Node Exporter+Grafana监控linux服务器
Prometheus Prometheus介绍 Prometheus新一代开源监控解决方案.github地址 Prometheus主要功能 多维 数据模型(时序由 metric 名字和 k/v 的 l ...
- 基于grafana+prometheus构建Flink监控
先上一个架构图 Flink App : 通过report 将数据发出去 Pushgateway : Prometheus 生态中一个重要工具 Prometheus : 一套开源的系统监控报警框架 ...
- Spotlight 监控Linux服务器的性能
Spotlight功能:详细的进程跟踪功能远程连接在线的Unix/Linux的调优指南事件日志跟踪配置警报 详细的进程跟踪功能:Spotlight对具体的Unix / Linux的进程长达24小时的历 ...
- nmon监控Linux服务器系统资源
本文转自:http://www.cnblogs.com/hyzhou/archive/2011/12/29/2305860.html 在实际的测试过程中,Loadrunner监控Linux系统资源不太 ...
随机推荐
- java线程调度
JAVA线程调度分抢占式和协调式 协调式的线程切换由线程本身自己控制,好处是实现简单,当前线程只有当事情做完才会通知系统进行切换并没有同步开销,坏处是容易引发事故,假如阻塞的线程由于代码BUG没有通知 ...
- 使用Spring中@Async注解实现异步调用
异步调用? 在解释异步调用之前,我们先来看同步调用的定义:同步就是整个处理过程顺序执行,当各个过程都执行完毕,并返回结果. 异步调用则是只是发送了调用的指令,调用者无需等待被调用的方法完全执行完毕,继 ...
- 新来的运维这样用HDFS,CIO都懵了···
摘要:本文主要研究了HDFS文件系统的读写流程以及基于MRS在windows客户端下读写HDFS文件的实现. HDFS(Hadoop分布式文件系统)是Apache Hadoop项目的一个子项目. HD ...
- IDEA 常用的一些 (就几个) 快捷键
快捷键 说明 Ctrl + P 提示类参数 Ctrl + Q 提示类的属性和方法包名 Ctrl + D 复制一行到下一行 Ctrl + F 查找 Ctrl + R 替换 Ctrl + Z 撤销 Ctr ...
- /etc/hosts导致的问题
今天安装完成orzdba之后,执行./orzdba -l 报如下错误: Usage: Socket::inet_ntoa(ip_address_sv) at /var/lib/mysql/trunk/ ...
- load data local带来的安全问题
load data默认读的是服务器上的文件,但是加上local参数后,就可以将本地具有访问权限的文件加载到数据库中,这在带来方便的同时,也带来了以下安全问题, 可以任意加载本地文件到数据库, 在web ...
- 容器编排系统K8s之HPA资源
前文我们了解了用Prometheus监控k8s上的节点和pod资源,回顾请参考:https://www.cnblogs.com/qiuhom-1874/p/14287942.html:今天我们来了解下 ...
- 【Linux】linux中用vim来比较文件内容不同
1. 使用vim的比较模式打开两个文件: vim -d file1 file2 或 vimdiff file1 file2 2. 如果已经打开了文件file1,再打开另一个文件file2进行比较: : ...
- Test typora
目录 0. test 0.5 easy test 1. problem 1 2. problem 2 3. problem 3 import numpy as np import matplotlib ...
- 攻防世界 - Web(二)
supersqli: (!!!) 1.判断有误注入,1'报错, 1' 报错,1'# 正常且为True,1' and 1=1# 正常且为True,1' and 1=2# 正常且为False,所以它里边存 ...