emails_received, emails_sent, emails_bounced if you’re building a transaction email
service.
How to instrument your services
LocalOps by default embeds prometheus in every environment. To make your service’s metrics available to prometheus, follow these steps to make sure you expose an endpoint that responds with metrics values as expected by prometheus.1. Use a prometheus client library in code
You can do this without prometheus client library too but it is much easier if you use the library. Prometheus officially supports these client libraries:- Go (example)
- Java
- Python
- Rust
2. Expose an endpoint in your service like /metrics
Define a specific endpoint like /metrics in your service and connect the prometheus client libraries url handler
functions with it. This endpoint will be called by the inbuilt monitoring stack (prometheus) periodically to scrap the
metrics exposed in step 1.
3. Declare the metrics endpoint in ops.json
ops.json lets you define configuration specific to your service. Just declare a metrics key like below in
ops.json:
interval is to inform prometheus how often this endpoint must be hit. Please don’t keep it too low like 1 second. Your
service might get too busy handling these requests instead of handling real user requests.
LocalOps will then make these metrics available automatically in the Grafana dashboard via Prometheus, just like any
other metric.