Webhook icon
Script icon
UploadFiles icon
Switch icon
Log icon
Fail icon

Catch new error patterns in the logs right after a deploy

Compare log patterns before and after a deploy with Drain3 in Kestra. Flag brand new error templates and surging warnings, signal a rollback.

Categories
AIInfrastructure

After a deploy, error counts look normal more often than they should: the new failure is one message among thousands, or it is logged at INFO. What changes reliably is the shape of the logs, because a new code path logs a message that did not exist before. This flow uses Drain3 to turn raw lines into templates (GET /api/cart/<NUM> 200 in <NUM> from <IP>), then compares the hour before the deploy with the minutes after it:

  • New templates: seen only after the deploy, at least min_new_count times. These fail the run so the pipeline can roll back.
  • Surging templates: known templates whose share of lines grew by surge_ratio or more. These are logged as a warning.

It needs no secrets. A demo generator writes 6,000 lines before and 2,000 after the deploy for three scenarios.

How it works

  1. diff_patterns (io.kestra.plugin.scripts.python.Script, drain3==0.9.11) masks IPs, regions and numbers, mines templates from the before window, keeps mining on the after window and compares counts per template. It writes pattern_diff.md and outputs verdict, new and surging.
  2. publish_diff (io.kestra.plugin.core.namespace.UploadFiles) keeps the report under deploys/<service>/.
  3. verdict (io.kestra.plugin.core.flow.Switch): CLEAN logs, SURGE warns, and NEW_PATTERN fails with the templates.
  4. after_deploy (io.kestra.plugin.core.trigger.Webhook).

Quick start

scenario Templates Result
CLEAN 4 No new or surging pattern
NEW_ERROR (default) 5 Failed: ERROR tax service returned null rate for region=<REGION> order=<NUM> appeared 36 times, only after the deploy
SURGE 4 Warning: WARN payment provider slow response <NUM> for order=<NUM> went from 4.9% to 33.4% of lines

The new error is 1.8% of the lines after the deploy, below most error-rate alerts. As a template, it stands out at once.

Using it with your logs

  • Replace the generator with two exports, one window before the deploy and one after, from Loki (logcli query), Elasticsearch or CloudWatch Logs Insights.
  • Add masking rules for your own identifiers, such as UUIDs, emails or tenant ids. Without them, every value becomes its own template.
  • Persist the miner state (drain3 supports file persistence) in namespace files to compare against a longer baseline.

Inputs

  • service (STRING), scenario (SELECT, demo only).
  • surge_ratio (FLOAT, default 5.0), min_new_count (INT, default 3).

Expected outputs

  • outputs.diff_patterns.vars: verdict, templates, new_count, new, surging.
  • Namespace file deploys/<service>/log-patterns-<execution>.md.

Links

This blueprint was created by zkasuran.

See How

New to Kestra?

Use blueprints to kickstart your first workflows.