Menu

macOS integration for Grafana Cloud

The macOS integration uses the agent 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 the agent using promtail. An accompanying dashboard is provided to visualize these metrics and logs.

Install macOS integration for Grafana Cloud

  1. In your Grafana instance, Click Integrations and Connections (lightning bolt icon), then click on install integration on macOS tile.
  2. Wait for the integration to be installed and then follow the steps shown to setup Grafana Agent to automatically scrape and send macOS metrics to your Cloud Instance.

Post-install configuration for the macOS integration

This integration supports metrics and logs from macOS. In order to see logs and metrics signals correlated on the same dashboard, you need to make sure that job and instance labels match in the node_exporter integration config and under logs. The job label should be set to integrations/macos-node. The following preferred agent configuration example includes logs collected.

Note: You must replace placeholder ‘<this_mac_hostname>’ with the appropriate hostname for your configuration needs:

integrations:
  prometheus_remote_write:
    - url: http://cortex:9009/api/prom/push
  node_exporter:
    enabled: true
    relabel_configs:
    - replacement: <this_mac_hostname>
      source_labels: [agent_hostname]
      target_label: instance
    - replacement: "integrations/macos-node"
      source_labels: [agent_hostname]
      target_label: job

logs:
  configs:
  - name: integrations
    clients:
    - url: http://loki:3100/loki/api/v1/push
    positions:
      filename: /tmp/positions.yaml
    target_config:
      sync_period: 10s
    scrape_configs:
    - job_name: integrations/node_exporter_direct_scrape
      static_configs:
      - targets:
        - localhost
        labels:
          instance: <this_mac_hostname>
          __path__: /var/log/*.log
          job: integrations/macos-node
      pipeline_stages:
      - multiline:
          firstline: '^([\w]{3} )?[\w]{3} +[\d]+ [\d]+:[\d]+:[\d]+|[\w]{4}-[\w]{2}-[\w]{2} [\w]{2}:[\w]{2}:[\w]{2}(?:[+-][\w]{2})?'
      - 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:.*))$'
      - labels:
          sender:
          hostname:
          pid:
      - match:
          selector: '{sender!="", pid!=""}'
          stages:
            - template:
                source: message
                template: '{{.sender }}[{{.pid}}]: {{ .message }}'
            - labeldrop:
                - pid
            - output:
                source: message

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

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 node_exporter integration to disable it:

    disable_collectors:
      - thermal # disable on M1

Dashboards

This integration includes the following dashboards.

  • Node Exporter / MacOS

MacOS overview

image

MacOS logs

image

Metrics

Below is a list of the metrics used on the dashboards and in alerts of the integration and are automatically written to your Grafana Cloud instance.

  • node_cpu_seconds_total
  • node_disk_io_time_seconds_total
  • node_disk_io_time_weighted_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_Buffers_bytes
  • node_memory_Cached_bytes
  • node_memory_MemAvailable_bytes
  • node_memory_MemFree_bytes
  • node_memory_MemTotal_bytes
  • node_memory_Slab_bytes
  • node_memory_compressed_bytes
  • node_memory_internal_bytes
  • node_memory_purgeable_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_textfile_scrape_error
  • node_uname_info
  • node_vmstat_pgmajfault

Alerts

The integration also comes packaged with a number of handy alerts.

Group: node-exporter

AlertDescription
NodeFilesystemAlmostOutOfSpaceWarning: Filesystem has less than 5% space left.
NodeFilesystemAlmostOutOfSpaceCritical: Filesystem has less than 3% space left.
NodeFilesystemFilesFillingUpWarning: Filesystem is predicted to run out of inodes within the next 24 hours.
NodeFilesystemFilesFillingUpCritical: Filesystem is predicted to run out of inodes within the next 4 hours.
NodeFilesystemAlmostOutOfFilesWarning: Filesystem has less than 5% inodes left.
NodeFilesystemAlmostOutOfFilesCritical: Filesystem has less than 3% inodes left.
NodeNetworkReceiveErrsWarning: Network interface is reporting many receive errors.
NodeNetworkTransmitErrsWarning: Network interface is reporting many transmit errors.
NodeTextFileCollectorScrapeErrorWarning: Node Exporter text file collector failed to scrape.

Changelog

# 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 and Cloud tier pricing.