Guides
Beginners के लिए Prometheus और Grafana कैसे सेटअप करें
By Ravindra Bagale, DevOps trainer · LinkedIn · Published: · Last updated:
Prometheus scrape → Targets UP → Grafana datasource → PromQL panel → save.
Friends, Prometheus pulls numbers; Grafana draws them. Chala mitrano — get Targets UP before you decorate dashboards.
मित्रांनो, Prometheus संख्या ओढते; Grafana काढते. Chala mitrano — Targets UP झाल्याशिवाय dashboard नका.
मित्रों, Prometheus संख्या खींचता है; Grafana बनाता है। Chala mitrano — Targets UP होने से पहले dashboard नहीं।
Quick answer
Hold this vertical picture:
- prometheus.yml.
- run; Targets.
- Grafana DS.
- PromQL panel.
- save; rate().
Language: English · मराठी · हिंदी
Prom + Grafana
Prom+Grafana क्यों
metrics रखो+देखो.
Why: SSH top scale नहीं.
What: scrape + graph.
How: self-scrape → exporters.
Example 1: Prometheus config scrape sketch
Type this:
mkdir -p /tmp/prom && printf '%s\n' 'global:' ' scrape_interval: 15s' 'scrape_configs:' ' - job_name: "prometheus"' ' static_configs:' ' - targets: ["localhost:9090"]' > /tmp/prom/prometheus.yml && cat /tmp/prom/prometheus.yml
You will see:
What it means: Prometheus scrapes targets on an interval — self-scrape first.
Example 2: Run Prometheus (compose-style idea)
Type this:
printf '%s\n' 'docker run --rm -p 9090:9090 -v /tmp/prom/prometheus.yml:/etc/prometheus/prometheus.yml public.ecr.aws/bitnami/prometheus:latest'
You will see:
docker run --rm -p 9090:9090 -v /tmp/prom/prometheus.yml:/etc/prometheus/prometheus.yml public.ecr.aws/bitnami/prometheus:latest
What it means: Lab path; production uses HA and persistent storage.
Example 7: Targets page check
Type this:
printf '%s\n' 'Open Prometheus UI → Status → Targets — State should be UP'
You will see:
Open Prometheus UI → Status → Targets — State should be UP
What it means: DOWN means scrape failed (network, path, or auth).
Concept 1: Scrape/query
jobs/targets/PromQL.
Why: DOWN = खाली.
What: UP; up{}; rate().
How: node exporter.
Example 3: Query up metric
Type this:
printf '%s\n' 'up{job="prometheus"}'
You will see:
What it means: up==1 means the target answered the scrape.
Example 5: First panel PromQL
Type this:
printf '%s\n' 'rate(process_cpu_seconds_total[1m])'
You will see:
rate(process_cpu_seconds_total[1m])
What it means: rate() turns counters into a per-second view for graphs.
Example 8: Add a node exporter job
Type this:
printf '%s\n' ' - job_name: "node"' ' static_configs:' ' - targets: ["node-exporter:9100"]' >> /tmp/prom/prometheus.yml && tail -4 /tmp/prom/prometheus.yml
You will see:
What it means: Exporters expose metrics Prometheus understands.
Concept 2: Panels
DS → Explore → save.
Why: unsaved जाता है.
What: URL; Explore; Save.
How: नाम साफ़.
Example 4: Grafana datasource JSON sketch
Type this:
printf '%s\n' '{' ' "name": "Prometheus",' ' "type": "prometheus",' ' "url": "http://prometheus:9090",' ' "access": "proxy"' '}' > /tmp/prom/ds.json && cat /tmp/prom/ds.json
You will see:
What it means: Grafana reads Prometheus over HTTP as a data source.
Example 6: Save dashboard reminder
Type this:
printf '%s\n' 'Save the dashboard with a clear name: App CPU — Payments'
You will see:
Save the dashboard with a clear name: App CPU — Payments
What it means: Unsaved panels vanish on refresh — Infosys demos warn about this.
Example 10: Grafana Explore
Type this:
printf '%s\n' 'Grafana → Explore → pick Prometheus → run PromQL → see graph'
You will see:
Grafana → Explore → pick Prometheus → run PromQL → see graph
What it means: Explore before you build a full dashboard.
Concept 3: Ops
reload, retention, pull.
Why: अंधा restart.
What: lifecycle; retention.
How: pull vs push.
Example 9: Reload config
Type this:
printf '%s\n' 'curl -X POST http://127.0.0.1:9090/-/reload'
You will see:
curl -X POST http://127.0.0.1:9090/-/reload
What it means: Requires --web.enable-lifecycle; else restart the process.
Example 11: Retention note
Type this:
printf '%s\n' 'Local Prometheus keeps short retention; long-term needs Thanos/Mimir later'
You will see:
Local Prometheus keeps short retention; long-term needs Thanos/Mimir later
What it means: Beginners start local; companies add long-term storage.
Example 12: Interview line
Type this:
printf '%s\n' 'Prometheus pulls (scrapes); many older tools push — that is the mental model'
You will see:
Prometheus pulls (scrapes); many older tools push — that is the mental model
What it means: TCS interviews open with pull vs push.
Prom/Grafana card
1 yml 2 Targets UP 3 DS 4 panel 5 save
Suppose: DOWN
network/path.
Suppose: empty
rate()/range.
Ravindra Bagale's Tip
At Flipkart-style on-call, the first panel is often request rate and error rate, not pretty CPU alone. Reviewers ask for rate() on counters.
Flipkart-style on-call मध्ये पहिला panel request/error rate. Reviewers counters वर rate() विचारतात.
Flipkart-style on-call में पहला panel request/error rate। Reviewers counters पर rate() पूछते हैं।
Check yourself (quiz)
Q1. data?
scrape pull
Q2. health?
Targets UP
Q3. Grafana?
datasource
Q4. counters?
rate()
Q5. empty?
query/target
Q6. long retain?
Thanos later
Reading tracking
Mark this guide when you finish. Your browser remembers it on this device.
scrape → UP → datasource → panel → save.
Did you understand? Let us try it once more.
Frequently asked questions
Pull vs push?
Prometheus scrapes targets by default.
What is an exporter?
A small process that exposes /metrics.
Why rate()?
Counters only go up; rate makes a graphable per-second.
HA Prometheus?
Advanced — start single then learn.
Grafana without Prometheus?
Other datasources exist; this guide focuses Prom.
Security?
Do not expose UIs publicly without auth.