Skip to main content

Service Desk Observability

The service desk feature exposes 5 Prometheus/OpenTelemetry metrics, structured slog logging on every error path, and integrates with the existing request tracing pipeline. Key handlers are instrumented with OpenTelemetry trace spans for end-to-end visibility.

Metrics

All metrics are registered under the proxima_ namespace and can be scraped from the /metrics endpoint.

MetricTypeLabelsDescription
proxima_service_desk_queries_totalCountersource, endpointTotal ClickHouse/JSM queries executed
proxima_service_desk_query_duration_secondsHistogramsource, endpointQuery latency distribution
proxima_service_desk_writes_totalCounteractionSuccessful JSM write operations
proxima_service_desk_write_errors_totalCounteractionFailed JSM write operations
proxima_service_desk_pending_writesUpDownCounterCurrent count of active pending writes

Label Values

source: clickhouse or jsm

endpoint (ClickHouse): tickets_count, tickets, ticket_detail, ticket_history, ticket_sla, ticket_delivery, kanban, metrics_sla, metrics_delivery, summary_counts, summary_sla, export_csv

endpoint (JSM): comments, approvals, transitions, attachments, request_type_fields

action: create, comment, transition, approve, attach

Example PromQL Queries

# Service desk query rate by source
rate(proxima_service_desk_queries_total[5m])

# Average ClickHouse query latency
rate(proxima_service_desk_query_duration_seconds_sum{source="clickhouse"}[5m])
/ rate(proxima_service_desk_query_duration_seconds_count{source="clickhouse"}[5m])

# JSM write error rate
rate(proxima_service_desk_write_errors_total[5m])

# Current pending writes gauge
proxima_service_desk_pending_writes

# P99 query latency by endpoint
histogram_quantile(0.99,
rate(proxima_service_desk_query_duration_seconds_bucket[5m])
)

Logging

All service desk handlers use slog.ErrorContext(r.Context(), ...) with consistent attributes:

{
"level": "ERROR",
"msg": "clickhouse data query failed",
"component": "api",
"error": "clickhouse: query: status 500: ...",
"trace_id": "abc123",
"span_id": "def456"
}

Write operations include additional context:

{
"level": "INFO",
"msg": "service desk ticket created",
"component": "api",
"issue_key": "PROJ-100"
}

The JSM client logs errors with context for trace correlation:

{
"level": "ERROR",
"msg": "jsm api error",
"component": "jsmclient",
"status": 429,
"error": "jsm: rate limited: rate limited",
"body": "..."
}

Pending Writes Cleanup

A background goroutine runs every 60 seconds to clean up expired pending writes:

  • Deletes rows where expires_at < NOW()
  • Decrements the proxima_service_desk_pending_writes gauge by the number of deleted rows
  • Logs the cleanup count at DEBUG level
  • Respects server shutdown context for graceful termination

OTel Trace Spans

The following handlers create OTel trace spans, visible in Tempo:

HandlerSpan NameNotes
ListTicketsservice_desk.list_ticketsParent span; ClickHouse count and data queries are child spans
GetTicketservice_desk.get_ticketParent span; history, SLA, and delivery queries run as parallel child spans
CreateTicketservice_desk.create_ticketCovers JSM API call and PostgreSQL pending write insert

The parallel sub-spans on GetTicket make it easy to identify which supplementary query (history, SLA, delivery) is slowest for a given request.

Cross-Signal Correlation

Use the standard observability workflow:

# 1. Find service desk errors
./scripts/obs.sh errors 15m | grep "service.desk\|clickhouse\|jsm"

# 2. Trace a specific request
./scripts/obs.sh trace <request_id>

# 3. Check service desk metrics trend
./scripts/obs.sh metrics proxima_service_desk_

Alerting Suggestions

Consider setting alerts for:

ConditionQuerySeverity
JSM write error rate > 5%rate(proxima_service_desk_write_errors_total[5m]) / rate(proxima_service_desk_writes_total[5m]) > 0.05Warning
ClickHouse P99 latency > 5shistogram_quantile(0.99, rate(proxima_service_desk_query_duration_seconds_bucket{source="clickhouse"}[5m])) > 5Warning
Pending writes accumulatingproxima_service_desk_pending_writes > 50Warning
JSM rate limitingrate(proxima_service_desk_write_errors_total{action=~".*"}[5m]) > 0 and rate(proxima_service_desk_queries_total{source="jsm"}[5m]) > 40Info