-
Notifications
You must be signed in to change notification settings - Fork 111
/
simple_prometheus_example.jmx
364 lines (340 loc) · 21.1 KB
/
simple_prometheus_example.jmx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="4.0" jmeter="4.0 r1823414">
<hashTree>
<TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="Test Plan" enabled="true">
<stringProp name="TestPlan.comments"></stringProp>
<boolProp name="TestPlan.functional_mode">false</boolProp>
<boolProp name="TestPlan.tearDown_on_shutdown">true</boolProp>
<boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
<elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
<collectionProp name="Arguments.arguments"/>
</elementProp>
<stringProp name="TestPlan.user_define_classpath"></stringProp>
</TestPlan>
<hashTree>
<ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="listener tg" enabled="true">
<stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
<boolProp name="LoopController.continue_forever">false</boolProp>
<intProp name="LoopController.loops">-1</intProp>
</elementProp>
<stringProp name="ThreadGroup.num_threads">1</stringProp>
<stringProp name="ThreadGroup.ramp_time">1</stringProp>
<boolProp name="ThreadGroup.scheduler">false</boolProp>
<stringProp name="ThreadGroup.duration"></stringProp>
<stringProp name="ThreadGroup.delay"></stringProp>
</ThreadGroup>
<hashTree>
<JSR223Sampler guiclass="TestBeanGUI" testclass="JSR223Sampler" testname="can_fail_sampler" enabled="true">
<stringProp name="TestPlan.comments">This sampler just does something to generate data for the prometheus listener.
Note that just by calling the function in the parameters section assigns the variable 'category' which the PrometheusListener plugin will pick up on.</stringProp>
<stringProp name="cacheKey">true</stringProp>
<stringProp name="filename"></stringProp>
<stringProp name="parameters">${__RandomString(1,ABC,category)}</stringProp>
<stringProp name="script">import java.util.Random;
import org.apache.commons.lang3.RandomStringUtils;
Random rand = new Random();
int maxWait = 3500;
// emulate different 'categories' being slower than others
if(args[0].equals("A")) {
maxWait = 1000;
} else if (args[0].equals("B")) {
maxWait = 1750;
} else if (args[0].equals("C")) {
maxWait = 3000;
}
int wait = rand.nextInt(maxWait);
int fail = rand.nextInt(10);
log.info("sleeping for {} ms", wait);
Thread.currentThread().sleep(wait);
if(fail >= 8 ){
SampleResult.setSuccessful(false);
SampleResult.setResponseCode("404");
}else{
SampleResult.setResponseCode("204");
}
SampleResult.setResponseData(new byte[wait]);
</stringProp>
<stringProp name="scriptLanguage">groovy</stringProp>
</JSR223Sampler>
<hashTree>
<SizeAssertion guiclass="SizeAssertionGui" testclass="SizeAssertion" testname="less than 2kB" enabled="true">
<stringProp name="Assertion.test_field">SizeAssertion.response_network_size</stringProp>
<stringProp name="SizeAssertion.size">2000</stringProp>
<intProp name="SizeAssertion.operator">4</intProp>
</SizeAssertion>
<hashTree/>
</hashTree>
<com.github.johrstrom.listener.PrometheusListener guiclass="com.github.johrstrom.listener.gui.PrometheusListenerGui" testclass="com.github.johrstrom.listener.PrometheusListener" testname="Main prometheus listener" enabled="true">
<collectionProp name="prometheus.collector_definitions">
<elementProp name="" elementType="com.github.johrstrom.listener.ListenerCollectorConfig">
<stringProp name="collector.help">the response time for a jsr223 sampler</stringProp>
<stringProp name="collector.metric_name">jsr223_rt_as_hist</stringProp>
<stringProp name="collector.type">HISTOGRAM</stringProp>
<collectionProp name="collector.labels">
<stringProp name="102727412">label</stringProp>
</collectionProp>
<stringProp name="collector.quantiles_or_buckets">100,500,1000,3000</stringProp>
<stringProp name="listener.collector.listen_to">samples</stringProp>
<stringProp name="listener.collector.measuring">ResponseTime</stringProp>
</elementProp>
<elementProp name="" elementType="com.github.johrstrom.listener.ListenerCollectorConfig">
<stringProp name="collector.help">the response time for a jsr223 sampler</stringProp>
<stringProp name="collector.metric_name">jsr223_rt_as_summary</stringProp>
<stringProp name="collector.type">SUMMARY</stringProp>
<collectionProp name="collector.labels">
<stringProp name="50511102">category</stringProp>
<stringProp name="102727412">label</stringProp>
<stringProp name="3059181">code</stringProp>
</collectionProp>
<stringProp name="collector.quantiles_or_buckets">0.75,0.5|0.95,0.1|0.99,0.01</stringProp>
<stringProp name="listener.collector.measuring">ResponseTime</stringProp>
</elementProp>
<elementProp name="" elementType="com.github.johrstrom.listener.ListenerCollectorConfig">
<stringProp name="collector.help">the total number of samplers</stringProp>
<stringProp name="collector.metric_name">jsr223_count_total</stringProp>
<stringProp name="collector.type">COUNTER</stringProp>
<collectionProp name="collector.labels">
<stringProp name="102727412">label</stringProp>
</collectionProp>
<stringProp name="collector.quantiles_or_buckets"></stringProp>
<stringProp name="listener.collector.measuring">CountTotal</stringProp>
</elementProp>
<elementProp name="" elementType="com.github.johrstrom.listener.ListenerCollectorConfig">
<stringProp name="collector.help">the total number of successful samplers</stringProp>
<stringProp name="collector.metric_name">jsr223_success_total</stringProp>
<stringProp name="collector.type">COUNTER</stringProp>
<collectionProp name="collector.labels">
<stringProp name="102727412">label</stringProp>
</collectionProp>
<stringProp name="collector.quantiles_or_buckets"></stringProp>
<stringProp name="listener.collector.measuring">SuccessTotal</stringProp>
</elementProp>
<elementProp name="" elementType="com.github.johrstrom.listener.ListenerCollectorConfig">
<stringProp name="collector.help">the response size for a jsr223 sampler</stringProp>
<stringProp name="collector.metric_name">jsr223_rsize_as_hist</stringProp>
<stringProp name="collector.type">HISTOGRAM</stringProp>
<collectionProp name="collector.labels"/>
<stringProp name="collector.quantiles_or_buckets">100,500,1000,3000</stringProp>
<stringProp name="listener.collector.measuring">ResponseSize</stringProp>
</elementProp>
<elementProp name="" elementType="com.github.johrstrom.listener.ListenerCollectorConfig">
<stringProp name="collector.help">success ratio of the can_fail_sampler</stringProp>
<stringProp name="collector.metric_name">jsr223_can_fail</stringProp>
<stringProp name="collector.type">SUCCESS_RATIO</stringProp>
<collectionProp name="collector.labels"/>
<stringProp name="collector.quantiles_or_buckets"></stringProp>
<stringProp name="listener.collector.measuring">SuccessRatio</stringProp>
</elementProp>
<elementProp name="" elementType="com.github.johrstrom.listener.ListenerCollectorConfig">
<stringProp name="collector.help">the latency (ttfb) for a jsr223 sampler</stringProp>
<stringProp name="collector.metric_name">jsr223_latency_as_hist</stringProp>
<stringProp name="collector.type">HISTOGRAM</stringProp>
<collectionProp name="collector.labels">
<stringProp name="102727412">label</stringProp>
</collectionProp>
<stringProp name="collector.quantiles_or_buckets">100,500,1000,3000</stringProp>
<stringProp name="listener.collector.measuring">Latency</stringProp>
</elementProp>
<elementProp name="" elementType="com.github.johrstrom.listener.ListenerCollectorConfig">
<stringProp name="collector.help">the idle time for a jsr223 sampler</stringProp>
<stringProp name="collector.metric_name">jsr223_idle_time</stringProp>
<stringProp name="collector.type">SUMMARY</stringProp>
<collectionProp name="collector.labels"/>
<stringProp name="collector.quantiles_or_buckets">0.75,0.5|0.95,0.1|0.99,0.01</stringProp>
<stringProp name="listener.collector.measuring">IdleTime</stringProp>
</elementProp>
<elementProp name="" elementType="com.github.johrstrom.listener.ListenerCollectorConfig">
<stringProp name="collector.help">default help string</stringProp>
<stringProp name="collector.metric_name">jsr223_assertions</stringProp>
<stringProp name="collector.type">SUCCESS_RATIO</stringProp>
<collectionProp name="collector.labels">
<stringProp name="102727412">label</stringProp>
</collectionProp>
<stringProp name="collector.quantiles_or_buckets"></stringProp>
<stringProp name="listener.collector.measuring">SuccessRatio</stringProp>
<stringProp name="listener.collector.listen_to">assertions</stringProp>
</elementProp>
</collectionProp>
<stringProp name="TestPlan.comments">This listener "measures" everything, sometimes in summaries, sometimes in histograms.</stringProp>
</com.github.johrstrom.listener.PrometheusListener>
<hashTree/>
</hashTree>
<ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="config tg" enabled="true">
<stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
<boolProp name="LoopController.continue_forever">false</boolProp>
<intProp name="LoopController.loops">-1</intProp>
</elementProp>
<stringProp name="ThreadGroup.num_threads">1</stringProp>
<stringProp name="ThreadGroup.ramp_time">1</stringProp>
<boolProp name="ThreadGroup.scheduler">false</boolProp>
<stringProp name="ThreadGroup.duration"></stringProp>
<stringProp name="ThreadGroup.delay"></stringProp>
</ThreadGroup>
<hashTree>
<com.github.johrstrom.config.PrometheusMetricsConfig guiclass="com.github.johrstrom.config.gui.PrometheusMetricsConfigGui" testclass="com.github.johrstrom.config.PrometheusMetricsConfig" testname="PrometheusMetricsConfig" enabled="true">
<collectionProp name="prometheus.collector_definitions">
<elementProp name="" elementType="com.github.johrstrom.collector.BaseCollectorConfig">
<stringProp name="collector.help">default help string</stringProp>
<stringProp name="collector.metric_name">jsr223_animals_total</stringProp>
<stringProp name="collector.type">COUNTER</stringProp>
<collectionProp name="collector.labels">
<stringProp name="94842723">color</stringProp>
<stringProp name="3530753">size</stringProp>
<stringProp name="-1081453217">mammal</stringProp>
</collectionProp>
<stringProp name="collector.quantiles_or_buckets"></stringProp>
</elementProp>
</collectionProp>
</com.github.johrstrom.config.PrometheusMetricsConfig>
<hashTree/>
<JSR223Sampler guiclass="TestBeanGUI" testclass="JSR223Sampler" testname="JSR223 Sampler" enabled="true">
<stringProp name="scriptLanguage">groovy</stringProp>
<stringProp name="parameters">${__RandomString(1,RGB,color)} ${__RandomString(1,SML,size)} ${__RandomString(1,YN,mammal)}</stringProp>
<stringProp name="filename"></stringProp>
<stringProp name="cacheKey">true</stringProp>
<stringProp name="script">import io.prometheus.client.*;
String color = vars.get("color");
String size = vars.get("size");
String mammal = vars.get("mammal");
Counter counter = (Counter) vars.getObject("jsr223_animals_total");
counter.labels(color,size,mammal).inc();
</stringProp>
</JSR223Sampler>
<hashTree>
<ConstantTimer guiclass="ConstantTimerGui" testclass="ConstantTimer" testname="Constant Timer" enabled="true">
<stringProp name="ConstantTimer.delay">3000</stringProp>
</ConstantTimer>
<hashTree/>
</hashTree>
</hashTree>
<ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="skip tg" enabled="true">
<stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
<boolProp name="LoopController.continue_forever">false</boolProp>
<intProp name="LoopController.loops">-1</intProp>
</elementProp>
<stringProp name="ThreadGroup.num_threads">1</stringProp>
<stringProp name="ThreadGroup.ramp_time">1</stringProp>
<boolProp name="ThreadGroup.scheduler">false</boolProp>
<stringProp name="ThreadGroup.duration"></stringProp>
<stringProp name="ThreadGroup.delay"></stringProp>
</ThreadGroup>
<hashTree>
<JSR223Sampler guiclass="TestBeanGUI" testclass="JSR223Sampler" testname="first_random_sampler" enabled="true">
<stringProp name="TestPlan.comments">This sampler just does something to generate data for the prometheus listener.
Note that just by calling the function in the parameters section assigns the variable 'category' which the PrometheusListener plugin will pick up on.</stringProp>
<stringProp name="cacheKey">true</stringProp>
<stringProp name="filename"></stringProp>
<stringProp name="parameters">${__RandomString(1,ABC,category)}</stringProp>
<stringProp name="script">import java.util.Random;
Random rand = new Random();
int wait = rand.nextInt(3500);
log.info("sleeping for {} ms", wait);
Thread.currentThread().sleep(wait);</stringProp>
<stringProp name="scriptLanguage">groovy</stringProp>
</JSR223Sampler>
<hashTree>
<com.github.johrstrom.listener.PrometheusListener guiclass="com.github.johrstrom.listener.gui.PrometheusListenerGui" testclass="com.github.johrstrom.listener.PrometheusListener" testname="GetFirstSample" enabled="true">
<collectionProp name="prometheus.collector_definitions">
<elementProp name="" elementType="com.github.johrstrom.listener.ListenerCollectorConfig">
<stringProp name="collector.help">the response time for a jsr223 sampler</stringProp>
<stringProp name="collector.metric_name">jsr223_rt_as_hist</stringProp>
<stringProp name="collector.type">HISTOGRAM</stringProp>
<collectionProp name="collector.labels">
<stringProp name="102727412">label</stringProp>
</collectionProp>
<stringProp name="collector.quantiles_or_buckets">100,500,1000,3000</stringProp>
<stringProp name="listener.collector.listen_to">samples</stringProp>
<stringProp name="listener.collector.measuring">ResponseTime</stringProp>
</elementProp>
</collectionProp>
</com.github.johrstrom.listener.PrometheusListener>
<hashTree/>
</hashTree>
<JSR223Sampler guiclass="TestBeanGUI" testclass="JSR223Sampler" testname="want_to_skp" enabled="true">
<stringProp name="TestPlan.comments">This sampler just does something to generate data for the prometheus listener.
Note that just by calling the function in the parameters section assigns the variable 'category' which the PrometheusListener plugin will pick up on.</stringProp>
<stringProp name="cacheKey">true</stringProp>
<stringProp name="filename"></stringProp>
<stringProp name="parameters">${__RandomString(1,ABC,category)}</stringProp>
<stringProp name="script">import java.util.Random;
Random rand = new Random();
int wait = rand.nextInt(3500);
log.info("sleeping for {} ms", wait);
Thread.currentThread().sleep(wait);</stringProp>
<stringProp name="scriptLanguage">groovy</stringProp>
</JSR223Sampler>
<hashTree/>
<JSR223Sampler guiclass="TestBeanGUI" testclass="JSR223Sampler" testname="second_random_sampler" enabled="true">
<stringProp name="TestPlan.comments">This sampler just does something to generate data for the prometheus listener.
Note that just by calling the function in the parameters section assigns the variable 'category' which the PrometheusListener plugin will pick up on.</stringProp>
<stringProp name="cacheKey">true</stringProp>
<stringProp name="filename"></stringProp>
<stringProp name="parameters">${__RandomString(1,ABC,category)}</stringProp>
<stringProp name="script">import java.util.Random;
Random rand = new Random();
int wait = rand.nextInt(3500);
log.info("sleeping for {} ms", wait);
Thread.currentThread().sleep(wait);</stringProp>
<stringProp name="scriptLanguage">groovy</stringProp>
</JSR223Sampler>
<hashTree>
<com.github.johrstrom.listener.PrometheusListener guiclass="com.github.johrstrom.listener.gui.PrometheusListenerGui" testclass="com.github.johrstrom.listener.PrometheusListener" testname="GetSampleSample" enabled="true">
<collectionProp name="prometheus.collector_definitions">
<elementProp name="" elementType="com.github.johrstrom.listener.ListenerCollectorConfig">
<stringProp name="collector.help">the response time for a jsr223 sampler</stringProp>
<stringProp name="collector.metric_name">jsr223_rt_as_hist</stringProp>
<stringProp name="collector.type">HISTOGRAM</stringProp>
<collectionProp name="collector.labels">
<stringProp name="102727412">label</stringProp>
</collectionProp>
<stringProp name="collector.quantiles_or_buckets">100,500,1000,3000</stringProp>
<stringProp name="listener.collector.listen_to">samples</stringProp>
<stringProp name="listener.collector.measuring">ResponseTime</stringProp>
</elementProp>
</collectionProp>
</com.github.johrstrom.listener.PrometheusListener>
<hashTree/>
</hashTree>
</hashTree>
<ResultCollector guiclass="ViewResultsFullVisualizer" testclass="ResultCollector" testname="View Results Tree" enabled="true">
<boolProp name="ResultCollector.error_logging">false</boolProp>
<objProp>
<name>saveConfig</name>
<value class="SampleSaveConfiguration">
<time>true</time>
<latency>true</latency>
<timestamp>true</timestamp>
<success>true</success>
<label>true</label>
<code>true</code>
<message>true</message>
<threadName>true</threadName>
<dataType>true</dataType>
<encoding>false</encoding>
<assertions>true</assertions>
<subresults>true</subresults>
<responseData>false</responseData>
<samplerData>false</samplerData>
<xml>false</xml>
<fieldNames>true</fieldNames>
<responseHeaders>false</responseHeaders>
<requestHeaders>false</requestHeaders>
<responseDataOnError>false</responseDataOnError>
<saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage>
<assertionsResultsToSave>0</assertionsResultsToSave>
<bytes>true</bytes>
<sentBytes>true</sentBytes>
<threadCounts>true</threadCounts>
<idleTime>true</idleTime>
<connectTime>true</connectTime>
</value>
</objProp>
<stringProp name="filename"></stringProp>
</ResultCollector>
<hashTree/>
</hashTree>
</hashTree>
</jmeterTestPlan>