tutorial

How to Monitor Apache Spark MLlib with Vigilmon (Uptime, APIs, and Alerts)

Apache Spark MLlib is the machine learning library built into Apache Spark, providing scalable implementations of classification, regression, clustering, col...

Apache Spark MLlib is the machine learning library built into Apache Spark, providing scalable implementations of classification, regression, clustering, collaborative filtering, and feature engineering algorithms. MLlib pipelines run on the same distributed engine as Spark SQL and Spark Streaming — meaning they share the same failure modes as any Spark cluster, plus the additional complexity of model serving when you expose trained models as REST APIs.

When your Spark cluster loses a master node, MLlib training jobs queue indefinitely. When your model-serving microservice crashes, production predictions fail silently. This tutorial shows you how to set up uptime monitoring for Spark MLlib deployments using Vigilmon — free tier, no credit card.


Why Spark MLlib deployments need external monitoring

Spark MLlib adds monitoring surface area at every layer of the pipeline:

  • Cluster master failures — if the Spark master goes down, all submitted jobs hang at WAITING state with no automatic notification to submitters
  • Driver program crashes — the Spark driver (the process coordinating your MLlib job) can OOM or lose connectivity to executors mid-training, producing a failed job that nobody notices until they check the history server
  • Model serving outages — MLlib-trained models are often served via Spark's MLflow integration or a custom Flask/FastAPI wrapper; those serving processes can crash independently of the Spark cluster
  • REST history server timeouts — the Spark History Server can become unresponsive under large workloads, blocking your ability to diagnose past job failures

External monitoring from Vigilmon gives you real-time visibility across all these layers.


What you'll need

  • A running Apache Spark cluster (standalone, YARN, or Kubernetes mode)
  • A model serving endpoint exposing MLlib predictions (we'll use port 5000 in examples)
  • A free Vigilmon account (sign up takes 30 seconds)

Step 1: Expose health endpoints for your Spark stack

Spark exposes several built-in HTTP endpoints. Verify these are accessible:

# Spark master web UI (also indicates master health)
curl http://spark-master.example.com:8080/

# Spark REST API — list all applications
curl http://spark-master.example.com:6066/v1/submissions/status

# Spark History Server
curl http://spark-history.example.com:18080/api/v1/applications

For MLlib model serving, add a health route to your serving application:

# Flask-based MLlib model server
from flask import Flask, jsonify, request
from pyspark.ml import PipelineModel
import time

app = Flask(__name__)
model = PipelineModel.load("/models/your-mllib-model")

@app.get("/health")
def health():
    return jsonify({"status": "ok", "timestamp": time.time()}), 200

@app.post("/predict")
def predict():
    data = request.get_json()
    # inference logic
    result = model_infer(data)
    return jsonify({"prediction": result})

if __name__ == "__main__":
    app.run(host="0.0.0.0", port=5000)

For Docker deployments of your model server:

services:
  mllib-server:
    image: your-org/mllib-server:latest
    ports:
      - "5000:5000"
    environment:
      MODEL_PATH: /models/your-mllib-model
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:5000/health"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 60s
    restart: unless-stopped

Step 2: Set up HTTP monitoring for your model server

  1. Log in to vigilmon.online and go to Monitors → New Monitor
  2. Choose HTTP / HTTPS as the type
  3. URL: https://mllib.example.com/health
  4. Set check interval to 1 minute
  5. Under Expected response, configure:
    • Status code: 200
    • Response body contains: "status":"ok"
  6. Save the monitor

Vigilmon probes this endpoint from multiple regions every minute. A timeout or non-200 response triggers an incident immediately.


Step 3: Monitor the Spark master web UI

The Spark master web UI doubling as a health indicator is a practical free signal:

  1. Go to Monitors → New Monitor
  2. Choose HTTP / HTTPS
  3. URL: http://spark-master.example.com:8080/
  4. Expected status: 200
  5. Response body contains: Spark Master
  6. Save the monitor

This check fires if the Spark master process dies or becomes unresponsive — giving you early warning before job submissions start failing.


Step 4: Add TCP port monitoring for Spark internals

Spark's internal communication ports are the earliest indicator of cluster health problems. Add TCP monitors for the critical ones:

For the Spark master submission port:

  1. Go to Monitors → New Monitor
  2. Choose TCP Port
  3. Host: spark-master.example.com, Port: 7077
  4. Save the monitor

For the Spark History Server:

  1. Repeat for host spark-history.example.com, port 18080

If your MLlib pipeline reads from HDFS or an object store, add TCP checks for those too:

| Service | Default port | |---------|-------------| | HDFS NameNode | 8020 | | HDFS DataNode | 50010 | | S3 / MinIO | 9000 |


Step 5: Monitor the MLflow tracking server (if applicable)

If you use MLflow for experiment tracking alongside Spark MLlib, its tracking server is another failure point:

  1. Go to Monitors → New Monitor
  2. Choose HTTP / HTTPS
  3. URL: https://mlflow.example.com/health
  4. Expected status: 200
  5. Save the monitor

Losing the MLflow tracking server won't stop jobs from running, but it will cause training metrics to fail to log — which makes post-failure debugging much harder.


Step 6: Configure webhook alerts

Spark cluster failures often cascade quickly — a lost master means all in-flight jobs fail simultaneously. Get alerted the moment Vigilmon detects a problem.

  1. Go to Alert Channels → Add Channel → Webhook
  2. Enter your Slack, PagerDuty, or OpsGenie webhook URL
  3. Assign the channel to all your Spark MLlib monitors

Example alert payload from Vigilmon:

{
  "monitor_name": "Spark Master Web UI",
  "status": "down",
  "url": "http://spark-master.example.com:8080/",
  "started_at": "2026-05-20T03:14:00Z",
  "duration_seconds": 300
}

For the model-serving endpoints, configure a separate alert channel for your application team separate from the infrastructure alert channel — they need different response runbooks.


Step 7: Create a status page for your ML infrastructure

If internal teams submit MLlib training jobs or consume prediction APIs, give them a status page:

  1. Go to Status Pages → New Status Page
  2. Name it (e.g. "Spark ML Platform Status")
  3. Add all your monitors — model server HTTP, Spark master, TCP checks, MLflow
  4. Publish the page

Share the URL in your internal developer portal so teams can check status before escalating.


Monitor coverage summary

| Monitor | Type | What it catches | |---------|------|-----------------| | https://mllib.example.com/health | HTTP | Model server crash, failed model load | | http://spark-master.example.com:8080/ | HTTP | Spark master process failure | | https://mlflow.example.com/health | HTTP | MLflow tracking server outage | | spark-master.example.com:7077 | TCP | Spark submission port loss | | spark-history.example.com:18080 | TCP | History server unreachable |


What's next

  • Heartbeat monitors — wrap your scheduled MLlib training jobs to ping a Vigilmon heartbeat URL on successful completion; if it stops arriving, you know the job failed silently
  • SSL certificate monitoring — Vigilmon tracks TLS expiry across all your HTTPS endpoints, including model-serving APIs

Get started free at vigilmon.online — no credit card, monitors start running in under a minute.

Monitor your app with Vigilmon

Free plan — 5 monitors, no credit card required. Up and running in 60 seconds.

Start free →