Skip to content

Instantly share code, notes, and snippets.

@moisoto
Created July 28, 2026 19:37
Show Gist options
  • Select an option

  • Save moisoto/ddb264d515c82464cb57a3564921d7ee to your computer and use it in GitHub Desktop.

Select an option

Save moisoto/ddb264d515c82464cb57a3564921d7ee to your computer and use it in GitHub Desktop.
Setting Up Mactop + Prometheus + Grafana

Mactop + Prometheus + Grafana

This guide shows the steps needed to setup Mactop for use with Grafana using Prometheus as a data source.

About Mactop and Grafana

Mactop is a resource monitor tool for use on the terminal. You can use it like you would use tools like top, htop, btop, asitop, etc.

One of the "extra features" you get with MacTop is a built-in Prometheus exporter. This will let you use Mactop as a datasource for Prometheus.

Prometheus is a monitor system that is capable of collecting data (scraping) from several sources, and keeping it organized in a database. It then acts as query engine and alerting source for other software. In this case we want to use it as a query engine for Grafana.

Grafana is a powerfull dashboard platform. In this case we just want to create a dashboard that shows the information exported by Mactop and collected by Prometheus.

What follows is a description of such a basic setup.

Update and Upgrade brew

# Update brew package list
brew update

# Upgrade brew packages

Install mactop

# Check Package Info
brew info mactop

# Install mactop
brew install mactop

Install prometheus

# Check Package Info
brew info prometheus

# Install mactop
brew install prometheus

Install grafana

# Check Package Info
brew info grafana

# Install mactop
brew install grafana

Check and update Prometheus Config

To edit your Prometheus configuration file:

# Use vi or your favorite editor to modify prometheus.yml
vi $(brew --prefix)/etc/prometheus.yml

The file should look like:

global:
  scrape_interval: 5s

scrape_configs:
  - job_name: "prometheus"
    static_configs:
    - targets: ["localhost:9090"]

Add the following text to it:

  - job_name: "mactop"
    static_configs:
      - targets: ["localhost:9101"]

It should end up looking like this:

global:
  scrape_interval: 5s

scrape_configs:
  - job_name: "prometheus"
    static_configs:
    - targets: ["localhost:9090"]

  - job_name: "mactop"
    static_configs:
      - targets: ["localhost:9101"]

Starting Services with brew

To check brew services status:

# List brew services
brew services list

Start the services:

brew services start mactop
brew services start prometheus
brew services start grafana

Configure Grafana

You will need to access grafana using a browser. Open the following url: http://localhost:3000

You will be asked to provide an admin password. Take note of the password you used.

Adding a connection to Prometheus

Go to the Connections menu item and select Add new connection. This will normally take you to http://localhost:3000/connections/add-new-connection

Search for Prometheus and click on it (should show you a page for the Prometheus Native Plugin).

Click on the Add new data source button:

  • On the Prometheus URL field put http://localhost:9090
  • Click Save & Test

Adding a Mactop dashboard to grafana

Go to the Dashboard menu item:

You should now be able to access de Mactop dashboard in the dashboard menu.

Resetting Grafana Password

If you lose your Grafana password and need to reset use this:

# Stop service
brew services stop grafana

# Get --config and --homepad paths
brew info grafana
# Copy the paths shown and use them in the command below

# Change Password
grafana cli \
--config /opt/homebrew/etc/grafana/grafana.ini \
--homepath /opt/homebrew/opt/grafana/share/grafana \
admin reset-admin-password 'YourNewPassword'

# Start service again
brew services start grafana
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment