Skip to main content

Alert on the feed request log emergency row-cap guardrail

Free Beginner Since v1.0.0

Route the feed request log emergency-purge guardrail firing to PagerDuty, Sentry, Slack, or any external monitoring channel. When the raw log row count exceeds the configured hard cap, Benecaster trims the oldest rows to 80% of cap and publishes an admin notice — but a steady drip of guardrail events over multiple nights signals that the operator’s retention window is undersized for the show’s traffic and deserves an external alert.

Pipe these events to your on-call system so the pattern surfaces before the built-in notice is dismissed and forgotten.

Code

<?php
add_action( 'benecaster_feed_request_log_hard_cap_enforced', function ( array $ctx ): void {
    wp_remote_post( 'https://events.pagerduty.com/v2/enqueue', [
        'blocking' => false,
        'body'     => wp_json_encode( [
            'routing_key'  => getenv( 'PAGERDUTY_KEY' ),
            'event_action' => 'trigger',
            'payload'      => [
                'summary'  => sprintf(
                    'Benecaster feed-request-log guardrail deleted %d rows (was %d, cap %d)',
                    $ctx['deleted'],
                    $ctx['previous_count'],
                    $ctx['cap']
                ),
                'source'   => home_url(),
                'severity' => 'warning',
            ],
        ] ),
        'headers'  => [ 'Content-Type' => 'application/json' ],
    ] );
} );

View on GitHub →

Hooks Used