11.11. Enabling the JBoss Metrics Plug-in
The JBoss Metrics plug-in supports JBoss EAP 6 and JBossAS 7 version cartridges and is used to print JBoss metrics to stdout.
Enable the JBoss metrics plug-in by ensuring your JBoss application has the following in the application's
standalone.xml
file within the <extensions>
element:
<extension module="com.openshift.metrics"/>
Then configure the metrics subsystem inside the
<profile>
element to look similar to the following:
Example 11.16. JBoss Metrics Plug-in XML
<subsystem xmlns="urn:redhat:openshift:metrics:1.0"> <max-line-length>1024</max-line-length> <metrics-group cron="*/5 * * * * ?"> <source type="jboss" path="core-service=platform-mbean/type=memory-pool/name=CMS_Old_Gen"> <metric source-key="usage.used" publish-key="oldgen.used" /> <metric source-key="usage.max" publish-key="oldgen.max" /> <metric source-key="usage.committed" publish-key="oldgen.committed" /> </source> <source path="java.lang:type=Memory" type="mbean"> <metric source-key="HeapMemoryUsage.used" publish-key="jmx.heap.used"/> </source> </metrics-group> </subsystem>
As in the above example, you can specify one or more sources inside a metrics group. Anything that is a valid JBoss resource, such as
core-service=platform-mbean/type=memory-pool/name=CMS_Old_Gen
, or a valid MBean, such as java.lang:type=Memory
can be a source. Each source has a type (jboss
or mbean
) and a path, which is the name of the resource. A source contains one or more data points that can be read and published. You can specify a source-key (the location in the source of the data point) and a publish-key (the label of the information when written to stdout). Metrics are printed to stdout similar to the following:
Example 11.17. Logged Metrics Data
Jun 10 16:25:39 vm openshift-platform[29398]: type=metric appName=php6 gear=53961099e659c55b08000102 app=53961099e659c55b08000102 ns=demo quota.blocks.used=988 quota.blocks.limit=1048576 quota.files.used=229 quota.files.limit=80000
You can specify one or more
metrics-group
entries in order to group together the data points you wish to emit at any interval. For example, to emit memory data every 10 seconds but database connection pool data every 30 seconds, you would need two different metrics groups, because their schedules are different.
Note that you can add
enabled="false"
to any <metrics-group>
, <source>
, or <metric>
attribute to disable it from being logged:
<metrics-group enabled="false">