Junior — Middle
What metrics do you collect and monitor using Prometheus?
sobes.tech AI
Answer from AI
Prometheus is typically used to collect and monitor the following metrics:
- Application performance metrics: response time, requests per second, errors.
- System resources: CPU load, memory usage, disk I/O, network.
- Service status: availability, dependency status.
- Custom metrics: business metrics specific to the application (e.g., number of active users).
Example of a metric in Go using the Prometheus client:
var opsProcessed = prometheus.NewCounter(prometheus.CounterOpts{
Name: "myapp_processed_ops_total",
Help: "The total number of processed events",
})
func init() {
prometheus.MustRegister(opsProcessed)
}
func processEvent() {
// process event
opsProcessed.Inc()
}
Thus, Prometheus helps monitor the state and performance of applications in real time.