Prometheus and Grafana
Prometheus and Grafana
📈 Scalability: Both tools are highly scalable, suitable for small setups
creating a unified monitoring and alerting solution.
●
and enterprise-level deployments.
—---------------------------------------------------------------------------------------------------------
—---------------------------------------------------------------------------------------------------------
scrape_interval: 5s
scrape_configs:
- job_name: 'docker-target'
static_configs:
- targets: ['vulnerable-app:8080']
👉 Explanation:
● scrape_interval: Defines how frequently Prometheus collects metrics
(5 seconds here).
● static_configs: Specifies the endpoint (vulnerable-app:8080)
where metrics will be scraped.
--network=monitoring-net \
-p 9090:9090 \
-v $(pwd)/prometheus.yml:/etc/prometheus/prometheus.yml \
prom/prometheus
👉 What’s Happening?
● --network=monitoring-net: Connects Prometheus to the
monitoring-net network.
● -v: Mounts the configuration file to Prometheus’ configuration directory.
● -p 9090:9090: Exposes Prometheus on port 9090.
--name=grafana \
--network=monitoring-net \
-p 3000:3000 \
grafana/grafana
👉 What’s Happening?
● This starts Grafana and connects it to the same Docker network as
Prometheus.
● Grafana is accessible at http://localhost:3000.
Step 4: Deploy a Vulnerable Application 🐞
Let’s deploy a vulnerable container (e.g., vulnweb) for monitoring:
docker run -d \
--name=vulnerable-app \
--network=monitoring-net \
-p 8080:8080 \
vulnerables/web-dvwa
👉 What’s Happening?
● This starts the Damn Vulnerable Web Application (DVWA) on port 8080.
● The container is added to the monitoring-net network, making it
accessible to Prometheus.
1. Login to Grafana:
○ Open http://localhost:3000 in your browser.
○ Default credentials:
■ Username: admin
■ Password: admin.
2. Add Prometheus as a Data Source:
○ Navigate to Configuration > Data Sources in Grafana.
○ Select Prometheus from the list.
○ Provide the Prometheus URL (e.g., http://prometheus:9090).
2. Define Alerts:
👉 What’s Happening?
● Alerts monitor container behavior for unusual patterns or excessive
requests, which could indicate exploitation attempts.
Conclusion
🚀
risks. Use this setup to explore further metrics or secure vulnerabilities in your
applications.