Skip to content

Commit f07ee09

Browse files
committed
Update doc related to Promotheus JMX Exporter
1 parent d655269 commit f07ee09

4 files changed

Lines changed: 38 additions & 4 deletions

File tree

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ and spark-shell/pyspark environments.
2020
of Spark jobs under various configurations or code changes.
2121
- **Batch Job Analysis:** With Flight Recorder mode sparkMeasure transparently records batch job metrics
2222
for later analysis.
23-
- **Monitoring Capabilities:** Integrates with external systems like Apache Kafka, InfluxDB,
24-
and Prometheus Push Gateway for extensive monitoring.
23+
- **Monitoring Capabilities:** Integrates with external systems like Apache Kafka,
24+
Prometheus Push Gateway, Prometheus JMX Exporter, and InfluxDB for extensive monitoring.
2525
- **Educational Tool:** Serves as a practical example of implementing Spark Listeners for the collection
2626
of detailed Spark task metrics.
2727
- **Language Compatibility:** Fully supports Scala, Java, and Python, making it versatile for a wide range
@@ -332,6 +332,7 @@ SparkMeasure is one tool for many different use cases, languages, and environmen
332332
and analyzing Spark workload metrics data. Examples and how-to guides:
333333
- **[Instrument Spark-Python code](docs/Instrument_Python_code.md)**
334334
- **[Instrument Spark-Scala code](docs/Instrument_Scala_code.md)**
335+
- **[JMX Exporter integration](docs/JMX_Exporter_integration.md)**
335336
- See also [Spark_CPU_memory_load_testkit](https://github.com/LucaCanali/Miscellaneous/tree/master/Performance_Testing/Spark_CPU_memory_load_testkit)
336337
as an example of how to use sparkMeasure to instrument Spark code for performance testing.
337338

docs/Prometheus_through_JMX.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ In addition to exposing metrics via JMX, you must configure the Prometheus JMX e
4848
Ensure your Spark pod manifest or Helm chart includes a properly configured `ConfigMap` for the JMX exporter. Specifically, you’ll need to add mappings for the custom `sparkMeasure` metrics to the YAML under the `rules` section used by the Prometheus JMX exporter.
4949

5050
A production-ready configuration example is available here:
51-
📄 [How to configure the Prometheus exporter to expose sparkMeasure metrics](../e2e/charts/spark-demo/templates/jmx-configmap.yaml)
51+
📄 [How to configure the Prometheus exporter to expose sparkMeasure metrics](../e2e/charts/spark-jobs/templates/jmx-configmap.yaml)
5252

5353
---
5454

docs/Reference_SparkMeasure_API_and_Configs.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,39 @@ Configuration - PushGatewaySink parameters
450450
--conf spark.sparkmeasure.pushgateway.jobname=JOBNAME // default is pushgateway
451451
```
452452

453+
## Prometheus JMX Exporter
454+
```
455+
\\ This object provides an interface to the Dropwizard metrics registry
456+
object DropwizardMetrics
457+
458+
def setMetric(shortname: String, value: Double, metricType: String): Unit
459+
def describeMetrics() : String
460+
```
461+
462+
## Prometheus JMX Exporter - Python
463+
```
464+
from sparkmeasure.jmx import jmxexport
465+
466+
def jmxexport(spark: SparkSession, metrics: dict):
467+
"""
468+
Export the provided metrics to the JMX MBean server for Prometheus scraping.
469+
470+
Parameters:
471+
spark (SparkSession): The active Spark session.
472+
metrics (dict): A dictionary of metric names and their corresponding values.
473+
474+
This function updates the JMX MBean server with the provided metrics,
475+
making them available for scraping by Prometheus.
476+
"""
477+
478+
Example:
479+
480+
# get metrics data as a dictionary
481+
current_metrics = stagemetrics.aggregate_stagemetrics()
482+
# export metrics to JMX Prometheus exporter
483+
jmxexport(spark, current_metrics)
484+
```
485+
453486
## IOUtils
454487

455488
The object IOUtils contains some helper code for the sparkMeasure package

python/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
setup(
2222
name='sparkmeasure',
23-
version='0.25.0',
23+
version='0.26.0',
2424
description='Python API for sparkMeasure, a tool for performance troubleshooting of Apache Spark workloads.',
2525
long_description=long_description,
2626
long_description_content_type='text/markdown',

0 commit comments

Comments
 (0)