Pathway is an open source Python framework for building real-time AI and data pipelines — RAG document ingestion, ML feature computation, CDC-driven analytics — using familiar pandas-like APIs and automatic incremental computation. A Pathway pipeline is a long-running Python process that continuously reads from sources (Kafka, S3, PostgreSQL, REST APIs), transforms data, optionally calls LLMs or writes to vector databases, and emits results to output sinks. When any link in that chain breaks — an LLM API goes down, a Kafka connector drops, memory grows unbounded — your real-time AI application silently degrades. Vigilmon monitors every layer of the Pathway stack so you catch failures before your RAG index goes stale or your ML features fall behind.
What You'll Set Up
- Process health monitor for the Pathway worker via REST API
- Data source connector health checks per input source
- LLM API availability and error rate monitoring
- Vector database write health (for RAG pipelines)
- Incremental computation lag monitoring
- Output sink write health
- Memory usage alert
- RAG freshness heartbeat
- Pipeline error rate alerting
Prerequisites
- Pathway pipeline deployed (Docker container, systemd service, or Kubernetes pod)
- Pathway REST API server enabled (
pw.io.http.rest_connectororpw.run_server()) - Access to your LLM provider API endpoint (if applicable)
- A free Vigilmon account
Step 1: Monitor the Pathway Worker Process
The Pathway worker is the Python process running your pipeline. A crash stops all incremental computation — source connectors disconnect, LLM calls stop, and your real-time index freezes.
Expose a health endpoint from your Pathway application:
import pathway as pw
from pathway.io.http import rest_connector
# Add a health check route alongside your pipeline
@pw.udf
def health_check(query: str) -> str:
return '{"status": "ok", "pipeline": "running"}'
# Or use Pathway's built-in REST server
pw.run_server(host="0.0.0.0", port=8000, with_cache=False)
Then add the monitor in Vigilmon:
- Log in to vigilmon.online and click Add Monitor.
- Set Type to
HTTP / HTTPS. - URL:
http://your-pathway-host:8000/health - Check interval:
1 minute - Expected HTTP status:
200 - Keyword check:
running - Click Save.
If your pipeline runs as a systemd service, also monitor the TCP port the Pathway REST server binds to as a secondary liveness signal.
Step 2: Monitor Data Source Connectors
Pathway reads from Kafka, S3, PostgreSQL, and REST APIs. A lost connector means your pipeline processes stale data silently.
Kafka Input Connector
- Click Add Monitor → TCP Port.
- Host: your Kafka broker hostname.
- Port:
9092(or your broker port). - Check interval:
1 minute - Click Save.
PostgreSQL Input Connector (CDC)
- Click Add Monitor → TCP Port.
- Host: your PostgreSQL host.
- Port:
5432 - Check interval:
1 minute - Click Save.
REST API Input Connector
If Pathway polls an external REST API as a data source:
- Click Add Monitor → HTTP / HTTPS.
- URL: the external REST API endpoint Pathway polls.
- Expected HTTP status:
200 - Check interval:
2 minutes - Click Save.
For each connector, add the health metric to your Pathway pipeline's instrumentation:
import pathway as pw
import requests
class ConnectorHealthLogger:
def log_connector_status(self, connector_name: str, ok: bool):
# Emit to your metrics endpoint
print(f"connector_health{{connector=\"{connector_name}\"}} {1 if ok else 0}")
Step 3: Monitor LLM API Health
If your Pathway pipeline calls an LLM for real-time AI processing (e.g., embedding generation for RAG, classification, summarization), LLM API downtime or elevated error rates directly break your pipeline's AI output.
LLM API Endpoint Monitor
- Click Add Monitor → HTTP / HTTPS.
- For OpenAI: URL
https://api.openai.com/v1/modelsFor a self-hosted model (Ollama, vLLM): URLhttp://your-llm-host:11434/api/tags - Expected HTTP status:
200 - Check interval:
2 minutes - Click Save.
LLM Error Rate via Pipeline Metrics
Add error rate instrumentation to your LLM calls in the Pathway pipeline:
import pathway as pw
import openai
import time
@pw.udf
def call_llm_with_monitoring(text: str) -> str:
start = time.time()
try:
response = openai.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": text}]
)
# Record success metric
record_metric("llm_api_success", 1)
record_metric("llm_api_latency_ms", (time.time() - start) * 1000)
return response.choices[0].message.content
except Exception as e:
# Record failure metric
record_metric("llm_api_error", 1)
raise
Expose the error rate via an HTTP metrics endpoint and add a Vigilmon keyword check:
- Click Add Monitor → HTTP / HTTPS.
- URL:
http://your-pathway-host:8000/metrics/llm - Keyword check: ensure
error_rateis below your threshold (e.g., check forerror_rate":0.matching only values under 0.05). - Check interval:
2 minutes - Click Save.
Step 4: Monitor Vector Database Write Health (RAG Pipelines)
Pathway-powered RAG pipelines write embeddings to a vector database (Pinecone, Weaviate, Qdrant). Failed writes cause your RAG index to go stale — queries return outdated results without any obvious error.
Add write health tracking to your Pathway vector sink:
import pathway as pw
import requests
@pw.udf
def write_to_vector_db_with_health(embedding: list, doc_id: str) -> str:
try:
# Your vector DB write logic here
result = vector_db_client.upsert([(doc_id, embedding)])
record_metric("vector_write_success", 1)
return "ok"
except Exception as e:
record_metric("vector_write_failure", 1)
raise
Then monitor the sink health endpoint:
- Click Add Monitor → HTTP / HTTPS.
- URL:
http://your-pathway-host:8000/metrics/vector-sink - Expected HTTP status:
200 - Keyword check:
write_failure":0 - Check interval:
2 minutes - Click Save.
Step 5: Monitor Incremental Computation Lag
Pathway's key promise is low-latency incremental updates — your output should reflect new input within your SLA window. If lag grows, your real-time AI application is serving stale results.
Instrument end-to-end lag in your pipeline:
import pathway as pw
import time
@pw.udf
def tag_with_ingestion_time(data: str) -> dict:
return {"data": data, "ingested_at": time.time()}
@pw.udf
def compute_lag_and_emit(tagged_data: dict) -> str:
lag_ms = (time.time() - tagged_data["ingested_at"]) * 1000
record_metric("pipeline_lag_ms", lag_ms)
if lag_ms > 5000: # Alert threshold: 5 second SLA
record_metric("pipeline_sla_breach", 1)
return tagged_data["data"]
Monitor the lag metric:
- Click Add Monitor → HTTP / HTTPS.
- URL:
http://your-pathway-host:8000/metrics/lag - Keyword check:
sla_breach":0 - Check interval:
1 minute - Click Save.
Step 6: Monitor the Pathway REST API Output
If Pathway exposes query results via HTTP (e.g., for real-time RAG retrieval), monitor the API endpoint directly:
- Click Add Monitor → HTTP / HTTPS.
- URL:
http://your-pathway-host:8000/v1/query(or your configured endpoint path). - Method:
GETorPOSTdepending on your Pathway REST connector configuration. - Expected HTTP status:
200 - Check interval:
1 minute - Click Save.
Step 7: Monitor Output Sink Health
Pathway writes results to Kafka, S3, or REST endpoints. A sink failure means processed data accumulates in memory without being delivered downstream.
Kafka Output Topic
- Click Add Monitor → TCP Port.
- Host: your Kafka broker.
- Port:
9092 - Check interval:
1 minute - Click Save.
For sink-level write success, use the same metrics endpoint pattern from Step 4:
@pw.udf
def write_to_kafka_with_health(record: dict) -> str:
try:
producer.produce(output_topic, key=record["id"], value=json.dumps(record))
producer.flush()
record_metric("kafka_sink_write_success", 1)
return "ok"
except Exception as e:
record_metric("kafka_sink_write_failure", 1)
raise
Step 8: Monitor Memory Usage
Pathway maintains incremental computation state in memory. Unbounded state growth causes OOM crashes — particularly for pipelines that join large historical datasets or accumulate windowed aggregations.
Expose memory usage from your Pathway process:
import psutil
import os
from http.server import BaseHTTPRequestHandler, HTTPServer
import json
import threading
class MetricsHandler(BaseHTTPRequestHandler):
def do_GET(self):
if self.path == '/metrics/memory':
process = psutil.Process(os.getpid())
mem_info = process.memory_info()
total_ram = psutil.virtual_memory().total
usage_pct = (mem_info.rss / total_ram) * 100
payload = {
"rss_bytes": mem_info.rss,
"memory_pct": round(usage_pct, 2),
"oom_risk": usage_pct > 80
}
self.send_response(200)
self.end_headers()
self.wfile.write(json.dumps(payload).encode())
# Start metrics server in background thread
threading.Thread(
target=lambda: HTTPServer(('0.0.0.0', 9090), MetricsHandler).serve_forever(),
daemon=True
).start()
Then add the Vigilmon monitor:
- Click Add Monitor → HTTP / HTTPS.
- URL:
http://your-pathway-host:9090/metrics/memory - Keyword check:
oom_risk":false - Check interval:
2 minutes - Click Save.
Step 9: RAG Freshness Heartbeat
For RAG pipelines, staleness is a silent failure: the pipeline is running but hasn't ingested a new document in hours. Add a heartbeat that fires each time a document is successfully ingested and indexed:
- Click Add Monitor → Cron Heartbeat.
- Set the expected interval to your target ingestion cadence (e.g.,
30 minutesif you expect new documents at least every 30 minutes). - Copy the heartbeat URL.
- Fire the heartbeat from your document ingestion sink:
import pathway as pw
import requests
@pw.udf
def index_document_with_freshness_ping(doc: dict) -> str:
# Index the document
index_result = vector_db_client.upsert_document(doc)
# Ping Vigilmon to record a successful ingest
try:
requests.get(
"https://vigilmon.online/heartbeat/rag-freshness-abc123",
timeout=3
)
except Exception:
pass # Don't let heartbeat failures affect pipeline processing
return index_result
If document ingestion stalls, the heartbeat goes silent and Vigilmon alerts you.
Step 10: Configure Alert Channels
Route alerts based on severity:
Worker crash (P0):
- Monitor: Worker process HTTP health check
- Alert condition:
down for 1 check - Channel: PagerDuty or SMS
- Reason: pipeline stops entirely; no incremental updates until process restarts
LLM API down (P1):
- Monitor: LLM API endpoint HTTP check
- Alert condition:
down for 2 consecutive checks - Channel: Slack
#ai-ops - Reason: real-time AI processing fails; RAG queries degrade to stale results
Incremental lag SLA breach (P1):
- Monitor: Pipeline lag metrics HTTP check
- Alert condition:
sla_breach keyword present - Channel: Slack
#ai-ops - Reason: real-time AI inference is serving stale data
Vector DB write failures (P1):
- Monitor: Vector sink health HTTP check
- Alert condition:
write_failure > 0 - Channel: Slack
#ai-ops - Reason: RAG index going stale
Memory OOM risk (P2):
- Monitor: Memory metrics HTTP check
- Alert condition:
oom_risk true - Channel: Slack
#data-engineering+ PagerDuty - Reason: OOM imminent; need to tune state retention or scale memory
RAG freshness heartbeat missed (P2):
- Monitor: Cron Heartbeat
- Alert condition:
missed by 1 interval - Channel: Slack
#ai-ops - Reason: document ingestion stalled; RAG index becoming stale
Summary
| What to monitor | Monitor type | Check interval | Alert condition | |---|---|---|---| | Pathway worker process | HTTP | 1 min | Down for 1 check | | Kafka/PG source connectors | TCP Port | 1 min | Unreachable | | LLM API availability | HTTP | 2 min | Down for 2 checks | | LLM API error rate | HTTP / keyword | 2 min | Error rate > 0 | | Vector DB write health | HTTP / keyword | 2 min | Write failures > 0 | | Incremental computation lag | HTTP / keyword | 1 min | SLA breach flag | | Pathway REST API output | HTTP | 1 min | Down for 1 check | | Output sink write health | HTTP / keyword | 2 min | Write failures > 0 | | Process memory usage | HTTP / keyword | 2 min | OOM risk flag | | RAG document freshness | Cron Heartbeat | Per ingest cadence | Heartbeat missed |
Pathway's incremental computation model makes it uniquely powerful for real-time AI pipelines — but that same continuous-processing model means a silent failure can let stale data accumulate undetected. Vigilmon closes that gap with end-to-end monitoring from source connector to vector index freshness, so your RAG pipeline stays fresh and your users never see yesterday's answers.