Skip to content

Commit 1bb4302

Browse files
committed
add documentation
1 parent 550b003 commit 1bb4302

File tree

1 file changed

+48
-0
lines changed
  • instrumentation/jmx-metrics/javaagent

1 file changed

+48
-0
lines changed

instrumentation/jmx-metrics/javaagent/README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,54 @@ Thus, the above definitions will create several metrics, named `my.kafka.streams
221221

222222
The metric descriptions will remain undefined, unless they are provided by the queried MBeans.
223223

224+
### State Metrics
225+
226+
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.
227+
For example, with Tomcat connector, the `Catalina:type=Connector,port=*` MBean has `stateName` (of type `String`), we can define the following rule:
228+
229+
```yaml
230+
---
231+
rules:
232+
- bean: Catalina:type=Connector,port=*
233+
mapping:
234+
stateName:
235+
type: state
236+
metric: tomcat.connector.state
237+
metricAttribute:
238+
port: param(port)
239+
state:
240+
ok: STARTED
241+
failed: [STOPPED,FAILED]
242+
degraded: '*'
243+
```
244+
245+
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`].
246+
For every sample, 3 metrics will be captured for each value of `state` depending on the value of `stateName`:
247+
248+
When `stateName` = `STARTED`, we have:
249+
250+
- `tomcat.connector.state` value = `1`, attributes `port` = `8080` and `state` = `ok`
251+
- `tomcat.connector.state` value = `0`, attributes `port` = `8080` and `state` = `failed`
252+
- `tomcat.connector.state` value = `0`, attributes `port` = `8080` and `state` = `degraded`
253+
254+
When `stateName` = `STOPPED` or `FAILED`, we have:
255+
256+
- `tomcat.connector.state` value = `0`, attributes `port` = `8080` and `state` = `ok`
257+
- `tomcat.connector.state` value = `1`, attributes `port` = `8080` and `state` = `failed`
258+
- `tomcat.connector.state` value = `0`, attributes `port` = `8080` and `state` = `degraded`
259+
260+
For other values of `stateName`, we have:
261+
262+
- `tomcat.connector.state` value = `0`, attributes `port` = `8080` and `state` = `ok`
263+
- `tomcat.connector.state` value = `0`, attributes `port` = `8080` and `state` = `failed`
264+
- `tomcat.connector.state` value = `1`, attributes `port` = `8080` and `state` = `degraded`
265+
266+
Each state key can be mapped to one or more values of the MBean attribute using:
267+
- a string literal or a string array
268+
- a `*` wildcard to provide default option and avoid enumerating all values.
269+
270+
Exactly one wildcard is expected to be present in the mapping to ensure all possible values of the MBean attribute can be mapped to a state key.
271+
224272
### General Syntax
225273

226274
Here is the general description of the accepted configuration file syntax. The whole contents of the file is case-sensitive, with exception for `type` as described in the table below.

0 commit comments

Comments
 (0)