How to Add Extra Scrape Configuration for Prometheus

After some recent updating to my home server running Ubuntu Server 20.04, the InfluxDB server suddenly stopped working. I’ve used InfluxDB + Telegraf for many years, the combination worked very well without much maintenance. But as I have deployed some new-ish stuff – Prometheus, Loki, etc. in my garage Kubernetes lab, I think it’s time to let Prometheus take the place.

The Prometheus server in Loki stack is from its community Helm charts. It worked amazingly out-of-box and monitors the cluster very well. However my home server is just a bare-metal server outside of the cluster and can’t be auto-discovered by Prometheus.

I did a bit of reading so there are 2 steps needed to get Prometheus to scrape metrics.

1, installation of prometheus-node-exporter

This in a Ubuntu Server is as easy as

apt install prometheus-node-exporter

# verify if it's running
systemctl status promtheus-node-exporter

2, add a new scrape configuration for the server

This can be done in Helm values file, like:

# this goes in same level as the `server` section
extraScrapeConfigs: |
  - job_name: host_home_server
      - targets:
        - <server-ip>:9100

For more info on the values file please see here.