Grafana: Ingest MacOS data

I have installed and tested this on Monterey Beta 12.3 & Catalina 10.15.7. The default configuration only shows: CPU Usage, Load Average and Network Traffic. I am sure there is a way to extend this, but I will post that later when I have time.

Install and configure node_exporter

# Install node_exporter
$ brew install node_exporter

# Start node_exporter and make it persistent
$ sudo cp -n homebrew.mxcl.node_exporter.plist /Library/LaunchDaemons/
$ sudo launchctl bootstrap system/ /Library/LaunchDaemons/homebrew.mxcl.node_exporter.plist

# Check it's running
sudo launchctl list | grep node_exporter

# See full process state
sudo launchctl print system/homebrew.mxcl.node_exporter

# View logs
sudo tail /usr/local/var/log/node_exporter.err.log

Configure Firewall to allow connections

  1. Open System Preferences
  2. Go to Security & Privacy
  3. Click on Firewall and locate node_exporter. You should see it blocked per image below
  1. Click on node_exporter and Allow Incoming Connections

Configure Prometheus on your Grafana server

Next, we are going to add the MacOS server in Prometheus and restart

  1. vi /etc/prometheus/prometheus.yml
# Global config
global:
  scrape_interval:     15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. 
  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. 
  scrape_timeout: 15s  # scrape_timeout is set to the global default (10s).
# A scrape configuration containing exactly one endpoint to scrape:# Here it's Prometheus itself.
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
scrape_configs:
  - job_name: 'prometheus'
    static_configs:
    - targets: ['localhost:9090']
  - job_name: 'node_exporter'
    static_configs:
    - targets: ['localhost:9100']
# Macs
  - job_name: macsrv
    static_configs:
      - targets: ['10.0.1.164:9100']
        labels:
          alias: macsrv
  - job_name: formula2
    static_configs:
      - targets: ['10.0.1.155:9100']
        labels:
          alias: formula2
  1. Restart Prometheus
    1. sudo systemctl restart prometheus
    2. sudo systemctl status prometheus
● prometheus.service - Prometheus Time Series Collection and Processing Server
Loaded: loaded (/etc/systemd/system/prometheus.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2022-03-10 07:57:29 EST; 2h 11min ago
Main PID: 54216 (prometheus)
Tasks: 10 (limit: 48277)
Memory: 168.3M
CGroup: /system.slice/prometheus.service
└─54216 /usr/local/bin/prometheus --config.file=/etc/prometheus/prometheus.yml --storage.tsdb.path

Verify Data is being sent to Grafana

The easiest way is to check your dashboard. Refer here for adding servers to Prometheus: Grafana Linux Install

  1. Login into your Grafana via your browser and go to your dashboard.
  2. Above in the “host” dropdown you will see a list of hosts. You should see your new host if you added it and restart Prometheus.
Advertisement