johrstrom / jmeter-prometheus-plugin

A Prometheus Listener for Apache JMeter that exposes results in an http API
Apache License 2.0
166 stars 110 forks source link

Add response_code and response_message metrics #59

Closed OlegKashtanov closed 5 years ago

OlegKashtanov commented 5 years ago

Hi! On influx backend listener "responseMessage", "responseCode" fields are available. And responseMessage is used when we have a error response. They are very useful in grafana table view like that: image. Is it possible to add that kind of metrics?

johrstrom commented 5 years ago

Response code for sure, See the README for code is a keyword. It's the response code of the result.

I don't think response message is really appropriate though. Remember these are prometheus metrics and we're not supposed to have labels with super high cardinality, like response messages.

johrstrom commented 5 years ago

That said, take a look a the README again - specifically this bit about creating arbitrary labels from variables.

If you where able extract the response message from jmeter, maybe through a JSR223 PostProcessor and put it into a variable, called, say response_message - then add response_message to the labels of a given metric, then you would be collecting the response message.

Again, this is not recommended, so you may want to check in the JSR223 post processor if the response size is less than so much or if it starts with 'Not HTTP response', etc then you add it, if not you just assign an empty string.

Response codes should work out of the box with the code, and should even capture codes like that exception message you have shown.

OlegKashtanov commented 5 years ago

Thanks. It works for me.