🚀 Setting Up Prometheus Monitoring for Portfolio
🧐 Step 1: Edit Prometheus Configuration
Open the Prometheus configuration file using nano
:
sudo nano /etc/prometheus/prometheus.yml
Add the following job configuration at the end of the scrape_configs
section:
scrape_configs:
- job_name: portfolio
static_configs:
- targets: ['13.201.191.75:9100']
relabel_configs:
- source_labels: [__address__]
regex: '.*'
target_label: instance
replacement: 'Prod: Portfolio'
📝 Explanation:
job_name: portfolio
→ Defines a new scrape job for monitoring.static_configs
→ Specifies the target server to monitor (13.201.191.75:9100
).relabel_configs
→ Changes the instance label from the default IP format toProd: Portfolio
for better readability in Grafana.
🔍 Step 2: Install yamllint
(YAML Linter)
YAML files are indentation-sensitive. Install yamllint
to check the syntax:
sudo apt install yamllint -y
After installation, run:
yamllint /etc/prometheus/prometheus.yml
If there are any errors, fix them before proceeding.
🔄 Step 3: Restart Prometheus
After making changes, restart Prometheus to apply them:
sudo systemctl restart prometheus
Check if Prometheus is running correctly:
sudo systemctl status prometheus
✔️ If everything is correct, you should see active (running)
in green.
🎯 Final Notes:
- Always validate YAML syntax using
yamllint
before restarting Prometheus. - Ensure port
9100
is accessible from the Prometheus server. - Monitor logs using:
journalctl -u prometheus -f --no-pager
- Check your Prometheus targets here: http://15.207.86.27:9090/targets