---
title: "Apache Spark integration | Grafana Cloud documentation"
description: "Learn about Apache Spark 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).

# Apache Spark integration for Grafana Cloud

Apache Spark™ is a multi-language engine for executing data engineering, data science, and machine learning on single-node machines or clusters.

This integration includes 1 pre-built dashboard to help monitor and visualize Apache Spark metrics.

## Before you begin

This integration monitors a Spark cluster based on the built-in prometheus plugin, available from version 3.0 upwards, which should be enabled following the [official documentation](https://spark.apache.org/docs/3.5.1/monitoring.html). [This tutorial](https://dzlab.github.io/bigdata/2020/07/03/spark3-monitoring-1/) by [dzlab](https://dzlab.github.io/) might be helpful as well.

## Install Apache Spark integration for Grafana Cloud

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

## Configuration snippets for Grafana Alloy

### Advanced mode

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

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

### Advanced metrics snippets

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

```alloy
discovery.relabel "metrics_integrations_integrations_spark_master" {
	targets = [{
		__address__ = "spark-master:8080",
	}]

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

	rule {
		target_label = "instance_type"
		replacement  = "master"
	}

	rule {
		target_label = "spark_cluster"
		replacement  = "<your-cluster-name>"
	}
}

discovery.relabel "metrics_integrations_integrations_spark_worker" {
	targets = [{
		__address__ = "spark-worker:8081",
	}]

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

	rule {
		target_label = "instance_type"
		replacement  = "worker"
	}

	rule {
		target_label = "spark_cluster"
		replacement  = "<your-cluster-name>"
	}
}

discovery.relabel "metrics_integrations_integrations_spark_driver" {
	targets = [{
		__address__ = "spark-driver:4040",
	}]

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

	rule {
		target_label = "instance_type"
		replacement  = "driver"
	}

	rule {
		target_label = "spark_cluster"
		replacement  = "<your-cluster-name>"
	}
}

prometheus.scrape "metrics_integrations_integrations_spark_master" {
	targets      = discovery.relabel.metrics_integrations_integrations_spark_master.output
	forward_to   = [prometheus.remote_write.metrics_service.receiver]
	job_name     = "integrations/spark-master"
	metrics_path = "/metrics/master/prometheus"
}

prometheus.scrape "metrics_integrations_integrations_spark_worker" {
	targets      = discovery.relabel.metrics_integrations_integrations_spark_worker.output
	forward_to   = [prometheus.remote_write.metrics_service.receiver]
	job_name     = "integrations/spark-worker"
	metrics_path = "/metrics/prometheus"
}

prometheus.scrape "metrics_integrations_integrations_spark_driver" {
	targets      = discovery.relabel.metrics_integrations_integrations_spark_driver.output
	forward_to   = [prometheus.remote_write.metrics_service.receiver]
	job_name     = "integrations/spark-driver"
	metrics_path = "/metrics/prometheus/"
}
```

To monitor your Apache Spark instance, you must use a [discovery.relabel](/docs/alloy/latest/reference/components/discovery.relabel/) component to discover your Apache Spark Prometheus endpoint and apply appropriate labels, followed by a [prometheus.scrape](/docs/alloy/latest/reference/components/prometheus.scrape) component to scrape it.

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

- `__address__`: The address to your Apache Spark Prometheus metrics endpoint.
- `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 Apache Spark instance.
- `spark_cluster`: The `spark_cluster` label to group your Apache Spark instances within a cluster. Set the same value for all nodes within your cluster.

If you have multiple Apache Spark servers to scrape, configure one `discovery.relabel` for each and scrape them by including each under `targets` within the `prometheus.scrape` component.

## Dashboards

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

- Apache Spark Metrics

**Apache Spark Dashboard**

## Metrics

The most important metrics provided by the Apache Spark integration, which are used on the pre-built dashboard, are as follows:

- metrics\_master\_workers\_Number
- metrics\_spark\_app\_driver\_BlockManager\_disk\_diskSpaceUsed\_MB\_Number
- metrics\_spark\_app\_driver\_BlockManager\_memory\_maxMem\_MB\_Number
- metrics\_spark\_app\_driver\_BlockManager\_memory\_maxOffHeapMem\_MB\_Number
- metrics\_spark\_app\_driver\_BlockManager\_memory\_maxOnHeapMem\_MB\_Number
- metrics\_spark\_app\_driver\_DAGScheduler\_job\_activeJobs\_Number
- metrics\_spark\_app\_driver\_DAGScheduler\_job\_allJobs\_Number
- metrics\_spark\_app\_driver\_DAGScheduler\_messageProcessingTime\_Max
- metrics\_spark\_app\_driver\_DAGScheduler\_messageProcessingTime\_Mean
- metrics\_spark\_app\_driver\_DAGScheduler\_messageProcessingTime\_Min
- metrics\_spark\_app\_driver\_DAGScheduler\_messageProcessingTime\_StdDev
- metrics\_spark\_app\_driver\_DAGScheduler\_stage\_failedStages\_Number
- metrics\_spark\_app\_driver\_DAGScheduler\_stage\_runningStages\_Number
- metrics\_spark\_app\_driver\_DAGScheduler\_stage\_waitingStages\_Number
- metrics\_spark\_app\_driver\_LiveListenerBus\_listenerProcessingTime\_org\_apache\_spark\_HeartbeatReceiver\_Count
- metrics\_spark\_app\_driver\_LiveListenerBus\_listenerProcessingTime\_org\_apache\_spark\_HeartbeatReceiver\_Max
- metrics\_spark\_app\_driver\_LiveListenerBus\_listenerProcessingTime\_org\_apache\_spark\_HeartbeatReceiver\_Mean
- metrics\_spark\_app\_driver\_LiveListenerBus\_listenerProcessingTime\_org\_apache\_spark\_HeartbeatReceiver\_Min
- metrics\_worker\_coresFree\_Number
- metrics\_worker\_coresUsed\_Number
- metrics\_worker\_memFree\_MB\_Number
- metrics\_worker\_memUsed\_MB\_Number
- up

## Changelog

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

```md
# 1.0.0 - December 2025

* Chore: Fix incorrect semver to 1.0.0. No further changes

# 0.0.5 - November 2023

* Replaced Angular dashboard panels with React panels

# 0.0.4 - September 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.
* New hostname relabel option, which applies the instance name you write on the text box to the Grafana Agent configuration snippets, making it easier and less error prone to configure this mandatory label.

# 0.0.3 - March 2023

* Updated to the latest mixin version

# 0.0.2 - May 2022

* Updated to the last mixin version:
  - fix panels that did not have the /integrations prefix on the queries.

# 0.0.1 - December 2021

* Initial release
```

## Cost

By connecting your Apache Spark 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/).
