[[MicroProfile_Metrics_SmallRye]]
= MicroProfile Metrics Subsystem Configuration

Support for https://microprofile.io/project/eclipse/microprofile-metrics[MicroProfile Metrics] is provided by
 the _microprofile-metrics-smallrye_ subsystem.

[[required-extension-microprofile-metrics-smallrye]]
== Required Extension

This extension is included in the standalone-microprofile configurations included in the
WildFly distribution.

You can also add the extension to a configuration without it either by adding
an `<extension module="org.wildfly.extension.microprofile.metrics-smallrye"/>`
element to the xml or by using the following CLI operation:

[source,options="nowrap"]
----
[standalone@localhost:9990 /] /extension=org.wildfly.extension.microprofile.metrics-smallrye:add
----

It depends on the base metrics extension `org.wildfly.extension.metrics` that must be installed.

== Management Model

The `/subsystem=microprofile-metrics-smallrye` resource defines two attributes:

* `exposed-subsystems` - a list of strings corresponding to the names of subsystems that exposes their metrics in the HTTP metrics endpoints.
  By default, it is not defined (there will be no metrics exposed by subsystem. The special wildcard "*" can be used to expose metrics from _all_ subsystems. The standalone
  configuration sets this attribute to "*".
* `prefix` - A string to prepend to WildFly metrics that are exposed by the HTTP endpoint `/metrics` with the Prometheus output format.

== HTTP Endpoint

The Metric HTTP endpoint is accessible on WildFly HTTP management interface http://localhost:9990/metrics[http://localhost:9990/metrics].

Secured access to the HTTP endpoint is controlled by the `security-enabled` attribute of the `/subsystem=microprofile-metrics-smallrye` resource.
The value of this attribute will override the `security-enabled` attribute of the `/subsystem=metrics` resource (documented in <<metrics-http-endpoint,Metrics subsystem configuration guide>>).

When the `microprofile.metrics-smallrye` is installed, this HTTP endpoint will return metrics according to MicroProfile Metrics specification.

----
$ curl -v http://localhost:9990/metrics
< HTTP/1.1 200 OK
...
# HELP base:classloader_total_loaded_class_count Displays the total number of classes that have been loaded since the Java virtual machine has started execution
.
# TYPE base:classloader_total_loaded_class_count counter
base:classloader_total_loaded_class_count 10822.0
...
----

== Exposed Metrics

The HTTP endpoint exposes the following metrics:

* Base metrics - Required metrics specified in the MicroProfile 1.1 specification are exposed in the `base`  scope.
* Vendor metrics - Vendor-specific metrics (e.g. for memory pools)
* Application metrics - Metrics from the application and from the deployment's subsystems are exposed in the `application` scope.

The WildFly metrics (that measures activity in the subsystem or application deployments) are exposed only on the `/metrics`
endpoint with the Prometheus format.

== Component Reference

The MicroProfile Metrics implementation is provided by the SmallRye Metrics project.

****

* https://microprofile.io/project/eclipse/microprofile-metrics[MicroProfile Metrics]
* http://github.com/smallrye/smallrye-metrics/[SmallRye Metrics]

****