All Downloads are FREE. Search and download functionalities are using the official Maven repository.

includes.metrics.metrics-config.adoc Maven / Gradle / Ivy

There is a newer version: 4.1.4
Show newest version
///////////////////////////////////////////////////////////////////////////////

    Copyright (c) 2021, 2024 Oracle and/or its affiliates.

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

///////////////////////////////////////////////////////////////////////////////

ifndef::rootdir[:rootdir: {docdir}/../..]
ifndef::flavor-lc[:flavor-lc: se]
:description: Helidon metrics
:keywords: helidon, metrics, configuration


// tag::config-intro[]
== Configuration

To control how the Helidon metrics subsystem behaves, add a `metrics` section to
ifdef::mp-flavor[your `META-INF/microprofile-config.properties` file.]
ifdef::se-flavor[your configuration file, such as `application.yaml`.]

include::{rootdir}/config/io_helidon_webserver_observe_metrics_MetricsObserver.adoc[tag=config,leveloffset=+1]

// end::config-intro[]

// tag::config-examples[]
[#example-configuration]
=== Example Configuration

Metrics configuration is quite extensive and powerful and, therefore, a bit complicated.
The rest of this section illustrates some of the most common scenarios:

* <>
* <>
ifdef::mp-flavor[]
* <>

endif::[]

[#config-disable]
==== Disable Metrics Subsystem

.Disabling metrics entirely
ifdef::mp-flavor[]
[source,properties]
----
metrics.enabled=false
----
endif::[]
ifdef::se-flavor[]
[source,yaml]
----
server:
  features:
    observe:
      observers:
        metrics:
          enabled: false
----
endif::[]
Helidon does not update metrics, and the `{metrics-endpoint}` endpoints respond with `404`..

[#config-kpi]
==== Collecting Basic and Extended Key Performance Indicator (KPI) {metrics_uc}

Any time you include the Helidon metrics module in your application, Helidon tracks a basic performance indicator {metric}: a `Counter` of all requests received (`requests.count`)

Helidon {h1-prefix} also includes additional, extended KPI {metrics} which are disabled by default:

* current number of requests in-flight - a `Gauge` (`requests.inFlight`) of requests currently being processed
* long-running requests - a `Counter` (`requests.longRunning`) measuring the total number of requests which take at least a given amount of time to complete; configurable, defaults to 10000 milliseconds (10 seconds)
* load - a `Counter` (`requests.load`) measuring the number of requests worked on (as opposed to received)
* deferred - a `Gauge` (`requests.deferred`) measuring delayed request processing (work on a request was delayed after Helidon received the request)

You can enable and control these {metrics} using configuration:

.Controlling extended KPI {metrics}
ifdef::mp-flavor[]
[source,properties]
----
metrics.key-performance-indicators.extended = true
metrics.key-performance-indicators.long-running.threshold-ms = 2000
----
endif::[]
ifdef::se-flavor[]
[source,yaml]
----
server:
  features:
    observe:
      observers:
        metrics:
          key-performance-indicators:
            extended: true
            long-running:
              threshold-ms: 2000
----
endif::[]

[#config-rest-request]
ifdef::mp-flavor[]
==== Enable `REST.request` {metrics_uc}

.Controlling REST request {metrics}
[source,properties]
----
metrics.rest-request-enabled=true
----
Helidon automatically registers and updates `Timer` {metrics} for every REST endpoint in your service.
endif::[]

// end::config-examples[]




© 2015 - 2025 Weber Informatics LLC | Privacy Policy