Back to Blog
team@tinypod.app

Self-Hosting Prometheus: Metrics Collection for Everything

Prometheus scrapes and stores metrics from your apps and infrastructure. The foundation of modern monitoring stacks.

prometheusmonitoringmetricsobservability

What Is Prometheus?


Prometheus is a time-series database designed for monitoring. It scrapes metrics from targets at regular intervals, stores them, and lets you query and alert on them.


How It Works


Pull Model

Prometheus pulls metrics from your applications. Each app exposes a /metrics endpoint. Prometheus scrapes it every 15 seconds.


This is different from push-based systems where apps send metrics to a collector.


Metrics Format

Plain text, human-readable:

http_requests_total{method="GET", status="200"} 12345

http_request_duration_seconds{quantile="0.95"} 0.25

process_cpu_seconds_total 456.78


PromQL

Prometheus's query language:

  • rate(http_requests_total[5m]): Requests per second over 5 minutes
  • histogram_quantile(0.95, rate(http_request_duration_seconds_bucket[5m])): 95th percentile latency
  • node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes: Memory usage percentage

  • What to Monitor


    Node Exporter (Server Metrics)

  • CPU, memory, disk, network usage
  • Filesystem space and inodes
  • System load

  • cAdvisor (Container Metrics)

  • Per-container CPU and memory
  • Container restarts
  • Network I/O per container

  • Application Metrics

    Most frameworks have Prometheus client libraries:

  • Node.js: prom-client
  • Python: prometheus_client
  • Go: prometheus/client_golang
  • Java: micrometer

  • Database Metrics

  • PostgreSQL: postgres_exporter
  • MySQL: mysqld_exporter
  • Redis: redis_exporter

  • Alerting


    Prometheus includes Alertmanager for alerting on metrics:


  • alert: HighCPU
  • expr: node_cpu_seconds_total > 0.8

    for: 5m

    labels:

    severity: warning

    annotations:

    summary: CPU usage above 80% for 5 minutes


    Alertmanager routes alerts to Slack, email, PagerDuty, etc.


    Deployment


    1. Deploy Prometheus on TinyPod

    2. Configure scrape targets (node_exporter, cAdvisor, app metrics)

    3. Connect Grafana to Prometheus

    4. Import dashboards

    5. Set up alerting rules


    Resources: 1 CPU, 1 GB RAM for small setups. Scales with number of metrics.


    Retention


    Default: 15 days. For long-term storage, use Thanos or VictoriaMetrics as a Prometheus backend.