Monitoring Moose Applications
When running Moose applications in production, comprehensive monitoring is essential for ensuring performance, reliability, and quick troubleshooting. Moose provides several built-in monitoring capabilities that you can leverage in your deployment.
Health Monitoring
Moose applications expose a health check endpoint at /health
that returns a 200 OK response when the application is operational.
This endpoint is used by container orchestration systems like Kubernetes to determine the health of your application.
In production environments, we recommend configuring three types of probes:
- Startup Probe: Gives Moose time to initialize before receiving traffic
- Readiness Probe: Determines when the application is ready to receive traffic
- Liveness Probe: Detects when the application is in a deadlocked state and needs to be restarted
See our Kubernetes deployment guide for specific configuration details.
Prometheus Metrics
Moose applications expose metrics in Prometheus format at the /metrics
endpoint. These metrics include:
- HTTP request latency histograms for each endpoint
- Request counts and error rates
- System metrics for the Moose process
Example metrics output:
# HELP latency Latency of HTTP requests.
# TYPE latency histogram
latency_sum{method="POST",path="ingest/UserActivity"} 0.025
latency_count{method="POST",path="ingest/UserActivity"} 2
latency_bucket{le="0.001",method="POST",path="ingest/UserActivity"} 0
latency_bucket{le="0.01",method="POST",path="ingest/UserActivity"} 0
latency_bucket{le="0.02",method="POST",path="ingest/UserActivity"} 1
latency_bucket{le="0.05",method="POST",path="ingest/UserActivity"} 1
latency_bucket{le="0.1",method="POST",path="ingest/UserActivity"} 1
latency_bucket{le="0.25",method="POST",path="ingest/UserActivity"} 1
latency_bucket{le="0.5",method="POST",path="ingest/UserActivity"} 1
latency_bucket{le="1.0",method="POST",path="ingest/UserActivity"} 1
latency_bucket{le="5.0",method="POST",path="ingest/UserActivity"} 1
latency_bucket{le="10.0",method="POST",path="ingest/UserActivity"} 1
latency_bucket{le="30.0",method="POST",path="ingest/UserActivity"} 1
latency_bucket{le="60.0",method="POST",path="ingest/UserActivity"} 1
latency_bucket{le="120.0",method="POST",path="ingest/UserActivity"} 1
latency_bucket{le="240.0",method="POST",path="ingest/UserActivity"} 1
latency_bucket{le="+Inf",method="POST",path="ingest/UserActivity"} 1
You can scrape these metrics using a Prometheus server or similar monitoring system compatible with the Prometheus format.
OpenTelemetry Integration
In production deployments, Moose can be configured to export telemetry data using OpenTelemetry. This is enabled through environment variables:
MOOSE_TELEMETRY__ENABLED=true
MOOSE_TELEMETRY__EXPORT_METRICS=true
When running in Kubernetes with an OpenTelemetry operator, you can configure automatic sidecar injection by adding annotations to your deployment:
metadata:
annotations:
"sidecar.opentelemetry.io/inject": "true"
Logging
Moose provides structured logging that can be configured for production environments:
MOOSE_LOGGER__LEVEL=Info
MOOSE_LOGGER__STDOUT=true
MOOSE_LOGGER__FORMAT=Json
The JSON log format is particularly useful for log aggregation systems like ELK Stack, Graylog, or cloud logging solutions.
Production Monitoring Stack
For comprehensive monitoring of Moose applications in production, we recommend:
- Metrics Collection: Prometheus or cloud-native monitoring services
- Log Aggregation: ELK Stack, Loki, or cloud logging solutions
- Distributed Tracing: Jaeger or other OpenTelemetry-compatible tracing backends
- Alerting: Alertmanager or cloud provider alerting
Error Tracking
Moose can be integrated with error tracking systems like Sentry through environment variables:
SENTRY_DSN=https://your-sentry-dsn
RUST_BACKTRACE=1
This will capture and report detailed error information to help with debugging production issues.
Please share your feedback about Moose monitoring capabilities through our GitHub repository.