Interview Observability

How do you instrument an application with a Prometheus client library? [Intermediate]

Answer

To instrument an application, I add a Prometheus client library, define a small set of well-named counters, gauges, and histograms, expose a /metrics endpoint, and ensure labels are bounded and useful.

Technical explanation

Start with service RED metrics: request count, error count, and request duration histogram.

Add domain metrics only when they drive SLOs, capacity planning, or operational debugging.

Protect cardinality by using route templates, status classes, dependency names, and environment labels rather than IDs.

Hands-on example

Python Flask sketch:

from prometheus_client import Counter, Histogram, generate_latest

REQ = Counter('http_requests_total','Requests',['route','method','status'])

LAT = Histogram('http_request_duration_seconds','Latency',['route'])

@app.get('/metrics')

def metrics(): return generate_latest(), 200, {'Content-Type':'text/plain'}

Preparing for an interview?

Check how well your resume matches the role with our free resume checker— match score, ATS check, and the skills you're missing.

More Observability interview questions

← All Observability questions