前提:
已安装jmeter(>5.4版本)和influxdb2
方法一:
1、打开一个已经准备好的jmeter脚本
2、添加后端监听器:
名称:自定义
注释:自定义
后端监听器实现:选择第三个【org-apache,jmeter.visualizers.backend.influxdb.InfluxdbBackendListenerClient】
异步队列大小:5000
influxdbUrl:http://influxdb_ip:8086/write?db=jmeter&org=XX&bucket=XX
添加:influxdbToken
其余默认
运行-如果 成功如下图:右上角无报错
如果不成功有报错responseBody: 'code":'not found',"message":"no dbrp mapping found
解决方法:
- 在influxdb2的机器上安装influxdb-cli客户端
- docker安装
- rpm安装
地址:https://www.influxdata.com/downloads/
复制出来后到机器上运行# influxdata-archive_compat.key GPG fingerprint: # 9D53 9D90 D332 8DC7 D6C8 D3B9 D8FF 8E1F 7DF8 B07E cat <<EOF | sudo tee /etc/yum.repos.d/influxdata.repo [influxdata] name = InfluxData Repository - Stable baseurl = https://repos.influxdata.com/stable/\$basearch/main enabled = 1 gpgcheck = 1 gpgkey = https://repos.influxdata.com/influxdata-archive_compat.key EOF sudo yum install influxdb2-cli
安装结束后执行influxdb命令 如果出现如下帮助信息说明安装成功
创建config配置信息,让influxdb-cli能连接到influxdb2influx config create --config-name influxdb-cli-config --host-url http://127.0.0.1:8086 --org 360 --token Fil8idBI1El8aVuzKforL8Yl-x2PEtcoUVMJS44mAXANMo40-j_NxegYDYHgycgqvmLyM-rfNOXqpebBMGQMLg== --active
创建库
influx v1 dbrp create --db jmeter --rp jmeter --bucket-id 4c4de4678fbd0d95 --default
方法二:
如何确定jmeter把数据写入influxdb?
在任意终端(cmd,linux等)运行以下命令:
curl --get http://10.160.128.159:8086/query --header "Authorization: Token Fil8idBI1El8aVuzKforL8Yl-x2PEtcoUVMJS44mAXANMo40-j_NxegYDYHgycgqvmLyM-rfNOXqpebBMGQMLg==" --data-urlencode "q=select * from jmeter.jmeter.jmeter order by time desc limit 2 tz('Asia/Shanghai');"