Skip to content
All writing

Building a SIEM with the ELK Stack

How I implemented an Elastic Stack for security monitoring and observability, in line with ISO 27001.

Published
Reading time
2 minutes
Topics
Elastic, SIEM, Observability

Security information and event management (SIEM) is the part of the infrastructure that tells you what the rest of it is doing. Here is how I built a production SIEM at BSistemi on the Elastic Stack: Elasticsearch, Logstash and Kibana.

Why Elastic for a SIEM

The Elastic Stack is strong at log aggregation, search and visualisation. As an Elastic Certified Engineer, I used it for three things:

  • real-time threat detection
  • ISO 27001 compliance reporting
  • infrastructure observability

Architecture

The stack has four layers:

  • Beats — lightweight shippers collecting logs from servers, firewalls and applications
  • Logstash — the central pipeline that parses, enriches and normalises events
  • Elasticsearch — the distributed search and analytics engine
  • Kibana — dashboards, detection rules and investigation

A minimal Logstash pipeline for firewall syslog looks like this:

input {
  syslog { port => 5514 type => "firewall" }
}

filter {
  if [type] == "firewall" {
    kv { source => "message" field_split => " " value_split => "=" }
    mutate { rename => { "srcip" => "[source][ip]" "dstip" => "[destination][ip]" } }
    geoip { source => "[source][ip]" target => "[source][geo]" }
  }
}

output {
  elasticsearch {
    hosts => ["https://es01:9200"]
    data_stream => true
  }
}

Key use cases

Failed login detection

Alerts on repeated failed authentications from the same source — the classic signature of a brute-force attempt.

Anomaly detection with machine learning

Elastic machine learning jobs flag unusual traffic patterns and process executions that do not match a host’s baseline.

Compliance dashboards

Kibana dashboards built for ISO 27001 audits: who accessed what, when systems changed, and who changed them.

Lessons learned

  • Start with a clear data taxonomy — the Elastic Common Schema — to avoid log chaos.
  • Set retention policies on day one; storage costs grow faster than you expect.
  • Use index lifecycle management to move data through hot, warm and cold tiers.
PUT _ilm/policy/logs-security
{
  "policy": {
    "phases": {
      "hot":    { "actions": { "rollover": { "max_age": "7d", "max_primary_shard_size": "50gb" } } },
      "warm":   { "min_age": "30d", "actions": { "shrink": { "number_of_shards": 1 } } },
      "delete": { "min_age": "365d", "actions": { "delete": {} } }
    }
  }
}
Esc
↑ ↓ moveEnter open> shell