jmeter-prometheus-plugin
jmeter-prometheus-plugin copied to clipboard
Collect thread group as a label
Currently we only collect threads with the state
label. This ticket is to add the group
label to indicate what thread group a given thread is in.
Hey sorry to get back to you so late @antplant, in the interum while I get to this, here's how you can implement this with a JSR223 Sampler and the Prometheus config element. Once this does get implemented, it will require a Prometheus Listener in every thread group so that the listener can get the thread group information from the context (that first group =
line there), so that'll be kinda weird and have to be specified for this to work as expected.
Then here, in a given thread, you could find the group name, and how
Given a gauge named enhanced_jmeter_threads
with labels state,group_name
you could do this.
import io.prometheus.client.*;
group = ctx.getThreadGroup();
Gauge guage = (Gauge) vars.getObject("enhanced_jmeter_threads");
int total = group.getNumThreads();
int active = group.getNumberOfThreads();
int notFinished = group.numberOfActiveThreads();
int finished = total - notFinished;
String name = group.getName();
guage.labels("total", name).set(total);
guage.labels("active", name).set(active);
guage.labels("finished", name).set(finished);
that's a nice workaround. but not good enough :) it creates another sampler metrics. and you need to remember to have it on every thread group.
this should probably be part of the plugin itself.
looking at the plugin code, it looks like the change should be in ThreadCollector
, first in getConfig()
to add the 'groupName' label. and then somehow in method collect()
need to get access to all the groups and their thread count.
as this is my first jmeter plugin coding, can you guide me how to get that information? the JMeterContextService
doesn't seems to have reference to all groups.
thanks.
another interesting information would be to get the real thread state i.e. BLOCKED, RUNNABLE, TIMED_WAITING, WAITING.
this information is available on jvm_threads_state
metric, but again without the group name...
Yea coming back to it after so long I don't really know off hand. This plugin isn't under active development anymore, so i'm not sure when or if it'll ever get implemented.
This plugin isn't under active development anymore, so i'm not sure when or if it'll ever get implemented.
Oh, so sad to hear 😭😭😭.
The enhancement suggestion seems to be a really good one to me.
Pull requests welcome! Does this not work for you?
https://github.com/johrstrom/jmeter-prometheus-plugin/issues/66#issuecomment-553206254
Does this not work for you?
I'd more agree with @yarix :
that's a nice workaround. but not good enough :) it creates another sampler metrics. and you need to remember to have it on every thread group.
this should probably be part of the plugin itself.