Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WildFly 10 example #87

Merged
merged 1 commit into from Oct 21, 2016
Merged

WildFly 10 example #87

merged 1 commit into from Oct 21, 2016

Conversation

cfrantsen
Copy link
Contributor

No description provided.

---
lowercaseOutputName: true
lowercaseOutputLabelNames: true
whitelistObjectNames:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given this is a framework, you shouldn't assume only the wildfly objects are of potential interest

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So remove the whitelist or did I missunderstand you?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd remove it

attrNameSnakeCase: true
name: wildfly_messaging_$2
labels:
name: $1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Call this queue or topic

labels:
name: $1

- pattern: "^jboss.as<subsystem=transactions><>(number_of_.+):"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd not include the number_of_ in the output name. Every metric is the number of something.

@cfrantsen
Copy link
Contributor Author

Updated with your suggestions, removing the whitelist increases scrape time with ~8x but since it's just an example config i guess that's not a real problem :)

@brian-brazil brian-brazil merged commit 48088e9 into prometheus:master Oct 21, 2016
@brian-brazil
Copy link
Contributor

Thanks!

@cfrantsen cfrantsen deleted the wildfly-example branch October 22, 2016 10:32
@Starefossen
Copy link

@cfrantsen I am trying to get this working with Wildfly 10 without any luck. I am wondering if you have a complete example you could share? The problem is the connection from jmx_exporter to the jmx management interface exposed by Wildlfy...

@cfrantsen
Copy link
Contributor Author

I'm using the jmx_exporter as a java agent when running on WildFly. It requires some fiddling with start parameters to get working, below is an excerpt from the start script I'm using:

JBOSS_LOGMANAGER_JAR=$(echo $JBOSS_HOME/modules/system/layers/base/org/jboss/logmanager/main/jboss-logmanager-*.jar)
JMX_EXPORTER_JAR=$(echo /opt/prometheus/jmx_exporter/jmx_prometheus_javaagent-*.jar)

if [ -f $JBOSS_LOGMANAGER_JAR -a -f $JMX_EXPORTER_JAR ]; then
    JBOSS_MODULES_SYSTEM_PKGS="$JBOSS_MODULES_SYSTEM_PKGS,org.jboss.logmanager"

    JAVA_OPTS="$JAVA_OPTS -Xbootclasspath/p:$JBOSS_LOGMANAGER_JAR"
    JAVA_OPTS="$JAVA_OPTS -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
    JAVA_OPTS="$JAVA_OPTS -javaagent:$JMX_EXPORTER_JAR=9102:/opt/prometheus/jmx_exporter/wildfly.yaml"
fi

@Starefossen
Copy link

Starefossen commented Mar 22, 2017

Thanks Christian! Do you have to specify either hostPort or jmxUrl in the wildfly.yaml? I am using the wildfly-10.yaml from your pull request and I only see jvm_* and process_* metrics.

Here is a dump of my http://localhost:9102/metrics: gist.github.com/dbb983

@cfrantsen
Copy link
Contributor Author

No that should not be needed when running it as a java agent. Have you tried a config file without explicit rules, that should give you a huge amount of metrics back.

@Starefossen
Copy link

Starefossen commented Mar 22, 2017

I get much more output, but still nothing about Wildfly/Undertow: gist.github.com/9a8ff4.

How do you start your Wildfly? Are you using the standalone.sh command?

@Starefossen
Copy link

Starefossen commented Mar 27, 2017

Sorry for bothering; I have made a minimal Wildfly jmx_exporter example using the official Wildfly Docker image and latest version of jmx_exporter which also does not show any Wildfly specific metrics.

From the Dockerfile source:

ADD jboss-logmanager-2.0.6.Final.jar /opt/jboss/wildfly
ADD jmx_prometheus_javaagent-0.9.jar /opt/jboss/wildfly
ADD prometheus-config.yaml /opt/jboss/wildfly

ENV JAVA_OPTS "-Djboss.modules.system.pkgs=org.jboss.byteman,org.jboss.logmanager \
               -Xbootclasspath/p:/opt/jboss/wildfly/jboss-logmanager-2.0.6.Final.jar \
               -javaagent:/opt/jboss/wildfly/jmx_prometheus_javaagent-0.9.jar=31500:/opt/jboss/wildfly/prometheus-config.yaml"

You can run this yourself using docker-compose up.

@cfrantsen
Copy link
Contributor Author

We are running 0.7.3.298dcdc here right now so maybe it's a problem with recent versions? Perhaps try an older version and if that works create an issue.

@Starefossen
Copy link

Thanks a million @cfrantsen 💯 I only tried with v0.8 and v0.9, this is now working perfectly in v0.7!

@cfrantsen
Copy link
Contributor Author

Could you perhaps create an issue regarding this as it can be fixed?

@juliohm1978
Copy link
Contributor

juliohm1978 commented Feb 16, 2018

Anyone got this working for Wildfly 8.2.1? Using @cfrantsen's example it dies with the following message.

java.lang.IllegalArgumentException: Failed to load module "org.jboss.logmanager" for handler "FILE"
	at org.jboss.logmanager.config.AbstractPropertyConfiguration.<init>(AbstractPropertyConfiguration.java:67)
	at org.jboss.logmanager.config.HandlerConfigurationImpl.<init>(HandlerConfigurationImpl.java:54)
	at org.jboss.logmanager.config.LogContextConfigurationImpl.addHandlerConfiguration(LogContextConfigurationImpl.java:145)
	at org.jboss.logmanager.PropertyConfigurator.configureHandler(PropertyConfigurator.java:669)
	at org.jboss.logmanager.PropertyConfigurator.configureLogger(PropertyConfigurator.java:579)
	at org.jboss.logmanager.PropertyConfigurator.configure(PropertyConfigurator.java:517)
	at org.jboss.logmanager.PropertyConfigurator.configure(PropertyConfigurator.java:97)
	at org.jboss.logmanager.LogManager.readConfiguration(LogManager.java:300)
	at org.jboss.logmanager.LogManager.readConfiguration(LogManager.java:262)
	at java.util.logging.LogManager$3.run(LogManager.java:399)
	at java.util.logging.LogManager$3.run(LogManager.java:396)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.util.logging.LogManager.readPrimordialConfiguration(LogManager.java:396)
	at java.util.logging.LogManager.access$800(LogManager.java:145)
	at java.util.logging.LogManager$2.run(LogManager.java:345)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.util.logging.LogManager.ensureLogManagerInitialized(LogManager.java:338)
	at java.util.logging.LogManager.getLogManager(LogManager.java:378)
	at java.util.logging.Logger.demandLogger(Logger.java:448)
	at java.util.logging.Logger.getLogger(Logger.java:502)
	at io.prometheus.jmx.shaded.io.prometheus.jmx.JmxCollector.<clinit>(JmxCollector.java:38)
	at io.prometheus.jmx.shaded.io.prometheus.jmx.JavaAgent.premain(JavaAgent.java:47)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:386)
	at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401)
Caused by: java.lang.NoClassDefFoundError: org/jboss/modules/ModuleLoader
	at org.jboss.logmanager.config.AbstractPropertyConfiguration$ModuleFinder.getClassLoader(AbstractPropertyConfiguration.java:466)
	at org.jboss.logmanager.config.AbstractPropertyConfiguration.<init>(AbstractPropertyConfiguration.java:65)
	... 27 more

@juliohm1978
Copy link
Contributor

juliohm1978 commented Feb 19, 2018

Finally got it working. If anyone else is stumbling on similar issues, remember: the following flags MUST ALL be included in JAVA_OPTS.

-Djboss.modules.system.pkgs=org.jboss.byteman,org.jboss.logmanager

-Xbootclasspath/p:/path/to/logmanager-X.X.X.Final.jar

-javaagent:/path/to/jmx_prometheus_javaagent.jar=NNNN:/path/to/config.yaml

Particularly, I was running in circles trying to define JBOSS_MODULES_SYSTEM_PKGS before starting wildfly. By the looks of standalone.conf, it should end up defining the -Djboss.modules.system.pkgs flag.

... Except, it isn't for some reason.

-Djboss.modules.system.pkgs=org.jboss.logmanager needs to be there. In order for this to work. Adding it to JAVA_OPTS myself resolved the issue.

I successfully tested it with Wildfly-8.2.1.Final and Wildfly-10.1.0.Final.

PS: If you have custom-handlers defined for logging, the above will also not work. Some of our installations need to define a custom logger to send logs to a remote graylog server via UDP. With a custom-handler defined, Wildfly's LogManager will not be able to bootstrap ahead of time for JMX Exporter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants