Prometheus Metrics

Instrumenting system diagnostics, counting requests, and exporting metrics to Prometheus monitoring systems.

Lord1Egypt Updated 2 repo stars

File contents

Prometheus Metrics

Overview

Prometheus is a free software ecosystem for monitoring and alerting, relying on pull-based timeseries ingestion.

When to Use This Skill

Use to track system loads, latency distributions, and error rates of running web applications.

Quick Start (with runnable code examples)

from prometheus_client import start_http_server, Counter
import time

# Create a metric to track requests
REQUESTS = Counter('http_requests_total', 'Total HTTP Requests')

def process_request():
    REQUESTS.inc()

if __name__ == '__main__':
    # Start exporter server on port 8000
    start_http_server(8000)
    while True:
        process_request()
        time.sleep(1)

Advanced Usage

Set up gauge metrics, summary latency buckets, custom registry setups, and alerting rules configuration.

Key References

Dependencies

  • prometheus-client>=0.17.0

Lord1Egypt/ai-skillforge/tree/main/js/skills/gemini/prometheus-metrics commit ce149dee44

Frequently asked questions

npx skillmds@latest add lord1egypt/prometheus-metrics-2