NatsHighSubscriptionsCount #
High number of NATS subscriptions ({{ $value }}) for {{ $labels.instance }}
Alert Rule
alert: NatsHighSubscriptionsCount
annotations:
description: |-
High number of NATS subscriptions ({{ $value }}) for {{ $labels.instance }}
VALUE = {{ $value }}
LABELS = {{ $labels }}
runbook: https://srerun.github.io/prometheus-alerts/runbooks/nats-exporter/natshighsubscriptionscount/
summary: Nats high subscriptions count (instance {{ $labels.instance }})
expr: gnatsd_connz_subscriptions > 50
for: 3m
labels:
severity: warning
Here is a runbook for the Prometheus alert rule NatsHighSubscriptionsCount
:
Meaning #
The NatsHighSubscriptionsCount
alert is triggered when the number of NATS subscriptions exceeds 50 for an instance. This alert indicates that there is a high number of subscriptions to NATS subjects, which can cause performance issues and increased memory usage.
Impact #
A high number of NATS subscriptions can lead to:
- Increased memory usage, potentially causing performance issues or even crashes
- Slower message processing times, affecting the overall system performance
- Potential bottlenecks in the NATS cluster, leading to message loss or delays
Diagnosis #
To diagnose the issue, follow these steps:
- Check the NATS cluster performance metrics, such as CPU usage, memory usage, and message throughput.
- Investigate the subscription patterns to identify which subjects are causing the high subscription count.
- Check the application logs for any errors or warnings related to NATS connections or message processing.
- Verify that the NATS configuration is correct and optimal for the current workload.
Mitigation #
To mitigate the issue, follow these steps:
- Identify the root cause of the high subscription count and take corrective action:
- If it’s due to a misconfigured application, adjust the configuration to reduce the number of subscriptions.
- If it’s due to a sudden increase in workload, consider scaling up the NATS cluster or optimizing the application to handle the load.
- Implement subscription filtering or subject pruning to reduce the number of unnecessary subscriptions.
- Consider implementing a subscription limit or quota to prevent excessive subscriptions.
- Monitor the NATS cluster performance and adjust the configuration as needed to ensure optimal performance.
Additional resources: