Turning noisy IDS logs into actionable alerts: a rule‑based workflow

Intrusion Detection Systems (Snort, Suricata, Zeek) churn out terabytes of raw events every day. Most of those are just port scans, mis‑configured clients, or protocol quirks. The real pain point is turning that noise into something a SOC can act on without drowning in alerts.

Below is a hands‑on, rule‑based playbook that plugs into the SIEMs you already run (ELK, Loki, cloud‑native) and trims alert fatigue without losing coverage.


1. Define the Threat Landscape

Before you write a single rule, map out the attack surface.

Asset Typical Attack Vectors Relevant IDS Signatures
Web API SQL injection, RCE, DoS OWASP Top‑10 signatures
SSH Brute‑force, credential stuffing “SSH login attempts”
SMB Lateral movement, ransomware “SMB Exploit”

Use the NIST CSF “Identify” function to flag mission‑critical assets. That list tells you which severity levels matter most later.


2. Normalize and Enrich Logs

IDS output is a mess. Normalization makes rule writing predictable.

# Convert Suricata JSON to a flat CSV
suricata-update --disable
suricata -c /etc/suricata/suricata.yaml -l /var/log/suricata --set log-dir=/tmp
jq -r '. | [
  .timestamp,
  .event_type,
  .src_ip,
  .src_port,
  .dest_ip,
  .dest_port,
  .proto,
  .signature_id,
  .signature
] | @csv' /tmp/suricata.log | gzip > /var/log/ids/normalized.csv.gz

Enrichment:

  • GeoIP – country, ASN
  • Threat intel – cross‑check IPs against AlienVault OTX or similar
  • Host metadata – map IP to hostname, role, or owner

Put the enriched data in a searchable index (Elasticsearch, Loki, or a small relational DB if the volume is low).


3. Build a Baseline

Noise follows patterns. A baseline lets you flag deviations.

  1. Statistical thresholds

    • Port scan: > 100 unique destination ports from one source in 5 min.
    • SSH brute‑force: > 20 failed logins from one IP in 10 min.
  2. Behavioral baselines

    • Light ML (Isolation Forest) to learn normal traffic per host.
    • Flag outliers beyond the 95th percentile in packet size or connection duration.

Store metrics in a time‑series DB (Prometheus) and expose them to the rule engine.


4. Rule Engine Architecture

A rule engine sits between the log source and the alerting system. Two open‑source options:

Engine Strength Example
Wazuh Tight integration with Suricata/Snort Custom rules in /var/ossec/etc/rules/local_rules.xml
OpenSCAP Compliance‑centric, extensible oscap xccdf eval --profile

We’ll use Wazuh because it already parses Suricata/Snort alerts and supports rule chaining.

4.1. Rule Syntax

<group name="custom-scan-rules">
  <rule id="100100" level="5">
    <if_sid>200001</if_sid> <!-- Suricata port scan signature -->
    <description>Suspicious port scan from external IP</description>
    <options>no_full_log</options>
    <field name="src_ip">10.0.0.0/8</field> <!-- Exclude internal traffic -->
  </rule>
</group>

Trade‑off:

  • Granular rules cut false positives but cost maintenance.
  • Broad rules catch more but can flood the SIEM.

Keep rules in a Git repo, run them through CI/CD against a replayed log set before pushing to prod.


5. Alert Enrichment and Correlation

When a rule fires, enrich the alert before it hits the triage queue.

# Enrich with threat intel
curl -s "https://otx.alienvault.com/api/v1/indicators/IPv4/${src_ip}/passive_dns" | jq '.data[] | .hostname'

Correlation steps:

  1. Event chaining

    • If a port scan is followed by a successful SSH login from the same IP within 30 min, elevate to “Potential Compromise”.
  2. Cross‑system correlation

    • Match IDS alerts with firewall logs (iptables, Cloudflare) to confirm the traffic was allowed.

Store correlated alerts in an index (ids_alerts) and push them to a ticketing system via webhook.


6. Triage Workflow

Severity Action Tool
3 (Low) Review in SIEM UI Kibana
4 (Medium) Auto‑create JIRA ticket JIRA API
5 (High) Escalate to SOC PagerDuty webhook

A simple policy file maps rule IDs to severity:

rules:
  100100: 3
  100200: 4
  100300: 5

A lightweight Python script reads the rule ID from the alert payload and assigns the proper severity.


7. Continuous Improvement

  1. Feedback loop

    • After an alert is investigated, tag it as “false positive” or “true positive” in the ticketing system.
    • Feed that label back into the rule engine to tweak thresholds.
  2. Rule rotation

    • Remove or downgrade rules that churn out false positives.
    • Add new rules when a new attack vector appears (e.g., a CVE in a public API).
  3. Metrics

    • Track alert volume, MTTD, MTTR.
    • Publish a quarterly report to stakeholders.

8. Common Pitfalls and Troubleshooting

Symptom Likely Cause Fix
Alerts never fire Rule syntax error Validate XML with xmllint
Too many false positives Threshold too low Raise threshold or add exclusion fields
Alerts missing critical events Baseline too strict Re‑train baseline with a longer window
Alert latency > 5 min Log ingestion lag Scale log shippers (Filebeat) or increase Kafka partitions

Use suricata -T to test signatures before deployment. For Wazuh, run wazuh-control test to validate rule files.


9. Real‑World Example

An API gateway in a microservices stack was blowing up with 12,000 Suricata alerts per day—mostly benign port scans from internal devs. By:

  1. Excluding internal IP ranges (<field name="src_ip">10.0.0.0/8</field>),
  2. Raising the port‑scan threshold to 200 ports per 10 min,
  3. Correlating with failed API auth logs,

the team cut noise by 85 % and surfaced three high‑severity alerts a week that uncovered a misconfigured service exposed to the internet.


10. Resources

See also