[id='configure_metrics']
= Enabling {brandname} Metrics
{brandname} is compatible with the Eclipse MicroProfile Metrics API and can
generate gauge and histogram metrics.

* {brandname} metrics are provided at the `vendor` scope. Metrics related to
the JVM are provided in the `base` scope for {brandname} server.
* Gauges provide values such as the average number of nanoseconds for write
operations or JVM uptime. Gauges are enabled by default. If you enable
statistics, {brandname} automatically generates gauges.
* Histograms provide details about operation execution times such as read,
write, and remove times. {brandname} does not enable histograms by default
because they require additional computation.

.Procedure

* Configure metrics declaratively or programmatically.

.Declaratively

[source,xml,options="nowrap",subs=attributes+]
----
<cache-container statistics="true"> <1>
  <metrics gauges="true" histograms="true" /> <2>
</cache-container>
----

.Programmatically

[source,java]
----
GlobalConfiguration globalConfig = new GlobalConfigurationBuilder()
  .statistics().enable() <1>
  .metrics().gauges(true).histograms(true) <2>
  .build();
----

<1> computes and collects statistics about the Cache Manager.
<2> exports collected statistics as gauge and histogram metrics.

.Reference

* link:https://github.com/eclipse/microprofile-metrics/blob/master/README.adoc[Eclipse MicroProfile Metrics]
* link:#enable_statistics[Enabling {brandname} Statistics]
