前往小程序,Get更优阅读体验!
立即前往
发布
社区首页 >专栏 >通过案例带你轻松玩转JMeter连载(53)

通过案例带你轻松玩转JMeter连载(53)

作者头像
顾翔
发布2022-02-10 15:57:07
发布2022-02-10 15:57:07
36100
代码可运行
举报
运行总次数:0
代码可运行

2被测端监控:Exporter + Prometheus + Grafana 上一节我们介绍了在压测端使用JMeter集群+Influxdb存储+Grafana实时数据展示进行监控压测端,这一节我们来介绍下在被测端的监控工具组合:Exporter + Prometheus + Grafana。 2.1 Exporter 在被测端,如果操作系统为Linux系统,对应的Exporter为node_exporter;如果操作系统为Windows系统,对应的Exporter为windows_exporter.exe。我们先来介绍node_exporter的安装。 1)node_exporter node_exporter可通过以下几个步骤进行和下载和安装。

  • 在命令行中输入“wget -c https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-amd64.tar.gz”在线下载node_exporter-0.18.1.linux-amd64.tar.gz文件。
  • 输入命令“tar zxvf node_exporter-0.18.1.linux-amd64.tar.gz”解压zxvf。

node_exporter-0.18.1.linux-amd64.tar.gz。

  • 运行命令“./node_exporter &”。
  • 打开浏览器,在浏览器地址中输入:192.168.1.3:9100。
  • 点击Metrics连接,可以看见node_exporter收集到的Linux信息。

2)windows_exporter.exe windows_exporter可通过以下几个步骤进行下载和安装。

  • 下载windows_exporter.exe或者windows_exporter.msi。
  • 下载完毕后进行安装,默认安装地址为:C:\Program Files\windows_exporter\。
  • 进入安装目录,运行windows_exporter.exe。
  • 打开浏览器,在浏览器地址中输入:192.168.1.3:9182。如图14所示。

图14 windows_exporter主界面

注意node_exporter端口为9100,而windows_exporter为9182。

点击Metrics可以显示收集到的Windows操作系统信息

代码语言:javascript
代码运行次数:0
复制
# HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles

# TYPE go_gc_duration_seconds summary
go_gc_duration_seconds{quantile="0"} 0
go_gc_duration_seconds{quantile="0.25"} 0
go_gc_duration_seconds{quantile="0.5"} 0
go_gc_duration_seconds{quantile="0.75"} 0
go_gc_duration_seconds{quantile="1"} 0.0022913
go_gc_duration_seconds_sum 0.0043842
go_gc_duration_seconds_count 34
…

其中。

  • HELP是解释下面指标的含义,相当于帮助文档。
  • TYPE用于解释指标的数据类型。
  • 下面的信息是具体的统计信息。

2.2 Prometheus Prometheus 是由 SoundCloud 开源监控告警解决方案。 1)Prometheus Windows版本通过网页下载prometheus-2.27.1.windows-amd64;Liunx下通过以下命令来完成安装。

  • wget -c

https://github.com/prometheus/prometheus/releases/download/v2.15.1/prometheus-2.15.1.linux-amd64.tar.gz

  • tar zxvf prometheus-2.15.1.linux-amd64.tar.gz

2)修改prometheus.yml文件中的端口号。

代码语言:javascript
代码运行次数:0
复制
scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from 
this config.

  - job_name: 'OS'



    # metrics_path defaults to '/metrics'

    # scheme defaults to 'http'.



    static_configs:

    - targets: ['127.0.0.1:9182']

在这里Windows下使用- targets: ['127.0.0.1:9182'],而Linux下使用- targets: ['127.0.0.1:9100']。 下面来简单介绍一下这个文件。

  • global:为全局配置,比如每次数据收集的间隔、规则扫描数据的间隔。
  • alerting:这里可以设置告警的插件,比如 alertmanager等。
  • rule_files:这里为具体的报警规则设置,比如基于什么指标进行报警,相当于触发器。
  • scrape_configs:采集数据的对象,job_name、target 以及 job_name 是配置主机的名称,target 是为安装的 Exporter 地址。

3)运行prometheus.exe,打开浏览器,在地址栏中输入:http://127.0.0.1:9090/targets,如图15所示。

图15 Prometheus主界面

在这个界面中我们可以看见windows_exporter.exe或node_exporter被Prometheus监控到。

2.3 Grafana Grafana的安装我们在上一节中介绍过,现在让我们来看一下如何对Prometheus进行配置。 1)启动Grafana 2)打开浏览器,在地址栏中输入:http://127.0.0.1:3000/datasources/new,按下图输入Name,HTTP下的URL、Access。如图16所示。

图16 配置Grafana访问Prometheus信息

3)点击【Save & Test】,验证测试通过,如图17所示。

图17 验证配置Grafana访问Prometheus信息是否正确

4)接下来按照1.3第7)步,import windows_exporter.exe或node_exporter数据,如图18所示。

图18 import windows_exporter或node_exporter数据

注意:windows_exporter ID为10467,node_exporter ID为8919。可以通过https://grafana.com/grafana/dashboards/10467和https://grafana.com/grafana/dashboards/8919来查看信息。 5)点击【Import】就可以看到监控信息了,如图19所示和图20所示。这里监控都是被测机器操作系统的数据,包括CPU、内存、网络、磁盘等信息。

图19 确认Import windows_exporter或node_exporter数据

图20 windows_exporter或node_exporter监控数据展示

2.4 配置MySQL监控 另外我们还可以来监控MySQL信息。 1)通过https://prometheus.io/download/来下载mysql_export。如图21所示。

图21 下载mysql_export

2)下载完毕,修改my.cnf文件,配置MySQL连接信息。

代码语言:javascript
代码运行次数:0
复制
[client]
host=127.0.0.1
port=3306
user=root
password=123456

在这里host为MySQL所在的IP地址、port为端口号,默认是3306、user是MySQL的用户名、password是MySQL的密码。 3)通过运行mysqld_exporter.exe --config.my-cnf=my.cnf启动,启动后,在浏览器的地址栏中输入:http://127.0.0.1:9104/。得到图22所示。

图22 mysqld_exporter主界面

4)对prometheus.yml进行如下配置。

代码语言:javascript
代码运行次数:0
复制
scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this 
config.

  - job_name: 'OS'



    # metrics_path defaults to '/metrics'

    # scheme defaults to 'http'.



    static_configs:

    - targets: ['127.0.0.1:9182']

  - job_name: 'MySql'



    # metrics_path defaults to '/metrics'

    # scheme defaults to 'http'.



    static_configs:

    - targets: ['127.0.0.1:9104']

5)重新启动prometheus.exe,在浏览器送输入http://127.0.0.1:9090/targets,得到图23界面。

图23 Prometheus主界面

在这个界面中我们可以看见mysqld_exporter被prometheus监控。 6)启动Grafana,Import mysql_exporter数据信息。如图24所示。

图24 import mysql_exporter数据

7)mysql_exporter节点为11323,可以通过https://grafana.com/grafana/dashboards/11323来查看 8)最后点击【Load】,仍旧选择Prometheus就可以看到mysql_exporter的信息了。如图25所示。

图25 mysql_exporter监控数据展示

关于Prometheus可以参考https://www.bookstack.cn/read/prometheus-book/README.md。

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2022-01-21,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档