Metric Collection Methods
What you'll learn: How metrics travel from your systems to your monitoring platform — and which approach fits which scenario.
Two Ways to Gather Metrics
When collecting metrics in cloud environments, you have two fundamental approaches: push and pull.
Push Model
In the push model, your application or infrastructure actively sends metrics to a central monitoring system. Think of it like mailing a letter — you walk to the mailbox and drop it in.
When to use push:
- Short-lived processes (containers, serverless functions) that may disappear before being polled
- Firewalled environments where the monitoring system can't reach your services
- High-volume metrics where you want to control when and how often data is sent
- Cloud services that generate metrics independently (like AWS CloudWatch receiving metrics from Lambda)
Example flow: Your application uses a library to send a counter increment to your monitoring endpoint every time a user logs in.
Pull Model
In the pull model, your monitoring system periodically connects to your services and scrapes metrics from an exposed endpoint. Like a mail carrier collecting letters from your mailbox.
When to use pull:
- Long-running services with predictable lifespans
- When you want centralized control over collection frequency
- Environments where your monitoring system can reach all targets
- When you need the monitoring system to detect if services are down (failed scrapes = alerts)
Example flow: Your monitoring system contacts http://your-app:9090/metrics every 30 seconds to retrieve current metric values.
Choosing Your Approach
In cloud environments, hybrid approaches are common. Push for ephemeral workloads (Lambda, batch jobs), pull for stable infrastructure (EC2, Kubernetes pods).
Key Takeaway: Push models work best for short-lived or isolated workloads, while pull models suit stable, reachable services — cloud monitoring often uses both simultaneously.