# Metrics

The gateway exposes Prometheus metrics on the `/metrics` endpoint configured in the `monitor` section. All gateway-specific metrics use the `synadia_protect_` prefix.

## Connection metrics

| Metric                                   | Type  | Labels                         | Description        |
| ---------------------------------------- | ----- | ------------------------------ | ------------------ |
| `synadia_protect_proxy_connection_count` | gauge | `connection_kind`, `port_name` | active connections |

```
synadia_protect_proxy_connection_count{connection_kind="client",port_name="clients"} 1
```

## Protocol metrics

| Metric                                | Type    | Labels                                                  | Description            |
| ------------------------------------- | ------- | ------------------------------------------------------- | ---------------------- |
| `synadia_protect_nats_protocol_count` | counter | `connection_kind`, `direction`, `port_name`, `protocol` | protocol message count |
| `synadia_protect_nats_protocol_bytes` | counter | `connection_kind`, `direction`, `port_name`, `protocol` | protocol bytes         |

Labels:

| Label             | Values                                                                          |
| ----------------- | ------------------------------------------------------------------------------- |
| `connection_kind` | `client`, `leaf`                                                                |
| `direction`       | `to_backend`, `from_backend`                                                    |
| `port_name`       | port name from config                                                           |
| `protocol`        | `CONNECT`, `INFO`, `PUB`, `HPUB`, `SUB`, `UNSUB`, `MSG`, `HMSG`, `PING`, `PONG` |

```
synadia_protect_nats_protocol_count{connection_kind="client",direction="to_backend",port_name="clients",protocol="MSG"} 3

synadia_protect_nats_protocol_bytes{connection_kind="client",direction="to_backend",port_name="clients",protocol="MSG"} 198
```

## Rule metrics

| Metric                                      | Type    | Labels                                             | Description                 |
| ------------------------------------------- | ------- | -------------------------------------------------- | --------------------------- |
| `synadia_protect_rule_decision_count`       | counter | `connection_kind`, `decision`, `port_name`, `rule` | rule decisions by outcome   |
| `synadia_protect_rule_evaluation_ran_count` | counter | `rule`                                             | successful rule evaluations |
| `synadia_protect_rule_evaluation_seconds`   | summary | `language`, `rule`                                 | rule evaluation latency     |

The `rule` label identifies the specific rule within a bundle (e.g., `suspend-test@1.0.0/rules/builtins/com_synadia_protect_builtins_v1_suspend_header_message.yaml#1`).

The `decision` label shows the outcome: `allow`, `deny`, `error`, `suspend`.

```
synadia_protect_rule_decision_count{connection_kind="client",decision="suspend",port_name="clients",rule="suspend-test@1.0.0/..."} 3

synadia_protect_rule_evaluation_ran_count{rule="suspend-test@1.0.0/..."} 3

synadia_protect_rule_evaluation_seconds_sum{language="expr",rule="suspend-test@1.0.0/..."} 7.5791e-05

synadia_protect_rule_evaluation_seconds_count{language="expr",rule="suspend-test@1.0.0/..."} 3
```

## Auditor metrics

| Metric                                | Type    | Labels         | Description                                     |
| ------------------------------------- | ------- | -------------- | ----------------------------------------------- |
| `synadia_protect_auditor_processed`   | counter | —              | total audit events processed                    |
| `synadia_protect_auditor_dropped`     | counter | —              | audit events dropped (processor full or failed) |
| `synadia_protect_processor_active`    | gauge   | `name`, `type` | active audit processors                         |
| `synadia_protect_processor_processed` | counter | `name`         | events processed per processor                  |

```
synadia_protect_auditor_processed 1349

synadia_protect_auditor_dropped 0

synadia_protect_processor_active{name="file",type="file"} 1

synadia_protect_processor_processed{name="file"} 1349
```

## Bundle sync metrics

| Metric                                  | Type  | Labels | Description                                                 |
| --------------------------------------- | ----- | ------ | ----------------------------------------------------------- |
| `synadia_protect_bundle_sync_connected` | gauge | —      | bundle sync connection status (0=disconnected, 1=connected) |
| `synadia_protect_bundle_sync_syncing`   | gauge | —      | bundle sync active status (0=idle, 1=syncing)               |

These are relevant for managed gateways that sync bundles from a configuration server.

## Subject tracking metrics

When `count_message_with_subject` or `count_message_bytes_with_subject` are configured under `monitor.counters`, additional per-subject counters appear:

```
monitor:

  host: 0.0.0.0

  port: 8080

  counters:

    count_message_with_subject:

      - 'orders.>'

    count_message_bytes_with_subject:

      - 'orders.>'
```

```
synadia_protect_subject_stats_message_count{direction="to_backend",port_name="clients",subject="orders.>"} 141

synadia_protect_subject_stats_message_bytes{direction="to_backend",port_name="clients",subject="orders.>"} 69139
```

These track messages matching the configured subject patterns, not individual subjects. Subject patterns must not overlap, with a maximum of 1000 entries per list.

## Configuration

See [monitor](/protect/1.0/reference/configuration.md#monitor) in the Configuration Reference.
