Skip to content
Notifications
Clear all

Just built an alert that saves us 5 hours a week of manual log checking

1 Posts
1 Users
0 Reactions
1 Views
(@davidh)
Reputable Member
Joined: 1 week ago
Posts: 142
Topic starter   [#9211]

I've been tasked with reducing operational toil for our platform team, specifically around monitoring a set of legacy batch processing jobs that generate verbose, custom-formatted logs to Sumo Logic. The manual process involved a senior engineer running a set of pre-saved queries every Monday morning to scan for specific error patterns and anomalies across dozens of jobs, a task that typically consumed 4-5 person-hours weekly.

The breakthrough came from moving beyond simple log search and leveraging Sumo Logic's ability to create scheduled searches paired with real-time alerts, effectively automating the entire manual review. The key was constructing a `metrics` query that quantifies the issues, making alert logic far more reliable than trying to parse unstructured text directly.

Here is the core query structure I used, which identifies jobs with a failure signature (a specific error code followed by an abort statement) and then counts them per job ID:

```sql
_sourceCategory=prod/batch_processor
| parse "[job_id:*]" as job_id
| parse "[error_code: *]" as error_code
| parse "ABORT_SESSION" as abort_signal
| where error_code matches "5*" and abort_signal = "ABORT_SESSION"
| count by job_id
| fields job_id, _count
```

This query is executed as a **Scheduled Search** every Monday at 6 AM UTC. The critical piece is the **Alert** configuration on this search:

* **Condition:** `_count > 0`
* **Alert Type:** `Real-Time`
* **Time Window:** `15 minutes` (accounts for log ingestion delay)
* **Notification:** Sends a formatted email with a table of `job_id` and `_count`, and also triggers a Webhook to our internal incident management tool, creating a low-severity ticket automatically.

The alert effectively performs a state change detection: from "no failing jobs" to "one or more failing jobs." This automated triage saves the manual search time and, more importantly, ensures consistency and immediate notification.

**Cost & Performance Considerations:**
* The scheduled search runs over a 24-hour lookback period. We've added a `| head 10000` clause after the initial `where` clause as a safety measure to limit scan volume in case of a log format change or explosion.
* The query is optimized with `parse` operators early in the pipeline to leverage Sumo's indexing, significantly improving performance over `| regex` or `| if` chains.
* We evaluated using a Logs-to-Metrics rule for this, but the need to parse discrete `job_id` values made the scheduled search more appropriate.

The next iteration, which I'm currently prototyping, involves using the Sumo Logic API to fetch the alert results and automatically generate a weekly dashboard panel, providing a historical trend view alongside the alert. The main pitfall to avoid here is ensuring the alert condition is sufficiently specific to avoid noise; we had to refine the parsing logic three times to exclude false positives from pre-production environment logs that use similar message formats.


Data over dogma


   
Quote