

JMeter 实时监控仪表板配置 (Grafana + InfluxDB) · TesterHome
source link: https://testerhome.com/topics/11256?
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

从我的博客搬运:
http://keithmo.me/post/2017/12/2017-12-16-jmeter-grafana-dashboard/【警告】这篇东西是配置笔记,你会看到满屏鸡肠,不打算自己做一个可以不看。成品我已经传到官网了,能直接导入 Grafana 里,地址如下:
https://grafana.com/dashboards/4026接下来还会配 Gatling、服务器性能指标、数据库、MQ 的等等,都是把官网上一些比较好的拿来改造成方便自己看的样子
在服务器上跑 JMeter 做压测的话,给工具本身也配上实时监控是必须的,命令行输出能提供的信息太少。
JMeter 的 Backend Listener 支持 Graphite 和 InfluxDB,这里选择 InfluxDB 做时序数据库,支持类似 SQL 的查询语法是最大的优点。另外在 JMeter 3.2+ 里配置起来也比 Graphite 方便太多。(缺点是直到写这篇文章时官网文档都没更新,要自己查存储的字段,猜它有什么用)
Grafana 能配出非常漂亮的监控仪表板,就是配的过程非常痛苦,不做非常详细的笔记的话过几天又忘光了,于是有了这篇东西。
- 采集器:JMeter 3.2+,Backend Listener 里选择
InfluxdbBackendListenerClient
- 数据源:InfluxDB 1.4+
面板:Grafana 4.6+
- 已添加好数据源
- 新建面板,添加 3 行
吞吐率和响应时间图表只计算成功的请求(失败的通常没意义,超时失败的能在表格里看到数量),结果可能会跟 JMeter 里看到的有出入。
已经上传到 Grafana 官网,可以从以下地址下载 JSON 文件,或通过 ID 4026
直接导入:
https://grafana.com/dashboards/4026
JMeter Backend Listener 参考配置:
Settings
General
- Name:
JMeter Dashboard
- Description:
Monitor your JMeter load test in real time with InfluxDB and Grafana.
- Tags:
load_test
- Name:
Rows
-
Summary
,Errors
,Individual Transaction - $transaction
-
Templating
$data_source
- Name:
data_source
- Type: Datasource
- Type: InfluxDB
$application
- Name:
application
- Type: Query
- Data source:
$data_source
- Refresh: On Dashboard Load
- Query:
SHOW TAG VALUES FROM "$measurement_name" WITH KEY = "application"
$transaction
- Name:
transaction
- Type: Query
- Data source:
$data_source
- Refresh: On Dashboard Load
- Query:
SHOW TAG VALUES FROM "$measurement_name" WITH KEY = "transaction" WHERE "application" =~ /^$application$/ AND "transaction" != 'internal' AND "transaction" != 'all'
可惜 templating 里不支持 $timeFilter
(由于 InfluxDB show tag values
语法的限制),时间久了之后各种接口名看着会比较乱。
$measurement_name
- Name:
measurement_name
- Label:
Measurement name
- Type: Constant
- Hide: Variable
- Value:
jmeter
(JMeter Backend Listener 默认)
$send_interval
- Name:
send_interval
- Label:
Backend send interval
- Type: Constant
- Hide: Variable
- Value:
5
(JMeter InfluxdbBackendListenerClient 默认)
Annotations
编辑 Annotations & Alerts(Built-in)
- Name:
Start/stop marker
- Data source:
$data_source
- Query:
select text from events where $timeFilter
Singlestat - Total Requests
, Span 4
Metric
Data Source:
$data_source
- Options - Min time interval:
[[send_interval]]s
- Options - Min time interval:
SELECT sum("count") FROM "$measurement_name" WHERE ("application" =~ /^$application$/ AND "transaction" = 'all') AND $timeFilter GROUP BY time($__interval) fill(null)
Options
Value
- Stat: Total
- Postfix:
Requests
- Decimals:
0
- Coloring: Value,把中间的颜色换成浅一点的黄色
- Value Mappings: null ->
0
Singlestat - Failed Requests
, Span 4
Metric
Data Source:
$data_source
- Options - Min time interval:
[[send_interval]]s
- Options - Min time interval:
SELECT sum("countError") FROM "$measurement_name" WHERE ("transaction" = 'all' AND "application" =~ /^$application$/) AND $timeFilter GROUP BY time($__interval) fill(null)
Options
Value
- Stat: Total
- Postfix:
Failed
- Decimals:
0
- Coloring: Value,把中间的颜色换成红色
- Value Mappings: null ->
0
Singlestat - Error Rate %
, Span 4
Metric
Data Source:
$data_source
- Options - Min time interval:
[[send_interval]]s
- Options - Min time interval:
SELECT sum("error") / sum("all") FROM (SELECT sum("count") AS "all" FROM "$measurement_name" WHERE "transaction" = 'all' AND "application" =~ /^$application$/ AND $timeFilter GROUP BY time($__interval) fill(null)), (SELECT sum("countError") AS "error" FROM "$measurement_name" WHERE "transaction" = 'all' AND "application" =~ /^$application$/ AND $timeFilter GROUP BY time($__interval) fill(null))
Options
Value
- Stat: Total
- Unit: percent(0.0-1.0)
- Decimals:
2
- Coloring: Value,Thresholds:
0,0.01
- Gauge: Show,Max:
1
- Value Mappings: null ->
0
Graph - Total Throughput
, Span: 4
Metric
Data Source:
$data_source
- Options - Min time interval:
[[send_interval]]s
- Options - Min time interval:
SELECT mean("count") / $send_interval FROM "$measurement_name" WHERE ("transaction" = 'all' AND "application" =~ /^$application$/) AND $timeFilter GROUP BY time($__interval) fill(null)
- alias:
Req / sec
Legend
- As Table, Min, Max, Avg,Decimals:
2
- As Table, Min, Max, Avg,Decimals:
Display
- Lines,Fill:
7
, Null value:null
- Lines,Fill:
Graph - Total Errors
, Span: 4
Metric
Data Source:
$data_source
- Options - Min time interval:
[[send_interval]]s
- Options - Min time interval:
SELECT sum("countError") FROM "$measurement_name" WHERE ("transaction" = 'all' AND "application" =~ /^$application$/) AND $timeFilter GROUP BY time($__interval) fill(null)
- alias:
Num of Errors
Axes
- Decimals:
0
- Decimals:
Legend
- As Table, Total,Decimals:
0
- As Table, Total,Decimals:
Display
- Lines,Fill:
7
, Null value:null
- Lines,Fill:
Graph - Active Threads
, Span: 4
Metric
Data Source:
$data_source
- Options - Min time interval:
[[send_interval]]s
- Options - Min time interval:
SELECT last("maxAT") FROM "$measurement_name" WHERE ("transaction" = 'internal' AND "application" =~ /^$application$/) AND $timeFilter GROUP BY time($__interval) fill(null)
- alias:
Threads
Axes
- Decimals:
0
- Decimals:
Legend
- As Table, Current,Decimals:
0
- As Table, Current,Decimals:
Display
- Lines,Fill:
7
, Null value:null
- Lines,Fill:
Graph - Transactions Response Times (95th pct)
, Span: 4
Metric
Data Source:
$data_source
- Options - Min time interval:
[[send_interval]]s
- Options - Min time interval:
SELECT mean("pct95.0") FROM "$measurement_name" WHERE ("statut" = 'ok' AND "application" =~ /^$application$/) AND $timeFilter GROUP BY "transaction", time($__interval) fill(null)
- alias:
$tag_transaction
Axes
- Units:
milliseconds(ms)
- Units:
Legend
- As Table, To the right, Max, Avg,Decimals:
2
- As Table, To the right, Max, Avg,Decimals:
Display
- Lines,Null value:
null
Thresholds
- T1: lt
500
, ok, Fill, Line - T2: gt
1500
, warning, Line - T3: gt
5000
, critical, Fill, Line
- T1: lt
- Lines,Null value:
Table - Errors per Transaction
, Span: 4
Metric
Data Source:
$data_source
- Options - Min time interval:
[[send_interval]]s
- Options - Min time interval:
SELECT sum("count") FROM "$measurement_name" WHERE ("application" =~ /^$application$/ AND "statut" = 'ko') AND $timeFilter GROUP BY "transaction"
- format: Table
Column Styles
- Time - Type: Hidden
- /.*/ - Decimals:
0
Table - Error Info
, Span: 8
Metric
Data Source:
$data_source
- Options - Min time interval:
[[send_interval]]s
- Options - Min time interval:
SELECT sum("count") FROM "$measurement_name" WHERE ("application" =~ /^$application$/ AND "responseCode" !~ /^$/) AND $timeFilter GROUP BY "responseCode","responseMessage"
- format: Table
Column Styles
- Time: Type - Hidden
- /.*/ : Decimals
0
复制第 1 行的图表(除了线程图),改一下 SQL 和一些细节就行。
Singlestat - Total Requests - $transaction
, Span 4
Metric
Data Source:
$data_source
- Options - Min time interval:
[[send_interval]]s
- Options - Min time interval:
SELECT sum("count") FROM "$measurement_name" WHERE ("application" =~ /^$application$/ AND "transaction" =~ /^$transaction$/ AND "statut" = 'all') AND $timeFilter GROUP BY time($__interval) fill(null)
Options
Value
- Stat: Total
- Postfix:
Requests
- Decimals:
0
- Coloring: Value,把中间的颜色换成浅一点的黄色
- Value Mappings: null ->
0
Singlestat - Failed Requests - $transaction
, Span 4
Metric
Data Source:
$data_source
- Options - Min time interval:
[[send_interval]]s
- Options - Min time interval:
SELECT sum("count") FROM "$measurement_name" WHERE ("application" =~ /^$application$/ AND "transaction" =~ /^$transaction$/ AND "statut" = 'ko') AND $timeFilter GROUP BY time($__interval) fill(null)
Options
Value
- Stat: Total
- Postfix:
Failed
- Decimals:
0
- Coloring: Value,把中间的颜色换成红色
- Value Mappings: null ->
0
Singlestat - Error Rate % - $transaction
, Span 4
Metric
Data Source:
$data_source
- Options - Min time interval:
[[send_interval]]s
- Options - Min time interval:
SELECT sum("error") / sum("all") FROM (SELECT sum("count") AS "all" FROM "$measurement_name" WHERE "transaction" =~ /^$transaction$/ AND "statut" = 'all' AND "application" =~ /^$application$/ AND $timeFilter GROUP BY time($__interval) fill(null)), (SELECT sum("count") AS "error" FROM "$measurement_name" WHERE "transaction" =~ /^$transaction$/ AND "statut" = 'ko' AND "application" =~ /^$application$/ AND $timeFilter GROUP BY time($__interval) fill(null))
Options
Value
- Stat: Total
- Unit: percent(0.0-1.0)
- Decimals:
2
- Coloring: Value,Thresholds:
0,0.01
- Gauge: Show,Max:
1
- Value Mappings: null ->
0
Graph - Throughput - $transaction
, Span: 4
Metric
Data Source:
$data_source
- Options - Min time interval:
[[send_interval]]s
- Options - Min time interval:
SELECT last("count") / $send_interval FROM "$measurement_name" WHERE ("transaction" =~ /^$transaction$/ AND "statut" = 'ok') AND $timeFilter GROUP BY time($__interval)
- alias:
Req / sec
Legend
- As Table, Min, Max, Avg,Decimals:
2
- As Table, Min, Max, Avg,Decimals:
Display
- Lines,Fill:
7
, Null value:null
- Lines,Fill:
Graph - Errors - $transaction
, Span: 4
Metric
Data Source:
$data_source
- Options - Min time interval:
[[send_interval]]s
- Options - Min time interval:
SELECT sum("count") FROM "$measurement_name" WHERE "application" =~ /^$application$/ AND "transaction" =~ /^$transaction$/ AND "statut" = 'ko' AND $timeFilter GROUP BY time($__interval) fill(null)
- alias:
Num of Errors
Axes
- Decimals:
0
- Decimals:
Legend
- As Table, Total,Decimals:
0
- As Table, Total,Decimals:
Display
- Lines,Fill:
7
- Points, Point Radius:
1
- Null value:
null
- Lines,Fill:
Graph - Response Times - $transaction
, Span: 4
Metric
Data Source:
$data_source
- Options - Min time interval:
[[send_interval]]s
- Options - Min time interval:
SELECT last("avg") FROM "$measurement_name" WHERE ("transaction" =~ /^$transaction$/ AND "statut" = 'ok') AND $timeFilter GROUP BY time($__interval)
- alias:
Average
- alias:
SELECT last("pct50.0") FROM "$measurement_name" WHERE ("transaction" =~ /^$transaction$/ AND "statut" = 'ok') AND $timeFilter GROUP BY time($__interval)
- alias:
Median
- alias:
SELECT last("pct90.0") FROM "$measurement_name" WHERE ("transaction" =~ /^$transaction$/ AND "statut" = 'ok') AND $timeFilter GROUP BY time($__interval) fill(null)
- alias:
90th Percentile
- alias:
SELECT last("pct95.0") FROM "$measurement_name" WHERE ("transaction" =~ /^$transaction$/ AND "statut" = 'ok') AND $timeFilter GROUP BY time($__interval) fill(null)
- alias:
95th Percentile
- alias:
SELECT last("pct99.0") FROM "$measurement_name" WHERE ("transaction" =~ /^$transaction$/ AND "statut" = 'ok') AND $timeFilter GROUP BY time($__interval) fill(null)
- alias:
99th Percentile
- alias:
SELECT last("max") FROM "$measurement_name" WHERE ("transaction" =~ /^$transaction$/ AND "statut" = 'ok') AND $timeFilter GROUP BY time($__interval) fill(null)
- alias:
Max
- alias:
Axes
- Units:
milliseconds(ms)
- Units:
Legend
- As Table, To the right
- Max, Avg,Decimals:
2
- Hide Series: With only nulls
Display
- Lines,Null value:
null
Thresholds
- T1: lt
500
, ok, Fill, Line - T2: gt
1500
, warning, Line - T3: gt
5000
, critical, Fill, Line
- T1: lt
- Lines,Null value:
导出的 JSON 文件没有 data source,无法直接导入,需要手动编辑文件,在 "__inputs": []
里加入以下:
如果想上传到官网,为了能正确分类,"__requires": []
里还要加入以下:
Recommend
-
38
前一段时间自家养的几只猫经常出问题,由于没有有效的监控预警手段,以至于问题出现或者许久一段时间才会被通知到。凌晨一点这个锅可谁都不想背,为此基于目前的情况搭建了以下这么一套监控预警系统。
-
32
-
27
1 前言 Springboot 的运维监控是微服务系统必备的,不然就感觉是瞎子跑步,随时可能摔跤。本文通过 Springboot 整合 InfluxDB+Grafana 的方式进行监控,以保证系统可靠运行。 ...
-
11
概述:Telegraf收集信息,influxdb时序数据库存储数据,grafana平台展示数据,并进行监控告警,组成一个自动化运维监控平台。 一、influxdb InfluxDB是一个由InfluxData开发的开源时序型数据。它由Go写成,着力于高...
-
14
我们都知道Jmeter提供了原生的结果查看,既然有原生的查看结果,为什么还要多此一举使用其他工具进行查看呢,除了查看内容丰富外还有最主要的原因: Jmeter提供的查看结果插件本身是比较消耗性能的,所以在正式压测中应当禁用。...
-
10
基于 Prometheus、InfluxDB 与 Grafana 打造高可用监控平台 ...
-
9
Prometheus+InfluxDB+Grafana 打造高逼格监控平台!发布于 10 月 25 日在本模块中,我将把几个常用的监控部分给梳理一下。前面我们提到过,在性能监控图谱中,有操...
-
8
平时一般用Jmeter的Gui模式,添加对应的插件,查看每秒线程数、TPS、响应时间等曲线,其实高并发是不建议这么看的。 可以搭配InfluxDB+Grafana工具,使Jmeter异步发送数据到InfluxDB,然后由Grafana查询并展示出来,方便查看与比对。 之前使用Do...
-
5
Grafana 系列文章 Prometheus Template Variables 你可以使用变量来代替硬编码的细节,如 server、app 和 pod_name 在 metric...
-
9
Grafana系列-统一展示-6-Zabbix仪表板
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK