You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: instrumentation/jmx-metrics/README.md
+21-17Lines changed: 21 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -229,6 +229,10 @@ The metric descriptions will remain undefined, unless they are provided by the q
229
229
### State Metrics
230
230
231
231
Some JMX attributes expose current state as a non-numeric MBean attribute, in order to capture those as metrics it is recommended to use the special `state` metric type.
232
+
233
+
This type of metric fits the [semantic conventions recommendations for state metric](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/how-to-write-conventions/status-metrics.md),
234
+
using the `.status` suffix is compliant with the [naming recommendations](https://github.com/open-telemetry/semantic-conventions/blob/main/docs/how-to-write-conventions/status-metrics.md#naming).
235
+
232
236
For example, with Tomcat connector, the `Catalina:type=Connector,port=*` MBean has `stateName` (of type `String`), we can define the following rule:
233
237
234
238
```yaml
@@ -238,56 +242,56 @@ rules:
238
242
mapping:
239
243
stateName:
240
244
type: state
241
-
metric: tomcat.connector
245
+
metric: tomcat.connector.status
242
246
metricAttribute:
243
247
port: param(port)
244
-
connector_state:
248
+
tomcat.connector.state:
245
249
ok: STARTED
246
250
failed: [STOPPED,FAILED]
247
251
degraded: '*'
248
252
```
249
253
250
-
For a given value of `port`, let's say `8080` This will capture the `tomcat.connector.state` metric of type `updowncounter` with value `0` or `1` and the `state` metric attribute will have a value in [`ok`,`failed`,`degraded`].
251
-
For every sample, 3 metrics will be captured for each value of `state` depending on the value of `stateName`:
254
+
For a given value of `port`, let's say `8080` This will capture the `tomcat.connector.status` metric of type `updowncounter` with value `0` or `1` and the `tomcat.connector.state` metric attribute will have a value in [`ok`,`failed`,`degraded`].
255
+
For every sample, 3 metrics will be captured for each value of `tomcat.connector.state` depending on the value of `stateName`:
Each state key can be mapped to one or more values of the MBean attribute using:
272
276
- a string literal or a string array
273
277
- a `*` character to provide default option and avoid enumerating all values, this value must be quoted in YAML
274
278
275
279
Exactly one `*` value must be present in the mapping to ensure all possible values of the MBean attribute can be mapped to a state key.
276
280
277
-
The default value indicated by `*` does not require a dedicated state key. For example, if we want to have `connector_state` metric attribute with values `on` or `off`, we can use:
281
+
The default value indicated by `*` does not require a dedicated state key. For example, if we want to have `tomcat.connector.state` metric attribute with values `on` or `off`, we can use:
278
282
```yaml
279
-
connector_state:
283
+
tomcat.connector.state:
280
284
on: STARTED
281
285
off: [STOPPED,FAILED,'*']
282
286
```
283
287
In the particular case where only two values are defined, we can simplify further by explicitly defining one state and rely on default for the other.
284
288
```yaml
285
-
connector_state:
289
+
tomcat.connector.state:
286
290
on: STARTED
287
291
off: '*'
288
292
```
289
293
290
-
State metrics do not have a unit (nor source unit) and use an empty string `""` as unit.
294
+
State metrics do not need to define `unit` nor `sourceUnit` attributes, the unit of the metric will always be `1`.
Copy file name to clipboardExpand all lines: instrumentation/jmx-metrics/library/src/test/java/io/opentelemetry/instrumentation/jmx/engine/RuleParserTest.java
Copy file name to clipboardExpand all lines: instrumentation/jmx-metrics/library/src/test/java/io/opentelemetry/instrumentation/jmx/yaml/MetricStructureTest.java
0 commit comments