The official Python client for Prometheus monitoring system.
pip install prometheus-clientThis package is available on PyPI.
from prometheus_client import start_http_server, Counter
import time
# Create a metric to track request count
REQUESTS = Counter('hello_requests_total', 'Total HTTP requests.')
if __name__ == '__main__':
# Start up the server to expose the metrics.
start_http_server(8000)
print("Metrics server started at http://localhost:8000/metrics")
# Generate some metric activity.
while True:
REQUESTS.inc()
time.sleep(1)This repository includes enterprise-grade DevOps automation, containerization, and monitoring assets:
Launch a complete local sandbox with the instrumented app, Prometheus, Grafana, and Alertmanager:
make compose-up- App & Metrics: http://localhost:8000/metrics
- Prometheus UI: http://localhost:9090
- Grafana Dashboard: http://localhost:3000 (
admin/admin) - Alertmanager UI: http://localhost:9093
Deploy the instrumented microservice to Kubernetes with built-in ServiceMonitor CRD support:
helm upgrade --install prometheus-python-app ./charts/prometheus-python-app \
--namespace monitoring-apps \
--create-namespaceRefer to DEVOPS.md for:
- End-to-end CI/CD architecture diagrams
- Multi-stage hardened Docker containerization guidelines
- Multiprocess mode in-memory tmpfs configuration
- Operational runbooks for incident response (
TargetDown,HighErrorRate,HighLatencyP99,ProcessHighMemoryUsage)
- Documentation: https://prometheus.github.io/client_python
- Releases & Changelog: GitHub Releases
- PyPI: https://pypi.org/project/prometheus-client
- DevOps Guide: DEVOPS.md