Prometheus + Grafana 监控服务器性能

系统性能监控:Prometheus + Grafana 监控服务器性能(Window环境) 

目录

系统性能监控:Prometheus + Grafana 监控服务器性能(Window环境) 

一. Prometheus简介

1. 主要特性:

2. 组成:

二. Prometheus + Grafana监控系统性能

二.1. 安装wmi-exporter

二.2. 安装Prometheus

二.3. 安装Grafana

一. Prometheus简介

Prometheus使用Go语言开发,是最初在SoundCloud上构建的开源系统监控和警报工具,在2016年加入了Cloud Native Computing Foundation(CNCF)基金会,是继Kubernetes之后该基金会的第二个托管项目。

1. 主要特性:

1

2

3

4

5

6

7

8

9

10

11

12

13

多维数据模型,由指标名称和键值对标识的时间序列数据度量

 

PromQL查询语言

 

不依赖分布式存储;单个服务器节点是自治的

 

通过HTTP使用pull模式收集时间序列数据

 

支持通过中间网关推送时间序列数据

 

通过服务发现或静态配置发现目标对象

 

支持多种图形和仪表盘

 

2. 组成:

1

2

3

4

5

6

7

8

9

10

11

Prometheus主服务器:用于抓取并存储时间序列数据

 

客户端库:用于检测应用程序代码

 

推送网关:支持短生命周期

 

各种exporter:HAProxy,StatsD,Graphite等服务收集服务器性能数据

 

警告管理器

 

各种支持工具

 

二. Prometheus + Grafana监控系统性能

主要用到了Prometheus,windows_exporter和Grafana,Prometheus和windows_exporter收集保存服务器性能数据,Grafana用于图形化展示数据。

二.1. 安装wmi-exporter

下载地址:https://github.com/martinlindhe/wmi_exporter/releases选择最新msi文件下载安装即可。

完成安装后会自动创建一个开机自启的服务,通过服务(services.msc)判断是否有有windows_exporter

 

 通过访问http://localhost:9182 出现下图,即代表安装采集数据成功。

 

二.2. 安装Prometheus

下载地址:Download | Prometheus 选择windows环境下选择最新windows-amd64.zip文件下载。

文件下载后解压,双击prometheus.exe文件,运行Prometheus ;默认端口为9090,通过访问http://localhost:9090,显示下图,代表运行成功;

 

Prometheus配置文件为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: ["localhost:9090"]

  - job_name: 'A3mall'

    # metrics_path defaults to '/metrics'

    # scheme defaults to 'http'.

    static_configs:

    - targets: ['localhost:9182']

添加监控主机,在scrape_configs节点下配置如下,可根据需要配配置多个节点位置,也可在targets节点中使用逗号分隔配置多台主机:

1

2

3

4

5

  - job_name: 'A3mall'

    # metrics_path defaults to '/metrics'

    # scheme defaults to 'http'.

    static_configs:

- targets: ['wmi.Exporter主机地址:端口号’]

 完成配置,重新运行程序,进入http://localhost:9090/classic/targets,可查看查看监控信息;

 

 

二.3. 安装Grafana

下载地址:https://grafana.com/grafana/download,选择windows 版本;官方提供installer、zip file两种类型下载包,本次选用zip file文件包。

文件下载后解压,进入bin目录双击grafana-server.exe文件,运行Grafana,如下图:

进入系统:

上图所示,默认端口为3000,通过访问http://localhost:300,显示下图,代表运行成功;

系统第一次运行,默认用户密码为:admin/admin,系统会提示修改密码。

 

进入系统

 

配置数据源:

选择Configuration-Data source-Add data source,选择Prometheus;在HTTP-URL中填写Prometheus地址,保存配置(注意查看提示,是否验证成功);如下图:

 

 

  验证成功

 

添加仪表盘:

选择Dashboards-Browse,点击Import,导入模版,如下图:

模版获取地址:https://grafana.com/dashboards,打开上述地址,在Search框中输入选择所需要的模版;记录下模版ID或下载JSON文件(Download JSON);

Windows模板推荐:10467模块;

Linux服务器系统性能监控推荐8919。

mysql性能监控:7362

 

配置完成!

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

彭雨晏

感谢打赏

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值