---
title: "macOS integration | Grafana Cloud documentation"
description: "Learn about macOS Grafana Cloud integration."
---

> For a curated documentation index, see [llms.txt](/llms.txt). For the complete documentation index, see [llms-full.txt](/llms-full.txt).

# macOS integration for Grafana Cloud

The macOS integration uses Grafana Alloy to collect metrics related to the operating system, including aspects like CPU usage, load average, memory usage, and disk and networking I/O. It also supports system logs being scraped by Alloy using promtail. An accompanying dashboard is provided to visualize these metrics and logs.

The macOS integration is based on macOS mixin, which is in fact slightly modified [node-observ-lib](https://github.com/grafana/node_exporter/tree/master/docs/node-mixin/lib/macos).

This integration includes 9 useful alerts and 2 pre-built dashboards to help monitor and visualize macOS metrics and logs.

## Before you begin

This integration running MacOS machine running alongside Grafana Alloy.

Each MacOS node being observed must have a dedicated Grafana Alloy running.

## Install macOS integration for Grafana Cloud

1. In your Grafana Cloud stack, click **Connections** in the left-hand menu.
2. Find **macOS** and click its tile to open the integration.
3. Review the prerequisites in the **Configuration Details** tab and set up Grafana Alloy to send macOS metrics and logs to your Grafana Cloud instance.
4. Click **Install** to add this integration’s pre-built dashboards and alerts to your Grafana Cloud instance, and you can start monitoring your macOS setup.

## Configuration snippets for Grafana Alloy

### Simple mode

These snippets are configured to scrape a single macOS instance running locally with default ports.

First, **manually** copy and append the following snippets into your alloy configuration file.

### Integrations snippets

Alloy ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```alloy
prometheus.exporter.unix "integrations_node_exporter" { }

discovery.relabel "integrations_node_exporter" {
	targets = prometheus.exporter.unix.integrations_node_exporter.targets

	rule {
		target_label = "instance"
		replacement  = constants.hostname
	}

	rule {
		target_label = "job"
		replacement  = "integrations/macos-node"
	}
}

prometheus.scrape "integrations_node_exporter" {
	targets    = discovery.relabel.integrations_node_exporter.output
	forward_to = [prometheus.remote_write.metrics_service.receiver]
	job_name   = "integrations/node_exporter"
}
```

### Logs snippets

#### darwin

Alloy ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```alloy
local.file_match "logs_integrations_integrations_node_exporter_direct_scrape" {
	path_targets = [{
		__address__ = "localhost",
		__path__    = "/var/log/*.log",
		instance    = constants.hostname,
		job         = "integrations/macos-node",
	}]
}

loki.process "logs_integrations_integrations_node_exporter_direct_scrape" {
	forward_to = [loki.write.grafana_cloud_loki.receiver]

	stage.multiline {
		firstline     = "^([\\w]{3} )?[\\w]{3} +[\\d]+ [\\d]+:[\\d]+:[\\d]+|[\\w]{4}-[\\w]{2}-[\\w]{2} [\\w]{2}:[\\w]{2}:[\\w]{2}(?:[+-][\\w]{2})?"
		max_lines     = 0
		max_wait_time = "10s"
	}

	stage.regex {
		expression = "(?P<timestamp>([\\w]{3} )?[\\w]{3} +[\\d]+ [\\d]+:[\\d]+:[\\d]+|[\\w]{4}-[\\w]{2}-[\\w]{2} [\\w]{2}:[\\w]{2}:[\\w]{2}(?:[+-][\\w]{2})?) (?P<hostname>\\S+) (?P<sender>.+?)\\[(?P<pid>\\d+)\\]:? (?P<message>(?s:.*))$"
	}

	stage.labels {
		values = {
			hostname = null,
			pid      = null,
			sender   = null,
		}
	}

	stage.match {
		selector = "{sender!=\"\", pid!=\"\"}"

		stage.template {
			source   = "message"
			template = "{{ .sender }}[{{ .pid }}]: {{ .message }}"
		}

		stage.label_drop {
			values = ["pid"]
		}

		stage.output {
			source = "message"
		}
	}
}

loki.source.file "logs_integrations_integrations_node_exporter_direct_scrape" {
	targets    = local.file_match.logs_integrations_integrations_node_exporter_direct_scrape.targets
	forward_to = [loki.process.logs_integrations_integrations_node_exporter_direct_scrape.receiver]
}
```

### Advanced mode

The following snippets provide examples to guide you through the configuration process.

To instruct Grafana Alloy to scrape your macOS instances, **manually** copy and append the snippets to your alloy configuration file, then follow subsequent instructions.

### Advanced integrations snippets

Alloy ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```alloy
prometheus.exporter.unix "integrations_node_exporter" { }

discovery.relabel "integrations_node_exporter" {
	targets = prometheus.exporter.unix.integrations_node_exporter.targets

	rule {
		target_label = "instance"
		replacement  = constants.hostname
	}

	rule {
		target_label = "job"
		replacement  = "integrations/macos-node"
	}
}

prometheus.scrape "integrations_node_exporter" {
	targets    = discovery.relabel.integrations_node_exporter.output
	forward_to = [prometheus.remote_write.metrics_service.receiver]
	job_name   = "integrations/node_exporter"
}
```

This integrations uses the [prometheus.exporter.unix](/docs/alloy/latest/reference/components/prometheus.exporter.unix/) component to generate metrics from a macOS instance.

For the full array of configuration options, refer to the [prometheus.exporter.unix](/docs/alloy/latest/reference/components/prometheus.exporter.unix/) component reference documentation.

This exporter must be linked with a [discovery.relabel](/docs/alloy/latest/reference/components/discovery.relabel/) component to apply the necessary relabelings.

For each macOS instance to be monitored you must create a pair of these components.

Configure the following properties within each `discovery.relabel` component:

- `instance` label: `constants.hostname` sets the `instance` label to your Grafana Alloy server hostname. If that is not suitable, change it to a value uniquely identifies this macOS instance. Make sure this label value is the same for all telemetry data collected for this instance.

You can then scrape them by including each `discovery.relabel` under `targets` within the [prometheus.scrape](/docs/alloy/latest/reference/components/prometheus.scrape/) component.

Note that on Macs with an M1 architecture you might encounter errors similar to the following:

![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```none
level=error integration=node_exporter msg="collector failed" name=thermal duration_seconds=0.001089125 err="no CPU power status has been recorded"
```

To avoid collector errors, you can add `disable_collectors` setting to the `prometheus.exporter.unix` component to disable it:

Alloy ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```alloy
    disable_collectors = ["thermal"]
```

### Advanced logs snippets

#### darwin

Alloy ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```alloy
local.file_match "logs_integrations_integrations_node_exporter_direct_scrape" {
	path_targets = [{
		__address__ = "localhost",
		__path__    = "/var/log/*.log",
		instance    = constants.hostname,
		job         = "integrations/macos-node",
	}]
}

loki.process "logs_integrations_integrations_node_exporter_direct_scrape" {
	forward_to = [loki.write.grafana_cloud_loki.receiver]

	stage.multiline {
		firstline     = "^([\\w]{3} )?[\\w]{3} +[\\d]+ [\\d]+:[\\d]+:[\\d]+|[\\w]{4}-[\\w]{2}-[\\w]{2} [\\w]{2}:[\\w]{2}:[\\w]{2}(?:[+-][\\w]{2})?"
		max_lines     = 0
		max_wait_time = "10s"
	}

	stage.regex {
		expression = "(?P<timestamp>([\\w]{3} )?[\\w]{3} +[\\d]+ [\\d]+:[\\d]+:[\\d]+|[\\w]{4}-[\\w]{2}-[\\w]{2} [\\w]{2}:[\\w]{2}:[\\w]{2}(?:[+-][\\w]{2})?) (?P<hostname>\\S+) (?P<sender>.+?)\\[(?P<pid>\\d+)\\]:? (?P<message>(?s:.*))$"
	}

	stage.labels {
		values = {
			hostname = null,
			pid      = null,
			sender   = null,
		}
	}

	stage.match {
		selector = "{sender!=\"\", pid!=\"\"}"

		stage.template {
			source   = "message"
			template = "{{ .sender }}[{{ .pid }}]: {{ .message }}"
		}

		stage.label_drop {
			values = ["pid"]
		}

		stage.output {
			source = "message"
		}
	}
}

loki.source.file "logs_integrations_integrations_node_exporter_direct_scrape" {
	targets    = local.file_match.logs_integrations_integrations_node_exporter_direct_scrape.targets
	forward_to = [loki.process.logs_integrations_integrations_node_exporter_direct_scrape.receiver]
}
```

To monitor your macOS instance logs, you will use a combination of the following components:

- [local.file\_match](/docs/alloy/latest/reference/components/local.file_match) defines where to find the log file to be scraped. Change the following properties according to your environment:
  
  - `__address__`: The macOS instance address
  - `__path__`: The path to the log file.
  - `instance` label: `constants.hostname` sets the `instance` label to your Grafana Alloy server hostname. If that is not suitable, change it to a value uniquely identifies this macOS instance. Make sure this label value is the same for all telemetry data collected for this instance.
- [loki.process](/docs/alloy/latest/reference/components/loki.process) defines how to process logs before sending it to Loki.
- [loki.source.file](/docs/alloy/latest/reference/components/loki.source.file) sends logs to Loki.

## Dashboards

The macOS integration installs the following dashboards in your Grafana Cloud instance to help monitor your system.

- MacOS / logs
- MacOS / overview

**MacOS overview**

**MacOS logs**

## Alerts

The macOS integration includes the following useful alerts:

**darwin-filesystem-alerts**

Expand table

| Alert                          | Description                                                                     |
|--------------------------------|---------------------------------------------------------------------------------|
| NodeFilesystemAlmostOutOfSpace | Warning: Filesystem has less than 5% space left.                                |
| NodeFilesystemAlmostOutOfSpace | Critical: Filesystem has less than 3% space left.                               |
| NodeFilesystemFilesFillingUp   | Warning: Filesystem is predicted to run out of inodes within the next 24 hours. |
| NodeFilesystemFilesFillingUp   | Critical: Filesystem is predicted to run out of inodes within the next 4 hours. |
| NodeFilesystemAlmostOutOfFiles | Warning: Filesystem has less than 5% inodes left.                               |
| NodeFilesystemAlmostOutOfFiles | Critical: Filesystem has less than 3% inodes left.                              |

**darwin-alerts**

Expand table

| Alert                            | Description                                                   |
|----------------------------------|---------------------------------------------------------------|
| NodeNetworkReceiveErrs           | Warning: Network interface is reporting many receive errors.  |
| NodeNetworkTransmitErrs          | Warning: Network interface is reporting many transmit errors. |
| NodeTextFileCollectorScrapeError | Warning: Node Exporter text file collector failed to scrape.  |

## Metrics

The most important metrics provided by the macOS integration, which are used on the pre-built dashboards and Prometheus alerts, are as follows:

- node\_boot\_time\_seconds
- node\_cpu\_seconds\_total
- node\_disk\_io\_time\_seconds\_total
- node\_disk\_read\_bytes\_total
- node\_disk\_written\_bytes\_total
- node\_filesystem\_avail\_bytes
- node\_filesystem\_files
- node\_filesystem\_files\_free
- node\_filesystem\_readonly
- node\_filesystem\_size\_bytes
- node\_load1
- node\_load15
- node\_load5
- node\_memory\_compressed\_bytes
- node\_memory\_internal\_bytes
- node\_memory\_purgeable\_bytes
- node\_memory\_swap\_total\_bytes
- node\_memory\_swap\_used\_bytes
- node\_memory\_total\_bytes
- node\_memory\_wired\_bytes
- node\_network\_receive\_bytes\_total
- node\_network\_receive\_drop\_total
- node\_network\_receive\_errs\_total
- node\_network\_receive\_packets\_total
- node\_network\_transmit\_bytes\_total
- node\_network\_transmit\_drop\_total
- node\_network\_transmit\_errs\_total
- node\_network\_transmit\_packets\_total
- node\_os\_info
- node\_textfile\_scrape\_error
- node\_uname\_info
- up

## Changelog

md ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```md
# 1.0.2 - November 2024

* Update Log dashboard job selector to always have a selected option

# 1.0.1 - November 2024

* Update status panel check queries

# 1.0.0 - December 2023

* Sync dashboards styles with Linux/Windows
* Change dashboards prefix to 'MacOS /'
* Add inventory row
* Add reboot annotation
* Add separate dashboards for logs with sender/filename selectors

# 0.0.10 - August 2023

* New Filter Metrics option for configuring the Grafana Agent, which saves on metrics cost by dropping any metric not used by this integration. Beware that anything custom built using metrics that are not on the snippet will stop working.

# 0.0.9 - August 2023

* Add regex filter for logs datasource

# 0.0.8 - July 2023

* Update agent snippets

# 0.0.7 - January 2023

* Status panels fixes
	- Update status panel query to return only single series
	- Resolve status panels not opening when clicking view button
* Update node mixin to latest version

# 0.0.6 - November 2022

* Add integration status panel

# 0.0.5 - September 2022

* Update dashboard panels descriptions.

# 0.0.4 - May 2022

* Reverse fsSpaceAvailableCriticalThreshold and fsSpaceAvailableWarningThreshold
* Update units for disk and networking panels

# 0.0.3 - May 2022

* Use $(hostname) in the generated agent config to avoid manual snippet editing

# 0.0.2 - May 2022

* Update timestamp parsing in logs

# 0.0.1 - May 2022

* Initial release
```

## Cost

By connecting your macOS instance to Grafana Cloud, you might incur charges. To view information on the number of active series that your Grafana Cloud account uses for metrics included in each Cloud tier, see [Active series and dpm usage](/docs/grafana-cloud/fundamentals/active-series-and-dpm/) and [Cloud tier pricing](/products/cloud/pricing/).
