Observability
dotwire exports OpenTelemetry metrics and traces over OTLP. Metrics are on by default and traces are opt-in. Logs are not exported over OTLP.
No room, message, user or sender id, no NATS subject, no SQL text and no message content ever leaves dotwire as a metric, tag or span attribute. This is enforced in code, not left to convention: dotwire's own instruments never take ids, and filters drop or allowlist the tags from third-party libraries. See "What's scrubbed" below.
dotwire only speaks OTLP. It works with any collector and backend, and never depends on one being up.
Turn it on or off
| Setting | Default | Effect |
|---|---|---|
Dotwire__DisableMetrics | false | true registers no meter provider, and the JetStream poller doesn't run. |
Dotwire__EnableTracing | false | true exports traces to the same OTLP endpoint. It works with or without metrics. |
OTEL_EXPORTER_OTLP_ENDPOINT | http://localhost:4317 | Where metrics and traces are sent. |
The other standard OpenTelemetry variables apply too: OTEL_EXPORTER_OTLP_PROTOCOL, OTEL_EXPORTER_OTLP_HEADERS, OTEL_METRIC_EXPORT_INTERVAL, OTEL_SERVICE_NAME (default dotwire), OTEL_RESOURCE_ATTRIBUTES, OTEL_TRACES_SAMPLER and OTEL_TRACES_SAMPLER_ARG.
Inside a container, localhost is the container itself. compose.yaml and compose.multinode.yaml pass OTEL_EXPORTER_OTLP_ENDPOINT through with the localhost default, so set it to your collector's address. If you don't run a collector, set Dotwire__DisableMetrics=true.
Every process reports as its own series, identified by service.instance.id. The node role is the dotwire.node.role resource attribute.
Local dashboard (Grafana)
compose.observability.yaml is an optional overlay. It adds one grafana/otel-lgtm container, which bundles an OpenTelemetry Collector, Prometheus, Tempo, Loki and Grafana, with a provisioned dotwire dashboard.
OTEL_EXPORTER_OTLP_ENDPOINT=http://lgtm:4317 Dotwire__EnableTracing=true \
docker compose -f compose.yaml -f compose.observability.yaml up -d
Open http://localhost:3000 and go to Dashboards → dotwire. The same overlay works with compose.multinode.yaml, and every node reports to it.
The dashboard shows health stats with the suggested alert thresholds below, traffic and latency by route, connections, send duration, JetStream ack time, fanout lag and drops, rejections and webhooks, JetStream lag, the database per pool, the .NET runtime, auth lookups, and recent traces.
- It's for development and demos. Grafana runs with anonymous admin access, so the overlay publishes it on
127.0.0.1only and keeps the OTLP ports internal. Data lives in thelgtmdatavolume. - In production, point
OTEL_EXPORTER_OTLP_ENDPOINTat your own collector and importobservability/grafana/dotwire.jsoninto your Grafana. It expects Prometheus and Tempo data sources with the uidsprometheusandtempo. - To edit the dashboard, change
observability/grafana/dotwire.json, then rundocker compose -f compose.yaml -f compose.observability.yaml restart lgtm. Grafana reads the file only at startup. Data survives the restart. - Empty panels are normal until something happens. Webhook panels stay empty without webhooks configured, and rejections appear after the first one.
Metrics
dotwire's own instruments are on the meter Dotwire.
Health
| Instrument | Kind | Tags | What it measures |
|---|---|---|---|
dotwire.jetstream.consumer.pending | Gauge, {message} | stream, consumer | Messages the Postgres writer (ROOMS) or audit writer (AUDIT) hasn't processed or acked yet. |
dotwire.jetstream.consumer.oldest_pending.age | Gauge, s | stream, consumer | Age of the oldest unprocessed message. 0 when nothing is pending. |
dotwire.jetstream.stream.bytes | Gauge, By | stream | Bytes stored in the stream. |
dotwire.jetstream.stream.messages | Gauge, {message} | stream | Messages stored in the stream. |
dotwire.jetstream.stream.max_bytes | Gauge, By | stream | The stream's byte limit. Reported only when one is set (AUDIT). |
dotwire.jetstream.stream.max_age | Gauge, s | stream | The stream's age limit. Reported only when one is set (ROOMS). |
dotwire.audit.writer.lock_held | Gauge, 1 | none | 1 on the node that holds the audit writer lock, 0 elsewhere. See Audit log. |
dotwire.audit.unavailable | Counter, {response} | none | 503 audit_unavailable responses: admin changes refused because they couldn't be audited. |
The JetStream gauges come from a poller that reads ROOMS and AUDIT stream and consumer state every 30 seconds. It runs on All and Api nodes, not on Gateway nodes. Each of those nodes reports the same cluster-wide values, so take max() across nodes, never a sum. When a poll fails, that stream's gauges disappear instead of freezing at the last value, so alert on their absence.
Send and delivery
| Instrument | Kind | Tags | What it measures |
|---|---|---|---|
dotwire.message.send.duration | Histogram, s | transport (hub, rest), outcome (accepted, rejected, unavailable) | A member send from start to finish: validation, presend, encryption, the JetStream ack and the live republish. Admin injection isn't included. |
dotwire.jetstream.publish.duration | Histogram, s | outcome (ok, error) | The JetStream publish and ack only, for member sends and admin injection. |
dotwire.fanout.lag | Histogram, s | none | From the message timestamp, set by the sending node, to local fanout. It includes clock skew between nodes. |
dotwire.fanout.dropped | Counter, {event} | transport (hub, sse), reason (slow_consumer, ephemeral_shed) | slow_consumer: an event found the client's buffer full, which disconnects that client. ephemeral_shed: a typing or presence event skipped because the buffer was half full. |
dotwire.sse.active_connections | Gauge, {connection} | none | Open SSE streams on this node. |
Rejections and webhooks
| Instrument | Kind | Tags | What it measures |
|---|---|---|---|
dotwire.rejections | Counter, {rejection} | transport (hub, rest, sse), reason (rate_limited, too_many_connections, busy), operation (connect, subscribe, unsubscribe, send, audit_verify) | Rejections outside the rate-limit middleware: hub connects and calls, REST sends when hub sends are on, the SSE connection cap, and the full audit-verify gate. Middleware rejections are in aspnetcore.rate_limiting.requests. |
dotwire.webhook.presend.results | Counter, {call} | outcome (allowed, allowed_with_rewrite, rejected, unavailable, failed_open) | Presend call-outs by result. See Moderation webhooks. |
dotwire.webhook.postsend.dropped | Counter, {event} | reason (queue_bytes, queue_full, max_attempts) | Postsend events dropped because the queue was full or delivery kept failing. |
Auth lookups
| Instrument | Kind | Tags | What it measures |
|---|---|---|---|
dotwire.auth.lookup.duration | Histogram, s | path (direct, batched) | REST membership lookups that missed the cache. |
dotwire.auth.cache.lookups | Counter, {lookup} | result (hit, miss) | Auth cache results. Only with Dotwire__AuthCacheSeconds above 0. |
dotwire.auth.batch.size | Histogram, {lookup} | none | Lookups per batched query. Only with Dotwire__AuthBatching__Enabled=true. |
Built-in meters
dotwire also exports these .NET and library meters: ASP.NET Core hosting, Kestrel, SignalR connections, rate limiting, System.Net.Http, System.Runtime, Npgsql and NATS.Net.
Npgsql's pool metrics carry db.client.connection.pool.name, which is read or write, so you can watch the two pools separately.
In Prometheus
Sent to Prometheus through OTLP, names become snake case with unit suffixes:
dotwire.rejectionsbecomesdotwire_rejections_total.dotwire.jetstream.consumer.oldest_pending.agebecomesdotwire_jetstream_consumer_oldest_pending_age_seconds.dotwire.audit.writer.lock_heldbecomesdotwire_audit_writer_lock_held_ratio.
service.name and service.instance.id become the service_name and service_instance_id labels. The node role is on target_info as dotwire_node_role.
Suggested alert thresholds
Each limit is its own gauge, so the first two rows are ratios. Treat these as starting points.
| Signal | Warn | Critical | What it means |
|---|---|---|---|
ROOMS oldest_pending.age / max_age, max() across nodes | > 0.25 | > 0.5 | The Postgres writer is falling behind. Messages that reach the stream's max age (48 hours by default) before they're inserted are lost from history. |
AUDIT stream.bytes / max_bytes | > 0.5 | > 0.8 | Audit events are backing up. At the cap, admin changes start failing with 503 audit_unavailable. |
sum(audit.writer.lock_held) across nodes | 0 for 5 min | No node is writing the audit log. | |
rate(audit.unavailable) | > 0 | Admin changes are being refused. | |
rate(webhook.presend.results) with outcome unavailable or failed_open | > 0 for 5 min | Your presend endpoint is failing. Sends are refused or skip moderation, depending on the fail policy. | |
rate(webhook.postsend.dropped) | > 0 | Postsend events are being lost. | |
| JetStream gauges absent | 5 min | The poller is failing, or NATS is unreachable. | |
dotwire.rejections, aspnetcore.rate_limiting.requests | Depends on your traffic. No default. | Clients are hitting rate limits or connection caps. | |
Tracing
Set Dotwire__EnableTracing=true to export traces. Spans go to the same OTLP endpoint as metrics.
dotwire traces:
- ASP.NET Core server requests, named by route template, for example
GET /rooms/{roomId}/participants. - SignalR hub invocations, for example
Dotwire.Realtime.RoomHub/Send. - Outbound HTTP: webhooks and JWKS fetches.
- Npgsql commands.
NATS spans aren't collected. Their names carry subjects, and turning them on would make the NATS client write trace headers into stored JetStream messages.
Sampling. The default is parent-based always-on, so an incoming traceparent decides. To sample less under load, set OTEL_TRACES_SAMPLER=parentbased_traceidratio and OTEL_TRACES_SAMPLER_ARG=0.1.
What's scrubbed
A raw trace or third-party metric would carry URL paths, SQL text and span attributes, which would put room, message and user ids in your APM. dotwire removes them before export.
Traces. A processor runs before the exporter and keeps only these tags:
http.request.method, http.response.status_code, http.route, url.scheme, network.protocol.version, server.address, server.port, error.type, rpc.system, rpc.service, rpc.method, db.system.name, db.operation.name, db.response.status_code.
It also clears status descriptions and incoming tracestate. URL paths and queries, SQL text, client addresses, user agents and connection-string fragments are removed.
Span events can't be stripped, and a failed query's exception message can quote parameter values. So a span with a tagged event, in practice a recorded exception, isn't exported at all. Its parent request span still carries error.type and the status code.
Metrics. Views filter the third-party meters:
NATS.Netmessaging.client.*metrics are dropped, because they carry subjects.nats.client.*metrics carry no tags.db.client.*metrics keep onlydb.client.connection.state,db.client.connection.pool.name,db.operation.nameanderror.type.
The pool name is safe because dotwire names both data sources read and write. Without a name, Npgsql fills that tag with parts of the connection string.
Related
- Configuration: the telemetry settings next to every other option.
- Deployment: node roles and the Compose files.
- Compliance: how the metrics fit the SOC 2 monitoring controls.