Schedule icon
Request icon
Switch icon
SlackIncomingWebhook icon
If icon
Log icon

WireMock Unmatched Request & Journal Memory Sentinel

Audit WireMock request journals for unmapped contract drift, detect memory bloat, alert via Slack, and prune request history safely.

Categories
Infrastructure

Continuously monitors standalone WireMock instances in integration, staging, and CI/CD environments to detect unmapped API requests, alert on contract drift, track in-memory journal depth against capacity quotas, and optionally execute safe journal pruning to safeguard container stability.

How it works

  1. periodic_journal_audit (io.kestra.plugin.core.trigger.Schedule) triggers every 15 minutes with explicit connection and threshold inputs. Shipped disabled so initial manual verification can be performed first.
  2. probe_unmatched_requests (io.kestra.plugin.core.http.Request) invokes the WireMock Admin endpoint GET /__admin/requests/unmatched to retrieve requests recorded by the server that failed to match any configured stub definition.
  3. probe_request_count (io.kestra.plugin.core.http.Request) invokes GET /__admin/requests/count to retrieve the total count of recorded requests held in WireMock's in-memory journal.
  4. classify_journal_status (io.kestra.plugin.core.flow.Switch) evaluates probe responses:
    • CONTRACT_DRIFT_DETECTED: Fires when unmatched requests count is greater than zero, notifying #api-alerts via io.kestra.plugin.slack.notifications.SlackIncomingWebhook. If auto_reset_journal is enabled and dry_run is disabled, purge_journal_on_drift clears the request journal while leaving mock definitions intact.
    • JOURNAL_QUOTA_EXCEEDED: Fires when total recorded requests meet or exceed max_journal_capacity, dispatching a Slack warning and optionally purging the journal.
    • HEALTHY: Logs zero unmatched requests and nominal journal depth via io.kestra.plugin.core.log.Log.
  5. log_audit_complete always executes at the end of the workflow to persist execution metadata and state for observability history.
  6. The global errors block intercepts connection drops or HTTP errors to dispatch an urgent out-of-band Slack notification when WireMock is unreachable.

What you get

  • Early detection of integration contract drift when upstream microservices alter API request schemas, paths, or query parameters without corresponding mock updates.
  • JVM heap protection against unbounded in-memory request logging in high-throughput testing environments.
  • Non-destructive automated remediation: DELETE /__admin/requests clears request history logs without deleting or mutating stub mappings (DELETE /__admin/mappings is never invoked).
  • Dual safety gate control: dry_run defaults to true to ensure zero unexpected mutations during evaluation.

Who it's for

  • Platform Engineers and QA Automation Teams managing shared WireMock standalone instances in Kubernetes or Docker environments.
  • Microservice backend developers relying on mock servers for integration and end-to-end testing pipelines.
  • Site Reliability Engineers safeguarding test cluster infrastructure from memory exhaustion and OOM crashes.

Why orchestrate this with Kestra

WireMock does not natively provide threshold-based alerting or integration with collaboration platforms like Slack. Standalone shell scripts or cron jobs lack retry policies, secret masking, execution history, and stateful conditional remediation. Kestra provides declarative scheduling, robust error handling, secure credential management, and interactive execution logging.

Prerequisites

  • A running WireMock standalone instance (version 2.35.0+ or 3.x), reachable over HTTP. WireMock publishes an official open-source Docker image (wiremock/wiremock:latest) requiring no license or account.
  • A Slack incoming webhook URL configured for operational alerts.

Secrets

  • SLACK_WEBHOOK_URL: Slack incoming webhook URL used by alert_contract_drift, alert_journal_quota, and the global errors handler.

Quick start

  1. Start a local WireMock container:
    docker run -d --name wiremock-sentinel-test -p 8080:8080 wiremock/wiremock:latest
    
  2. Configure the SLACK_WEBHOOK_URL secret in your Kestra namespace.
  3. Import this blueprint into Kestra and trigger an execution with default inputs (dry_run: true).
  4. Verify that log_healthy_state logs 0 unmatched requests.
  5. Send an unmapped request to test alert routing:
    curl -X POST http://localhost:8080/api/v1/unmapped-endpoint -d '{"test": true}'
    
  6. Re-run the flow to observe alert_contract_drift dispatching to Slack.
  7. Enable periodic_journal_audit once verified.

How to extend

  • Add a downstream task using GET /__admin/requests/unmatched/near-misses to automatically compute and include diffs between unmatched calls and closest matching stubs in the Slack notification.
  • Integrate with PagerDuty via io.kestra.plugin.pagerduty.notifications.PagerDutyAlert for tier-1 CI/CD staging environments where mock downtime blocks deployments.
  • Export request volume metrics to Prometheus using io.kestra.plugin.prometheus.PushGateway for long-term capacity forecasting.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.