prometheus / jmx_exporter

A process for exposing JMX Beans via HTTP for Prometheus consumption
Apache License 2.0
3.01k stars 1.2k forks source link

Domain name in labels (weblogic) #727

Open dargow opened 2 years ago

dargow commented 2 years ago

How can I configure the exporter to get the domain name as a label in every runtime metric? As I can see, such information is present in JMX objects: image

dhoard commented 1 year ago

You should be able use a pattern along with labels per documentation.

Nirzak commented 4 months ago

I also want to know. have used the following pattern regex but didn't work.

 - pattern: "^com.bea<Name=(.+),Type=Domain><>(.+):"
    name: weblogic_$2
    attrNameSnakeCase: true
    labels:
      domain: $1

but it didn't work.

also another thing when we see the jmx mbean we can see the mbean is like as the following, com.bea:Name=name,Type=Domain

but in jmx config we have to mention it like as below format com.bea

can someone tell me how can I dump or see all the means like as the above format so that we can easily create custom configs?

Nirzak commented 4 months ago

OK I got this working perfectly. the whitelist object will be

"com.bea:Name=*,Type=Domain"

then the config will be like as below:

- pattern: "^com.bea<Name=(.*), Type=Domain><>(id): (.+)"
    name: weblogic_id
    attrNameSnakeCase: true
    labels:
      domain: $1

so basically the metrics will be like as below weblogic_id{domain="qa05",} 0.0

then we can use prometheus rules to concat this with the other WebLogic metrics.

dhoard commented 4 months ago

@Nirzak is it worth adding this to the example Weblogic configuration example (https://github.com/prometheus/jmx_exporter/blob/main/example_configs/weblogic.yml)?

Do you want to create a PR?

Nirzak commented 4 months ago

@Nirzak is it worth adding this to the example Weblogic configuration example (https://github.com/prometheus/jmx_exporter/blob/main/example_configs/weblogic.yml)?

Do you want to create a PR?

It's your call. It depends on the usage actually. People who want the domain name fetched dynamically will need this metric. If you approve I will create a PR. Thanks.

dhoard commented 4 months ago

My thought is to create a PR with a comment and the configuration change commented out. It may help other people in the future. The files are just examples.

Nirzak commented 4 months ago

Yeah Ok will do it.