Menu
Grafana Cloud

Apache Hadoop integration for Grafana Cloud

Apache Hadoop is an open-source framework designed to process and store large amounts of data across distributed clusters of computers. It provides a scalable and fault-tolerant solution for handling big data by utilizing a distributed file system (Hadoop Distributed File System) and a parallel processing model (MapReduce). This integration for Grafana Cloud allows users to monitor a Hadoop cluster with 4 separate dashboards for visualizing metrics and logs for a Hadoop NameNode, DataNode, NodeManager, and ResourceManager component.

This integration supports Apache Hadoop version 3.3.1+
Apache Hadoop 3.3 and upper supports Java 8 and Java 11 (runtime only)
This integration supports the JMX exporter 0.17.0+

This integration includes 8 useful alerts and 4 pre-built dashboards to help monitor and visualize Apache Hadoop metrics and logs.

Grafana Alloy configuration

Before you begin

In order for the integration to properly work, you must set up the JMX Exporter for Prometheus on each instance in your cluster.

Set up JMX Exporter

Each instance requires a JMX to Prometheus exporter. This is a collector that creates an HTTP server that serves mBean metrics of the local JVM target. Depending on the Apache Hadoop component being monitored - i.e., the NameNode, DataNode, NodeManager and/or ResourceManager - a slightly different configuration will be used. Typically, a DataNode and a NodeManager are grouped together, while the ResourceManager and NameNode are separate. However, each Hadoop deployment architecture may vary.

Expose JMX Remotely

To expose the JMX remotely, it needs to be enabled for the components being monitored. A configuration option enables JMX on the Hadoop daemons, which exists in a hadoop-env.sh file located in the /etc/hadoop/conf. Within the bash file, there is a HDFS_<COMPONENT>_OPTS value that will take an argument to enable JMX, specify the <JMX_PORT>, and manage security options. It should look similar to:

sh
export HDFS_<COMPONENT>_OPTS="-Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.port=<JMX_PORT> -Dcom.sun.management.jmxremote.ssl=false"

Then save the configuration file and restart the Hadoop daemons. For more details on setting up an Apache Hadoop cluster environment, refer to the official documentation.

Connect JMX to the Prometheus Exporter

In order to connect JMX to the Prometheus Exporter, a collector is configured in a config file for each component being monitored. This .yaml file, such as namenode.yaml, can be placed anywhere and named anything but must specify the exposed JMX_PORT for the component being monitored. It should look similar to:

sh
hostPort: localhost:<JMX_PORT>
lowercaseOutputName: true
lowercaseOutputLabelNames: true
rules:
    - pattern: ".*"

Run the Prometheus Exporter

To run the JMX to Prometheus exporter, the Java Agent or a Standalone HTTP Server is used. These require two arguments: a .yaml file that was created above and the <JMX_EXPORTER_PORT> that exposes the metrics.

To run the JMX to Prometheus exporter as a Java Agent:

sh
java -javaagent:./jmx_prometheus_javaagent-0.17.0.jar=<JMX_EXPORTER_PORT>:<COMPONENT>.yaml -jar yourJar.jar

To run the JMX to Prometheus exporter as a Standalone HTTP Server:

sh
java -jar jmx_prometheus_httpserver-0.17.0.jar <JMX_EXPORTER_PORT> /path-to-jmx-configs/<COMPONENT>.yaml

To validate that the JMX Exporter is setup correctly, the Prometheus metrics should be available locally via curl:

sh
curl http://localhost:<JMX_EXPORTER_PORT>/metrics

Install Apache Hadoop integration for Grafana Cloud

  1. In your Grafana Cloud stack, click Connections in the left-hand menu.
  2. Find Apache Hadoop and click its tile to open the integration.
  3. Review the prerequisites in the Configuration Details tab and set up Grafana Agent to send Apache Hadoop 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 Apache Hadoop 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 Hadoop instances, manually copy and append the snippets to your alloy configuration file, then follow subsequent instructions.

Advanced metrics snippets

river
prometheus.scrape "metrics_integrations_integrations_apache_hadoop" {
	targets = [{
		__address__    = "<your-host-name>:<jmx-exporter-port>",
		hadoop_cluster = "<your-cluster-name>",
		instance       = constants.hostname,
	}]
	forward_to = [prometheus.remote_write.metrics_service.receiver]
	job_name   = "integrations/apache-hadoop"
}

To monitor your Apache Hadoop instance, you must use a discovery.relabel component to discover your Apache Hadoop Prometheus endpoint and apply appropriate labels, followed by a prometheus.scrape component to scrape it.

Configure the following properties within each discovery.relabel component:

  • __address__: The address to your Apache Hadoop 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 Hadoop instance. Make sure this label value is the same for all telemetry data collected for this instance.
  • hadoop_cluster must be the value that identifies the Apache Hadoop cluster this node belongs to.

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

Advanced logs snippets

linux

river
local.file_match "logs_integrations_integrations_apache_hadoop" {
	path_targets = [{
		__address__    = "localhost",
		__path__       = "<your-log-path>",
		hadoop_cluster = "<your-cluster-name>",
		instance       = constants.hostname,
		job            = "integrations/apache-hadoop",
	}]
}

loki.source.file "logs_integrations_integrations_apache_hadoop" {
	targets    = local.file_match.logs_integrations_integrations_apache_hadoop.targets
	forward_to = [loki.write.grafana_cloud_loki.receiver]
}

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

  • local.file_match defines where to find the log file to be scraped. Change the following properties according to your environment:

    • __address__: The Apache Hadoop instance address
    • __path__: this is the component log location, which by default is indicated in the HADOOP_LOG_DIR entry within /etc/hadoop/conf config gile. An example log path may look like /hadoop/logs/*.log on Linux.
    • 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 Hadoop instance. Make sure this label value is the same for all telemetry data collected for this instance.
    • hadoop_cluster must be the value that identifies the Apache Hadoop cluster this node belongs to.
  • loki.source.file sends logs to Loki.

On Linux, you will also need to add the alloy user to the hadoop group to get logs. Run the following command to configure the user as required:

sh
sudo usermod -a -G hadoop alloy
Grafana Agent configuration

Before you begin

In order for the integration to properly work, you must set up the JMX Exporter for Prometheus on each instance in your cluster.

Set up JMX Exporter

Each instance requires a JMX to Prometheus exporter. This is a collector that creates an HTTP server that serves mBean metrics of the local JVM target. Depending on the Apache Hadoop component being monitored - i.e., the NameNode, DataNode, NodeManager and/or ResourceManager - a slightly different configuration will be used. Typically, a DataNode and a NodeManager are grouped together, while the ResourceManager and NameNode are separate. However, each Hadoop deployment architecture may vary.

Expose JMX Remotely

To expose the JMX remotely, it needs to be enabled for the components being monitored. A configuration option enables JMX on the Hadoop daemons, which exists in a hadoop-env.sh file located in the /etc/hadoop/conf. Within the bash file, there is a HDFS_<COMPONENT>_OPTS value that will take an argument to enable JMX, specify the <JMX_PORT>, and manage security options. It should look similar to:

sh
export HDFS_<COMPONENT>_OPTS="-Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.port=<JMX_PORT> -Dcom.sun.management.jmxremote.ssl=false"

Then save the configuration file and restart the Hadoop daemons. For more details on setting up an Apache Hadoop cluster environment, refer to the official documentation.

Connect JMX to the Prometheus Exporter

In order to connect JMX to the Prometheus Exporter, a collector is configured in a config file for each component being monitored. This .yaml file, such as namenode.yaml, can be placed anywhere and named anything but must specify the exposed JMX_PORT for the component being monitored. It should look similar to:

sh
hostPort: localhost:<JMX_PORT>
lowercaseOutputName: true
lowercaseOutputLabelNames: true
rules:
    - pattern: ".*"

Run the Prometheus Exporter

To run the JMX to Prometheus exporter, the Java Agent or a Standalone HTTP Server is used. These require two arguments: a .yaml file that was created above and the <JMX_EXPORTER_PORT> that exposes the metrics.

To run the JMX to Prometheus exporter as a Java Agent:

sh
java -javaagent:./jmx_prometheus_javaagent-0.17.0.jar=<JMX_EXPORTER_PORT>:<COMPONENT>.yaml -jar yourJar.jar

To run the JMX to Prometheus exporter as a Standalone HTTP Server:

sh
java -jar jmx_prometheus_httpserver-0.17.0.jar <JMX_EXPORTER_PORT> /path-to-jmx-configs/<COMPONENT>.yaml

To validate that the JMX Exporter is setup correctly, the Prometheus metrics should be available locally via curl:

sh
curl http://localhost:<JMX_EXPORTER_PORT>/metrics

Install Apache Hadoop integration for Grafana Cloud

  1. In your Grafana Cloud stack, click Connections in the left-hand menu.
  2. Find Apache Hadoop and click its tile to open the integration.
  3. Review the prerequisites in the Configuration Details tab and set up Grafana Agent to send Apache Hadoop 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 Apache Hadoop setup.

Post-install configuration for the Apache Hadoop integration

After enabling the metrics generation, instruct the Grafana Agent to scrape your Apache Hadoop component. The Grafana Agent config is stored in /etc/grafana-agent.yaml.

Enable the integration by adding the suggested snippets to your agent configuration file.

If you want to show logs and metrics signals correlated in your dashboards as a single pane of glass, ensure the following:

  • job and instance label values must match for the Apache Hadoop integration and logs scrape config in your agent configuration file.
  • job must be set to integrations/apache-hadoop (already configured in the snippets).
  • instance must be set to a value that uniquely identifies your Apache Hadoop node.
  • hadoop_cluster must be the value that identifies the Apache Hadoop cluster this node belongs to.
  • __path__ is the component log location, which the default Apache Hadoop log path is indicated in the HADOOP_LOG_DIR for your system located in /etc/hadoop/conf. An example log path may look like /hadoop/logs/*.log on Linux.

Make sure to change targets in the snippet according to your host name and JMX_EXPORTER_PORT.

On Linux, you will also need to add the grafana-agent user to the hadoop group to get logs. Run the following command to configure the user as required:

sh
sudo usermod -a -G hadoop grafana-agent

Configuration snippets for Grafana Agent

Below metrics.configs.scrape_configs, insert the following lines and change the URLs according to your environment:

yaml
    - job_name: integrations/apache-hadoop
      metrics_path: /metrics
      static_configs:
        - targets: ['<your-host-name>:<jmx-exporter-port>']
          labels:
            instance: '<your-instance-name>'
            hadoop_cluster: '<your-cluster-name>'

Below logs.configs.scrape_configs, insert the following lines according to your environment.

yaml
    - job_name: integrations/apache-hadoop
      static_configs:
        - targets:
          - localhost
          labels:
            job: integrations/apache-hadoop
            instance: '<your-instance-name>'
            hadoop_cluster: '<your-cluster-name>'
            __path__: '<your-log-path>'

Full example configuration for Grafana Agent

Refer to the following Grafana Agent configuration for a complete example that contains all the snippets used for the Apache Hadoop integration. This example also includes metrics that are sent to monitor your Grafana Agent instance.

yaml
integrations:
  prometheus_remote_write:
  - basic_auth:
      password: <your_prom_pass>
      username: <your_prom_user>
    url: <your_prom_url>
  agent:
    enabled: true
    relabel_configs:
    - action: replace
      source_labels:
      - agent_hostname
      target_label: instance
    - action: replace
      target_label: job
      replacement: "integrations/agent-check"
    metric_relabel_configs:
    - action: keep
      regex: (prometheus_target_sync_length_seconds_sum|prometheus_target_scrapes_.*|prometheus_target_interval.*|prometheus_sd_discovered_targets|agent_build.*|agent_wal_samples_appended_total|process_start_time_seconds)
      source_labels:
      - __name__
  # Add here any snippet that belongs to the `integrations` section.
  # For a correct indentation, paste snippets copied from Grafana Cloud at the beginning of the line.
logs:
  configs:
  - clients:
    - basic_auth:
        password: <your_loki_pass>
        username: <your_loki_user>
      url: <your_loki_url>
    name: integrations
    positions:
      filename: /tmp/positions.yaml
    scrape_configs:
      # Add here any snippet that belongs to the `logs.configs.scrape_configs` section.
      # For a correct indentation, paste snippets copied from Grafana Cloud at the beginning of the line.
    - job_name: integrations/apache-hadoop
      static_configs:
        - targets:
          - localhost
          labels:
            job: integrations/apache-hadoop
            instance: '<your-instance-name>'
            hadoop_cluster: '<your-cluster-name>'
            __path__: '<your-log-path>'
metrics:
  configs:
  - name: integrations
    remote_write:
    - basic_auth:
        password: <your_prom_pass>
        username: <your_prom_user>
      url: <your_prom_url>
    scrape_configs:
      # Add here any snippet that belongs to the `metrics.configs.scrape_configs` section.
      # For a correct indentation, paste snippets copied from Grafana Cloud at the beginning of the line.
    - job_name: integrations/apache-hadoop
      metrics_path: /metrics
      static_configs:
        - targets: ['<your-host-name>:<jmx-exporter-port>']
          labels:
            instance: '<your-instance-name>'
            hadoop_cluster: '<your-cluster-name>'
  global:
    scrape_interval: 60s
  wal_directory: /tmp/grafana-agent-wal

Dashboards

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

  • Apache Hadoop DataNode overview
  • Apache Hadoop NameNode overview
  • Apache Hadoop NodeManager overview
  • Apache Hadoop ResourceManager overview

Apache Hadoop NameNode overview (1/2)

Apache Hadoop NameNode overview (1/2)

Apache Hadoop DataNode overview (1/1)

Apache Hadoop DataNode overview (1/1)

Apache Hadoop NodeManger overview (1/2)

Apache Hadoop NodeManger overview (1/2)

Alerts

The Apache Hadoop integration includes the following useful alerts:

AlertDescription
ApacheHadoopLowHDFSCapacityWarning: Remaining HDFS cluster capacity is low which may result in DataNode failures or prevent DataNodes from writing data.
ApacheHadoopHDFSMissingBlocksCritical: There are missing blocks in the HDFS cluster which may indicate potential data loss.
ApacheHadoopHDFSHighVolumeFailuresCritical: A volume failure in HDFS cluster may indicate hardware failures.
ApacheHadoopHighDeadDataNodesCritical: Number of dead DataNodes has increased, which could result in data loss and increased network activity.
ApacheHadoopHighNodeManagerCPUUsageCritical: A NodeManager has a CPU usage higher than the configured threshold.
ApacheHadoopHighNodeManagerMemoryUsageCritical: A NodeManager has a higher memory utilization than the configured threshold.
ApacheHadoopHighResourceManagerVirtualCoreCPUUsageCritical: A ResourceManager has a virtual core CPU usage higher than the configured threshold.
ApacheHadoopHighResourceManagerMemoryUsageCritical: A ResourceManager has a higher memory utilization than the configured threshold.

Metrics

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

  • hadoop_datanode_blocksremoved
  • hadoop_datanode_ramdiskblocksevictedwithoutread
  • hadoop_datanode_volumefailures
  • hadoop_namenode_blockstotal
  • hadoop_namenode_capacityremaining
  • hadoop_namenode_capacitytotal
  • hadoop_namenode_capacityused
  • hadoop_namenode_filestotal
  • hadoop_namenode_missingblocks
  • hadoop_namenode_numdeaddatanodes
  • hadoop_namenode_totalload
  • hadoop_namenode_transactionssincelastcheckpoint
  • hadoop_namenode_underreplicatedblocks
  • hadoop_namenode_volumefailurestotal
  • hadoop_nodemanager_allocatedcontainers
  • hadoop_nodemanager_allocatedgb
  • hadoop_nodemanager_allocatedvcores
  • hadoop_nodemanager_applicationsrunning
  • hadoop_nodemanager_availablegb
  • hadoop_nodemanager_availablevcores
  • hadoop_nodemanager_containerlaunchdurationavgtime
  • hadoop_nodemanager_containerscompleted
  • hadoop_nodemanager_containersfailed
  • hadoop_nodemanager_containersiniting
  • hadoop_nodemanager_containerskilled
  • hadoop_nodemanager_containerslaunched
  • hadoop_nodemanager_containerspaused
  • hadoop_nodemanager_containersreiniting
  • hadoop_nodemanager_containerusedmemgb
  • hadoop_nodemanager_containerusedvmemgb
  • hadoop_nodemanager_gccount
  • hadoop_nodemanager_gctimemillis
  • hadoop_nodemanager_localizationdurationmillisavgtime
  • hadoop_nodemanager_memheapcommittedm
  • hadoop_nodemanager_memheapusedm
  • hadoop_nodemanager_memnonheapcommittedm
  • hadoop_nodemanager_memnonheapusedm
  • hadoop_nodemanager_nodecpuutilization
  • hadoop_nodemanager_nodegpuutilization
  • hadoop_resourcemanager_activeapplications
  • hadoop_resourcemanager_allocatedmb
  • hadoop_resourcemanager_allocatedvcores
  • hadoop_resourcemanager_appscompleted
  • hadoop_resourcemanager_appsfailed
  • hadoop_resourcemanager_appskilled
  • hadoop_resourcemanager_appspending
  • hadoop_resourcemanager_appsrunning
  • hadoop_resourcemanager_appssubmitted
  • hadoop_resourcemanager_availablemb
  • hadoop_resourcemanager_availablevcores
  • hadoop_resourcemanager_gccount
  • hadoop_resourcemanager_gctimemillis
  • hadoop_resourcemanager_memheapcommittedm
  • hadoop_resourcemanager_memheapusedm
  • hadoop_resourcemanager_memnonheapcommittedm
  • hadoop_resourcemanager_memnonheapusedm
  • hadoop_resourcemanager_numactivenms
  • hadoop_resourcemanager_numdecommissionednms
  • hadoop_resourcemanager_numlostnms
  • hadoop_resourcemanager_numrebootednms
  • hadoop_resourcemanager_numshutdownnms
  • hadoop_resourcemanager_numunhealthynms
  • up

Changelog

md
# 0.0.3 - 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.2 - August 2023

* Add regex filter for logs datasource

# 0.0.1 - July 2023

* Initial release

Cost

By connecting your Apache Hadoop 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.