---
description: Reference for the JMX detection criterion.
date_published: 2026-08-13
date_modified: 2026-08-13
canonical_url: https://metricshub.org/community-connectors/develop/detection/jmx.html
---

# Detection by JMX

On this Page

- [When to Use](#when-to-use)
- [Syntax](#syntax)
- [Properties](#properties)
- [Runtime Behavior](#runtime-behavior)
- [Recommended Pattern](#recommended-pattern)
- [Common Mistakes](#common-mistakes)
- [Examples](#examples)

## When to Use

Use `jmx` when connector eligibility is tied to a specific MBean/object name and attribute set. Typical usage: Java middleware and databases exposing JMX (for example Cassandra).

## Syntax

```yaml
connector:
  detection:
    criteria:
    - type: jmx
      objectName: org.apache.cassandra.metrics:type=Storage,name=Load
      attributes:
      - Count
      expectedResult: ^[0-9]
```

## Properties

| Property | Required | Default | Description |
| --- | --- | --- | --- |
| `type` | Yes | - | `jmx`. |
| `objectName` | Yes | - | MBean object name/pattern to query. Must be non-blank. |
| `attributes` | Yes | - | List of attributes read from the MBean. |
| `expectedResult` | No | none | Regex matched against serialized JMX result. |
| `errorMessage` | No | none | Connector-authored failure context (for logs/reporting). |
| `forceSerialization` | No | `false` | Guarantees operations are performed sequentially against one host. |

## Runtime Behavior

JMX query results are treated as a table (`List<Map<String,String>>`) and serialized as `=`-separated name-value pairs before matching.

- No `expectedResult`: success if serialized result is non-empty.
- With `expectedResult`: case-insensitive regex match.

See below example on how a JMX result is converted to text before matching with `expectedResult`:

#### Criterion

```yaml
- type: jmx
  objectName: org.apache.cassandra.metrics:type=Storage,name=Load
  attributes:
  - Count
  - Unit
  expectedResult: Count=[0-9]+
```

#### Result

| Count | Unit |
| --- | --- |
| 123456 | bytes |

#### Result As Text

```text
Count=123456
Unit=bytes
```

✅ The criterion passes because the serialized text contains a line that matches `expectedResult: Count=[0-9]+`.

## Recommended Pattern

- Query one deterministic MBean for detection.
- Request only required attributes.
- Match stable numeric or enum-like values rather than free text.

## Common Mistakes

- Using too many attributes in detection when one is enough.
- Matching volatile values (timestamps, counters with changing format).
- Confusing detection criteria with data collection monitors.

## Examples

Community example — the `jmx` criterion of [Cassandra](https://github.com/metricshub/community-connectors/blob/main/src/main/connector/database/Cassandra/Cassandra.yaml), included directly from the connector source:

```
- type: jmx
  objectName: org.apache.cassandra.metrics:type=Storage,name=Load
  attributes:
  - Count
  expectedResult: ^[0-9]
```
