@@ -3,18 +3,6 @@ title: Metrics
33weight : 83
44---
55
6- ## Runtime Info
7-
8- [ RuntimeInfo] ( https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/RuntimeInfo.java#L16-L16 )
9- is used mainly to check the actual health of event sources. Based on this information it is easy to implement custom
10- liveness probes.
11-
12- [ stopOnInformerErrorDuringStartup] ( https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/ConfigurationService.java#L168-L168 )
13- setting, where this flag usually needs to be set to false, in order to control the exact liveness properties.
14-
15- See also an example implementation in the
16- [ WebPage sample] ( https://github.com/java-operator-sdk/java-operator-sdk/blob/3e2e7c4c834ef1c409d636156b988125744ca911/sample-operators/webpage/src/main/java/io/javaoperatorsdk/operator/sample/WebPageOperator.java#L38-L43 )
17-
186## Metrics
197
208JOSDK provides built-in support for metrics reporting on what is happening with your reconcilers in the form of
@@ -90,7 +78,7 @@ compatibility with `histogram_quantile()` queries in Prometheus. This is importa
9078> ` OtlpMeterRegistry ` (metrics exported via OpenTelemetry Collector), it is exposed as
9179> ` reconciliations_execution_duration_milliseconds_* ` .
9280
93- #### Grafana Dashboard
81+ ### Grafana Dashboard
9482
9583A ready-to-use Grafana dashboard is available at
9684[ ` observability/josdk-operator-metrics-dashboard.json ` ] ( https://github.com/java-operator-sdk/java-operator-sdk/blob/main/observability/josdk-operator-metrics-dashboard.json ) .
@@ -100,7 +88,7 @@ executions, resource counts, and execution duration histograms and heatmaps.
10088The dashboard is designed to work with metrics exported via OpenTelemetry Collector to Prometheus, as set up by the
10189observability sample (see below).
10290
103- #### Exploring metrics end-to-end
91+ ### Exploring metrics end-to-end
10492
10593The
10694[ ` operations ` sample operator] ( https://github.com/java-operator-sdk/java-operator-sdk/tree/main/sample-operators/operations )
@@ -116,6 +104,34 @@ that:
116104This is a good starting point for experimenting with the metrics and the Grafana dashboard in a real cluster without
117105having to deploy your own operator.
118106
107+ ### Aggregated Metrics
108+
109+ The ` AggregatedMetrics ` class provides a way to combine multiple metrics providers into a single metrics instance using
110+ the composite pattern. This is particularly useful when you want to simultaneously collect metrics data from different
111+ monitoring systems or providers.
112+
113+ You can create an ` AggregatedMetrics ` instance by providing a list of existing metrics implementations:
114+
115+ ``` java
116+ // create individual metrics instances
117+ Metrics micrometerMetrics = MicrometerMetrics . withoutPerResourceMetrics(registry);
118+ Metrics customMetrics = new MyCustomMetrics ();
119+ Metrics loggingMetrics = new LoggingMetrics ();
120+
121+ // combine them into a single aggregated instance
122+ Metrics aggregatedMetrics = new AggregatedMetrics (List . of(
123+ micrometerMetrics,
124+ customMetrics,
125+ loggingMetrics
126+ ));
127+
128+ // use the aggregated metrics with your operator
129+ Operator operator = new Operator (client, o - > o. withMetrics(aggregatedMetrics));
130+ ```
131+
132+ This approach allows you to easily combine different metrics collection strategies, such as sending metrics to both
133+ Prometheus (via Micrometer) and a custom logging system simultaneously.
134+
119135### MicrometerMetrics (Deprecated)
120136
121137> ** Deprecated** : ` MicrometerMetrics ` (V1) is deprecated as of JOSDK 5.3.0. Use ` MicrometerMetricsV2 ` instead.
@@ -167,30 +183,3 @@ scope` where tags in square brackets (`[]`) won't be present when per-resource c
167183by a question mark are omitted if the value is empty. In the context of controllers' execution metrics, these tag names
168184are prefixed with ` resource. ` .
169185
170- ### Aggregated Metrics
171-
172- The ` AggregatedMetrics ` class provides a way to combine multiple metrics providers into a single metrics instance using
173- the composite pattern. This is particularly useful when you want to simultaneously collect metrics data from different
174- monitoring systems or providers.
175-
176- You can create an ` AggregatedMetrics ` instance by providing a list of existing metrics implementations:
177-
178- ``` java
179- // create individual metrics instances
180- Metrics micrometerMetrics = MicrometerMetrics . withoutPerResourceMetrics(registry);
181- Metrics customMetrics = new MyCustomMetrics ();
182- Metrics loggingMetrics = new LoggingMetrics ();
183-
184- // combine them into a single aggregated instance
185- Metrics aggregatedMetrics = new AggregatedMetrics (List . of(
186- micrometerMetrics,
187- customMetrics,
188- loggingMetrics
189- ));
190-
191- // use the aggregated metrics with your operator
192- Operator operator = new Operator (client, o - > o. withMetrics(aggregatedMetrics));
193- ```
194-
195- This approach allows you to easily combine different metrics collection strategies, such as sending metrics to both
196- Prometheus (via Micrometer) and a custom logging system simultaneously.
0 commit comments