1. prometheus-添加监控linux服务器

  • prometheus添加监控linux服务器

  • 安装部署

    • 下载node_exporter包

      https://github.com/prometheus/node_exporter/releases/download/v1.1.2/node_exporter-1.1.2.linux-amd64.tar.gz
    • 监控端主机下载

      [root@VM-0-17-centos ~]# wget https://github.com/prometheus/node_exporter/releases/download/v1.1.2/node_exporter-1.1.2.linux-amd64.tar.gz
    • 解压

      [root@VM-0-17-centos ~]# tar  -xvf node_exporter-1.1.2.linux-amd64.tar.gz
      node_exporter-1.1.2.linux-amd64/
      node_exporter-1.1.2.linux-amd64/LICENSE
      node_exporter-1.1.2.linux-amd64/NOTICE
      node_exporter-1.1.2.linux-amd64/node_exporter
    • 拷贝到opt目录下存放

      [root@VM-0-17-centos ~]# mv node_exporter-1.1.2.linux-amd64 /opt/
      [root@VM-0-17-centos ~]# ll /opt/node_exporter-1.1.2.linux-amd64/
      total 18748
      -rw-r--r-- 1 3434 3434 11357 Mar 5 17:41 LICENSE
      -rwxr-xr-x 1 3434 3434 19178528 Mar 5 17:29 node_exporter
      -rw-r--r-- 1 3434 3434 463 Mar 5 17:41 NOTICE
      [root@VM-0-17-centos ~]# mv /opt/node_exporter-1.1.2.linux-amd64 /opt/node_exporter
    • 切换目录

      [root@VM-0-17-centos ~]# cd /opt/node_exporter/
      [root@VM-0-17-centos node_exporter]# ll
      total 18748
      -rw-r--r-- 1 3434 3434 11357 Mar 5 17:41 LICENSE
      -rwxr-xr-x 1 3434 3434 19178528 Mar 5 17:29 node_exporter
      -rw-r--r-- 1 3434 3434 463 Mar 5 17:41 NOTICE
    • 启动服务尝试

      [root@VM-0-17-centos node_exporter]# ./node_exporter
      level=info ts=2021-05-19T07:00:05.583Z caller=node_exporter.go:178 msg="Starting node_exporter" version="(version=1.1.2, branch=HEAD, revision=b597c1244d7bef49e6f3359c87a56dd7707f6719)"
      level=info ts=2021-05-19T07:00:05.583Z caller=node_exporter.go:179 msg="Build context" build_context="(go=go1.15.8, user=root@f07de8ca602a, date=20210305-09:29:10)"
      level=warn ts=2021-05-19T07:00:05.583Z caller=node_exporter.go:181 msg="Node Exporter is running as root user. This exporter is designed to run as unpriviledged user, root is not required."
      level=info ts=2021-05-19T07:00:05.583Z caller=filesystem_common.go:74 collector=filesystem msg="Parsed flag --collector.filesystem.ignored-mount-points" flag=^/(dev|proc|sys|var/lib/docker/.+)($|/)
      level=info ts=2021-05-19T07:00:05.583Z caller=filesystem_common.go:76 collector=filesystem msg="Parsed flag --collector.filesystem.ignored-fs-types" flag=^(autofs|binfmt_misc|bpf|cgroup2?|configfs|debugfs|devpts|devtmpfs|fusectl|hugetlbfs|iso9660|mqueue|nsfs|overlay|proc|procfs|pstore|rpc_pipefs|securityfs|selinuxfs|squashfs|sysfs|tracefs)$
      level=info ts=2021-05-19T07:00:05.584Z caller=node_exporter.go:106 msg="Enabled collectors"
      level=info ts=2021-05-19T07:00:05.584Z caller=node_exporter.go:113 collector=arp
      level=info ts=2021-05-19T07:00:05.584Z caller=node_exporter.go:113 collector=bcache
      level=info ts=2021-05-19T07:00:05.584Z caller=node_exporter.go:113 collector=bonding
      level=info ts=2021-05-19T07:00:05.584Z caller=node_exporter.go:113 collector=btrfs
      level=info ts=2021-05-19T07:00:05.584Z caller=node_exporter.go:113 collector=conntrack
      level=info ts=2021-05-19T07:00:05.584Z caller=node_exporter.go:113 collector=cpu
      level=info ts=2021-05-19T07:00:05.584Z caller=node_exporter.go:113 collector=cpufreq
      level=info ts=2021-05-19T07:00:05.584Z caller=node_exporter.go:113 collector=diskstats
      level=info ts=2021-05-19T07:00:05.584Z caller=node_exporter.go:113 collector=edac
      level=info ts=2021-05-19T07:00:05.584Z caller=node_exporter.go:113 collector=entropy
      level=info ts=2021-05-19T07:00:05.584Z caller=node_exporter.go:113 collector=fibrechannel
      level=info ts=2021-05-19T07:00:05.584Z caller=node_exporter.go:113 collector=filefd
      level=info ts=2021-05-19T07:00:05.584Z caller=node_exporter.go:113 collector=filesystem
      level=info ts=2021-05-19T07:00:05.584Z caller=node_exporter.go:113 collector=hwmon
      level=info ts=2021-05-19T07:00:05.584Z caller=node_exporter.go:113 collector=infiniband
      level=info ts=2021-05-19T07:00:05.584Z caller=node_exporter.go:113 collector=ipvs
      level=info ts=2021-05-19T07:00:05.584Z caller=node_exporter.go:113 collector=loadavg
      level=info ts=2021-05-19T07:00:05.584Z caller=node_exporter.go:113 collector=mdadm
      level=info ts=2021-05-19T07:00:05.584Z caller=node_exporter.go:113 collector=meminfo
      level=info ts=2021-05-19T07:00:05.584Z caller=node_exporter.go:113 collector=netclass
      level=info ts=2021-05-19T07:00:05.584Z caller=node_exporter.go:113 collector=netdev
      level=info ts=2021-05-19T07:00:05.584Z caller=node_exporter.go:113 collector=netstat
      level=info ts=2021-05-19T07:00:05.584Z caller=node_exporter.go:113 collector=nfs
      level=info ts=2021-05-19T07:00:05.584Z caller=node_exporter.go:113 collector=nfsd
      level=info ts=2021-05-19T07:00:05.584Z caller=node_exporter.go:113 collector=powersupplyclass
      level=info ts=2021-05-19T07:00:05.584Z caller=node_exporter.go:113 collector=pressure
      level=info ts=2021-05-19T07:00:05.584Z caller=node_exporter.go:113 collector=rapl
      level=info ts=2021-05-19T07:00:05.584Z caller=node_exporter.go:113 collector=schedstat
      level=info ts=2021-05-19T07:00:05.584Z caller=node_exporter.go:113 collector=sockstat
      level=info ts=2021-05-19T07:00:05.584Z caller=node_exporter.go:113 collector=softnet
      level=info ts=2021-05-19T07:00:05.584Z caller=node_exporter.go:113 collector=stat
      level=info ts=2021-05-19T07:00:05.584Z caller=node_exporter.go:113 collector=textfile
      level=info ts=2021-05-19T07:00:05.584Z caller=node_exporter.go:113 collector=thermal_zone
      level=info ts=2021-05-19T07:00:05.584Z caller=node_exporter.go:113 collector=time
      level=info ts=2021-05-19T07:00:05.584Z caller=node_exporter.go:113 collector=timex
      level=info ts=2021-05-19T07:00:05.584Z caller=node_exporter.go:113 collector=udp_queues
      level=info ts=2021-05-19T07:00:05.584Z caller=node_exporter.go:113 collector=uname
      level=info ts=2021-05-19T07:00:05.584Z caller=node_exporter.go:113 collector=vmstat
      level=info ts=2021-05-19T07:00:05.584Z caller=node_exporter.go:113 collector=xfs
      level=info ts=2021-05-19T07:00:05.584Z caller=node_exporter.go:113 collector=zfs
      level=info ts=2021-05-19T07:00:05.584Z caller=node_exporter.go:195 msg="Listening on" address=:9100
      level=info ts=2021-05-19T07:00:05.584Z caller=tls_config.go:191 msg="TLS is disabled." http2=false
  • 配置为系统服务管理

    • 编写系统配置服务

      [root@iZj6cbgktk3zjpge312vq1Z node_exporter]# vim  /usr/lib/systemd/system/node_exporter.service
      [root@iZj6cbgktk3zjpge312vq1Z node_exporter]# cat /usr/lib/systemd/system/node_exporter.service
      [Unit]
      Description=node_exporter
      [Service]
      # 添加认证密码文件/opt/node_exporter/config.yml ,默认可以不需要
      ExecStart=/opt/node_exporter/node_exporter --web.config=/opt/node_exporter/config.yml
      ExecReload=/bin/kill -HUP $MAINPID
      KillMode=process
      Restart=on-failure
      [Install]
      WantedBy=multi-user.target
    • 添加config配置文件

      [root@VM-0-17-centos node_exporter]# yum install httpd-tools –y
      [root@VM-0-17-centos node_exporter]# htpasswd -nBC 12 '' | tr -d ':\n'
      New password: #这里输入的123456
      Re-type new password: #这里输入的123456
      $2y$12$.YGKNPkYfSOsm.JataWRUe4vWdTS8nW6YtPQI0Jr14eTv6E5Fpdga # 这段是生成的key
    • 编写启动配置文件

      [root@iZj6cbgktk3zjpge312vq1Z node_exporter]# vim config.yml
      [root@iZj6cbgktk3zjpge312vq1Z node_exporter]# cat config.yml
      basic_auth_users:
      prometheus: $2y$12$.YGKNPkYfSOsm.JataWRUe4vWdTS8nW6YtPQI0Jr14eTv6E5Fpdga
    • 启动服务

      systemctl daemon-reload
      systemctl start node_exporter
      systemctl enable node_exporter
  • 在prometheus添加主机

    • 添加配置文件

      [root@iZj6cbgktk3zjpge312vq2Z prometheus]# vim prometheus.yml
      [root@iZj6cbgktk3zjpge312vq2Z prometheus]# cat prometheus.yml
      # 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: ['127.0.0.1:9090']
      - job_name: linux
      # 添加监控主机的用户和密码
      basic_auth:
      username: prometheus
      password: 123456
      static_configs:
      - targets: ['10.1.2.211:9100']
      labels:
      prod: web
    • 重启服务

      [root@iZj6cbgktk3zjpge312vq2Z prometheus]# /bin/systemctl restart prometheus
  • 在Prometheus配置文件添加被监控端:

    • 验证prometheus配置文件

    • 验证发现已经有数据了

  • 使用Grafana展示node_exporter数据指标,仪表盘ID:9276

    • 导入仪表盘





    • 添加



prometheus-添加监控linux服务器的更多相关文章

  1. Prometheus 监控linux服务器

    Prometheus 监控linux服务器 node_exporter:用于*NIX系统监控,使用Go语言编写的收集器. 使用版本 node_exporter 0.17.0 相关文档 使用文档:htt ...

  2. Grafana+Prometheus通过node_exporter监控Linux服务器信息

    Grafana+Prometheus通过node_exporter监控Linux服务器信息 一.Grafana+Prometheus通过node_exporter监控Linux服务器信息 1.1nod ...

  3. 监控linux服务器网卡流量

    监控linux服务器网卡流量 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任.       欢迎加入:高级运维工程师之路 598432640 前言:众所周知,我们安装zabbix服务器 ...

  4. JMC监控(Windows上远程连接监控Linux服务器的JVM)

    Windows上远程连接监控Linux服务器的JVM:1.Linux服务器上配置:在Tomcat的tomcat-wms/bin/catalina.sh中添加CATALINA_OPTS="-X ...

  5. 监控linux服务器工具nmon的使用

    做压测时,需要查看服务器中的cpu.内存变化,但由于服务器是linux环境,则需要监控linux服务器的工具,下面用到的工具是nmon. 1.安装nmon.在网上下载nmon安装包,在linux服务器 ...

  6. Jmeter监控Linux服务器性能

    ①.下载JMeterPlugins相关的jar包,放jmeter的安装路径\lib\ext下——这个时候启动jmeter会发现,添加监听器时,出现了一堆的jp@jc……,这些就是插件的功劳. JMet ...

  7. Windows负载机JVM 远程监控Linux服务器下tomcat

    基本是跟着网上的操作进行的,除了遇到一个Local host name unknown的问题: 一.Linux服务器操作部分 服务器地址:10.64.111.68 首先配置JMX: 1.找到jdk目录 ...

  8. 监控 Linux 服务器活动的几个命令(watch top ac)

    watch.top 和 ac 命令为我们监视 Linux 服务器上的活动提供了一些十分高效的途径. 为了在获取系统活动时更加轻松,Linux 系统提供了一系列相关的命令.在这篇文章中,我们就一起来看看 ...

  9. loadrunner监控linux服务器

    参考http://www.cnblogs.com/yangxia-test/archive/2012/11/27/2790771.html http://www.cnblogs.com/candle8 ...

  10. Spotlight 监控Linux服务器的性能

    Spotlight功能:详细的进程跟踪功能远程连接在线的Unix/Linux的调优指南事件日志跟踪配置警报 详细的进程跟踪功能:Spotlight对具体的Unix / Linux的进程长达24小时的历 ...

随机推荐

  1. Pytorch及Yolov5环境配置及踩坑

    Pytorch及Yolov5环境配置及踩坑 1.何为Yolov5 yolo是计算机视觉方面用来进行目标检测的一个十分出名的开源框架,我搜不到官方的对此概括性的定义,但实际上也没什么必要,更重要的是会使 ...

  2. 洛谷P1638 逛画展 (尺取法)

    尺取法的经典题目: 博览馆正在展出由世上最佳的 mm 位画家所画的图画. 游客在购买门票时必须说明两个数字,aa 和 bb,代表他要看展览中的第 aa 幅至第 bb 幅画(包含 a,ba,b)之间的所 ...

  3. 华为路由器vrrp(虚拟路由器冗余协议)基本配置命令

    vrrp(虚拟路由器冗余协议)基本配置 int g0/0/0 vrrp vrid 1 virtual-ip 172.16.1.254 创建VRRP备份组,备份组号为1,配置虚拟IP为172.16.1. ...

  4. 基于Seq2Seq和注意力机制的句子翻译

    Seq2Seq(Attention) 目录 Seq2Seq(Attention) 1.理论 1.1 机器翻译 1.1.1 模型输出结果处理 1.1.2 BLEU得分 1.2 注意力模型 1.2.1 A ...

  5. 【MySQL】01_运算符、函数

    运算符 运算符是保留字或主要用于 SQL 语句的 WHERE 子句 中的字符,用于执行操作,例如:比较和算术运算. 这些运算符用于指定 SQL 语句中的条件,并用作语句中多个条件的连词. 常见运算符有 ...

  6. 题解 SP10500 HAYBALE - Haybale stacking

    前言 想了好久树状数组啥的,后来想想写打个差分再说,结果写完一遍AC了-- 强烈安利 题意 一个由 \(n\) 个元素组成的序列,给出 \(k\) 个操作,每次将 \(a\sim b\) 加上 \(1 ...

  7. 2022春每日一题:Day 24

    题目:Work Group 树形dp,设状态f[u][0/1] 表示以u为根节点,他的子树中选了0(偶数)1(奇数)个节点的最大价值,设x为他的一个儿子,显然f[u][1]=max(f[k][0]+f ...

  8. Armv8之Execution State 和 Exception Level(一)

    @ 目录 1. 典型的Exception Level使用模型 2.异常相关术语 3. Execution State 3.1 两种Execution State 3.2 决定Execution Sta ...

  9. (GCC) gcc 编译选项 -fno-omit-frame-pointer,-fno-tree-vectorize,fno-optimize-sibling-calls;及内存泄漏、非法访问检测 ASAN

    omit-frame-pointer 开启该选项,主要是用于去掉所有函数SFP(Stack Frame Pointer)的,即在函数调用时不保存栈帧指针SFP,代价是不能通过backtrace进行调试 ...

  10. Day19:属性封装详解

    属性封装详解 封装即隐藏一些数据,让外部不能直接访问,而是需要通过一些方法才能设置或者访问. 首先我们来看未封装的属性被外部调用的情况 public class Students{//创建一个学生类 ...