Schedule icon
Script icon
If icon
Create icon
SlackIncomingWebhook icon
Log icon

MongoDB WiredTiger Cache Pressure and Dirty Page Sentinel

Monitor MongoDB WiredTiger storage engine cache pressure and dirty pages with Kestra. Query serverStatus, log GitHub issues, and alert Slack.

Categories
DataInfrastructure

Diagram unavailable

We could not build the topology for this blueprint. The flow itself is valid, use the YAML on the left to run it.

MongoDB's default storage engine, WiredTiger, allocates half of available RAM minus 1 GB for its in-memory working cache. Under heavy write workloads or unindexed update operations, data pages in memory become dirty before being flushed to disk. When dirty bytes exceed 20% of the total cache, WiredTiger forces user application threads to stall and perform disk writes, causing catastrophic p99 query latency spikes and connection pileups. This blueprint probes MongoDB serverStatus on a 10-minute schedule, calculates dirty cache saturation, opens an automated GitHub DBA incident ticket, and alerts on-call database engineers on Slack.

How it works

  1. periodic_wiredtiger_health_check (io.kestra.plugin.core.trigger.Schedule) initiates the audit every 10 minutes (shipped disabled for safe verification).
  2. probe_wiredtiger_cache_status (io.kestra.plugin.scripts.python.Script) executes the serverStatus administrative command and extracts wiredTiger.cache metrics.
  3. branch_on_cache_pressure (io.kestra.plugin.core.flow.If) evaluates whether dirty cache percentage breached the operator threshold (is_pressure_critical == true):
    • then: Automatically files a GitHub tracking issue via create_dba_incident_issue (io.kestra.plugin.github.issues.Create) and alerts the Slack channel via alert_dba_slack (io.kestra.plugin.slack.notifications.SlackIncomingWebhook).
    • else: Emits an informational log entry (log_cache_healthy) confirming normal operational cache levels.
  4. log_audit_complete (io.kestra.plugin.core.log.Log) records the final audit outcome.
  5. The errors block alerts Slack if database authentication times out or network connectivity fails.

What you get

  • Automated, scheduled auditing of MongoDB WiredTiger storage engine health.
  • Early warning before dirty cache thresholds force foreground write stalls.
  • Consolidated GitHub incident tickets with configured vs utilized bytes and dirty ratios.
  • Real-time Slack notifications with direct ticket hyperlinks.

Who it's for

  • Database Administrators (DBAs) and Platform Engineers maintaining production MongoDB clusters.
  • Site Reliability Engineers safeguarding query response times under high write concurrency.
  • Infrastructure Architects sizing MongoDB compute and memory footprints.

Why orchestrate this with Kestra

Kestra coordinates administrative database probing, memory metric calculations, conditional escalation, and chat alerting inside a single declarative workflow. It manages database credentials securely, provides complete execution history, and eliminates the need for separate standalone monitoring daemons.

Prerequisites

  • A MongoDB cluster or standalone instance (OSS MongoDB, Atlas, or Percona Server for MongoDB).
  • A MongoDB user with serverStatus or clusterMonitor permissions.
  • A GitHub Personal Access Token with repository issue creation permissions.
  • A Slack incoming webhook URL for notifications.

Secrets

  • GITHUB_TOKEN: GitHub token used to open incident issues.
  • SLACK_WEBHOOK: Incoming Webhook URL for DBA alerts.

Inputs

  • connection_uri (STRING, default mongodb://mongo-cluster.internal.company.com:27017): MongoDB connection string.
  • dirty_cache_percent_threshold (FLOAT, default 20.0): Percentage of dirty cache above which alerts fire.
  • target_repository (STRING, default my-org/database-operations): Target GitHub repository for logging incident issues.

Outputs

  • outputs.probe_wiredtiger_cache_status.vars.bytes_in_cache: Current bytes in memory cache.
  • outputs.probe_wiredtiger_cache_status.vars.dirty_pct: Percentage of dirty bytes in cache.
  • outputs.probe_wiredtiger_cache_status.vars.is_pressure_critical: Boolean indicating whether threshold was breached.

Quick start

  1. Configure GITHUB_TOKEN and SLACK_WEBHOOK in your Kestra namespace.
  2. Import this flow and set connection_uri to match your database endpoint.
  3. Run the flow manually to verify cache metric calculation and Slack notification delivery.
  4. Enable the periodic_wiredtiger_health_check trigger for continuous cache health monitoring.

How to extend

  • Add an automated query profiler task to inspect current operations via db.currentOp().
  • Adjust WiredTiger cache size dynamically using setParameter administrative commands after approval.
  • Route urgent alerts to PagerDuty or Opsgenie if dirty cache exceeds 30%.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.