Jmeter+InfluxDB+Grafana实现测试监控

2020-12-31  本文已影响0人  renyjenny
image.png

InfluxDB

一种时序数据库,常用于监控数据统计。时序数据,即按时间维度记录的数据,可高性能地存储、查询时序性数据。

Grafana

Grafana是一个度量分析和可视化工具,可以通过将采集的数据查询然后可视化的展示,并及时通知。

实现原理

Jmeter+InfluxDB+Grafana.png

Jmeter发送压力到服务器的同时,会统计TPS、响应时间、线程数、错误率等信息,默认每30s在控制台输出一次结果。配置后端监听器后,会讲统计出的结果异步发送到InfluxDB中。最后在Grafana中配置InfluxDB数据源,并展示测试结果。

部署步骤

一、安装、卸载fluxdb

安装fluxdb

1.下载安装

wget https://dl.influxdata.com/influxdb/releases/influxdb-1.7.0.x86_64.rpm --no-check-certificate 
rpm -ivh influxdb-1.7.0.x86_64.rpm

2.修改配置文件vi /etc/influxdb/influxdb.conf

[[graphite]] 
  # Determines whether the graphite endpoint is enabled. 
  enabled = true database = "jmeter"    # 数据库名称 
  retention-policy = "" 
  bind-address = ":2003"    # 端口 
  protocol = "tcp" 
  consistency-level = "one" 
修改HTTP端口信息 
[http] 
  # Determines whether HTTP endpoint is enabled. 
  enabled = true 
  # The bind address used by the HTTP service.
  bind-address = ":8086"

3.启动influxd服务 influxd &

检查是否启动成功 netstat -anp|grep 8088

4.数据库操作

[root@jmeter ~]# influx    # 登录数据库 
Connected to http://localhost:8086 version 1.6.0 InfluxDB shell version: 1.6.0 
> show databases    # 查看数据库 
> create database "jmeter"    # 创建数据库 
> use jmeter    # 切换数据库 Using database jmeter 
> create user "admin" with password '123456' with all privileges    # 创建管理员权限的用户

5.开启端口(非必须)

[root@localhost ~]# firewall-cmd --zone=public --add-port=8086/tcp --permanent success 
[root@localhost ~]# firewall-cmd --zone=public --add-port=2003/tcp --permanent success 
[root@localhost ~]# firewall-cmd --zone=public --add-port=8088/tcp --permanent success 
[root@localhost ~]# firewall-cmd --reload success

6.其他

①停止influxdb
systemctl stop influxdb.service

②根据配置文件启动 influxd -config influxdb.conf

③卸载fluxdb

rpm -q influxdb  
rpm -e influxdb  
# 删除后清除文件 
rm -rf /etc/influx

参数说明:

二、配置jmeter

添加后端监听器

image.png

三、配置Grafana

1.安装

https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-5.2.1-1.x86_64.rpm

rpm -ivh grafana-5.2.1-1.x86_64.rpm

若提示:

警告:grafana-5.2.1-1.x86_64.rpm: 头V4 RSA/SHA1 Signature, 密钥 ID 24098cb6: NOKEY

错误:依赖检测失败:

fontconfig 被 grafana-5.2.1-1.x86_64 需要

urw-fonts 被 grafana-5.2.1-1.x86_64 需要

执行:yum install fontconfig freetype* urw-fonts -y

2.启动service grafana-server start

停止 service grafana-server stop

3.配置

①登录http://IP:3000/login,账号密码admin

②创建数据源

添加数据源.png

③导入dashboard模板,常用模板id为5496

导入模板.png
上一篇 下一篇

猜你喜欢

热点阅读