Monitoring
Monitoring data comes from two places:
- Application driven monitoring: where the application publishes readiness, status and custom metrics.
- API driven monitoring: where the API automatically publishes built-in metrics such as heartbeats, counters and histograms.
For a general overview of the monitoring stack and where this data is shown in Grafana, see Monitoring.
Application Driven Monitoring
Application driven monitoring is exposed through session.monitoring().
See JavaDoc for more details on KeySessionMonitoring.
Readiness
Readiness tells the platform when an application is ready to do useful work. A session starts with an unknown readiness state, the application should mark itself ready after it has completed its startup.
session.monitoring().readinessState(ReadinessState.READY);
This is useful when an application must finish loading config, connecting to dependencies or completing subscriptions before it should be treated as available.
Custom Status
Custom status is for application-specific state that is useful for support or other applications, for example data loading, external connectivity or completion of an important startup step.
Result result = session.monitoring()
.applicationCustomStatus("Data", Status.OK, "Database load completed");
The label identifies the status item in monitoring, the status value gives the state, and the message gives the detail. Keep labels short because they are used as monitoring identifiers and as part of the topic for monitoring events.
Counters
Counters record how many times something happened during a one minute window. They are useful for application-level quantities such as processed requests.
Counter requestCount = session.monitoring().createCounter("requests");
requestCount.increment();
Create counters once and reuse them. Recorded values are published automatically every minute and then reset.
Histograms
Histograms record measured values into buckets. They are usually used for timings, such as the time taken to process a request or generate a calculation.
Histogram curveLatency = session.monitoring().createHistogram("CurveGenLatency");
long start = System.nanoTime();
curveGenerator.generate();
curveLatency.recordValue(System.nanoTime() - start);
Create histograms once and reuse them. Recorded values are published automatically every minute and then reset.
API Driven Monitoring
The API also publishes monitoring data automatically.
| Monitoring | What It Shows |
|---|---|
| Heartbeats | Session liveness, heartbeat timing, readiness and acting leadership state. |
| Application metadata | The registered application identity and runtime details used by monitoring dashboards. |
| Built-in counters and histograms | Session-level message counts, rates and processing timings captured by the API. |
This gives every application a standard monitoring baseline before it adds any application-specific counters, histograms or status values.