REST Endpoint
MicroProfile Metrics specifies that all metrics are published at the endpoint /metrics
. For both Payara Server and Payara Micro, this means that the endpoint can be found on the HTTP port (default 8080
). By visiting these endpoints in a browser, the Prometheus text format can be viewed directly.
Metric Scopes
The Metrics specification defines four Scopes, Base, Vendor, Application and Custom which correspond to the following purposes:
- Base
-
Base metrics are a set of optional metrics that a compliant server may provide. A server that provides this kind of metric can implement all, some of them or none of them. A reason to choose a different set of metrics is that the metrics libraries they are using in their implementation come with metrics with a similar purpose to the spec-described base metrics.
These metrics can be accessed under
/metrics?scope=base
.These metrics must be tagged with
mp_scope=base
. - Vendor
-
Vendor metrics are specific to each implementation and are intended to offer metrics which are unique to each vendor.
These metrics can be accessed under
/metrics?scope=vendor
.These metrics must be tagged with
mp_scope=vendor
. - Application
-
Application metrics are reserved for those metrics which are to be exposed from the application by using the developer API.
These metrics can be accessed under
/metrics?scope=application
.These metrics must be tagged with
mp_scope=application
. - Custom Scopes
-
Applications may also define their own scope names by tagging metrics with a custom scope name (other than base, vendor or application).
These metrics can be accessed under
/metrics?scope=scope_name
.These metrics must be tagged with
mp_scope=scope_name
.For example:
@RequestScoped
public class Component{
@Gauge(name = "gaugeMethod", unit = MetricUnits.NONE, scope = "mygauge")
public long getGauge() {
log.info("Private Gauge:"+getPrivateGauge());
return gauge;
}
}