DEV Community

Alex Spinov
Alex Spinov

Posted on

Prometheus Has a Free Monitoring System With a Powerful Query Language

Prometheus is the CNCF graduated monitoring system. It collects metrics via pull model, stores them in a time-series database, and provides PromQL for powerful queries.

What You Get for Free

  • Pull-based collection — scrapes targets automatically
  • PromQL — powerful query language
  • Alertmanager — routing, silencing, grouping
  • Service discovery — Kubernetes, Consul, DNS, file
  • Client libraries — Go, Java, Python, Ruby, .NET
  • Federation — hierarchical metric collection
  • Recording rules — pre-compute expensive queries

Quick Start

docker run -p 9090:9090 prom/prometheus
Enter fullscreen mode Exit fullscreen mode

prometheus.yml

scrape_configs:
  - job_name: 'my-app'
    static_configs:
      - targets: ['localhost:8080']
    scrape_interval: 15s
Enter fullscreen mode Exit fullscreen mode

PromQL Examples

# Request rate
rate(http_requests_total[5m])

# Error percentage
sum(rate(http_requests_total{status=~"5.."}[5m])) / sum(rate(http_requests_total[5m])) * 100

# Top 5 memory consumers
topk(5, container_memory_usage_bytes)
Enter fullscreen mode Exit fullscreen mode

Prometheus vs Datadog

Feature Prometheus Datadog
Price Free (OSS) $15/host/mo
Query PromQL Proprietary
Storage Local/remote Cloud
Self-hosted Yes No

Need monitoring setup? Check my work on GitHub or email spinov001@gmail.com for consulting.

Top comments (0)