Skip to content
DevOps AI ToolKit
Newsletter
All prompts
AI for Logstash Difficulty: Intermediate ClaudeChatGPTCursor

Logstash GeoIP Enrichment Prompt

Design a Logstash geoip filter that enriches IP fields with geolocation and ASN data reliably — handling private IPs, database freshness, ECS field targets, and lookup failures.

Target user
Security and observability engineers enriching network logs in the Elastic Stack
Difficulty
Intermediate
Tools
Claude, ChatGPT, Cursor

The prompt

You are a senior Elastic Stack engineer who designs Logstash `geoip` enrichment for network and access logs.

I will provide:
- Sample events with the IP field(s) to enrich (client IP, source, destination, x-forwarded-for chain)
- Which enrichment you need (city/country geo, ASN/organization, both)
- The GeoIP database available (GeoLite2-City, GeoLite2-ASN, commercial) and how it's updated
- Target schema (ECS or custom)

Your job:

1. **Filter config** — produce `geoip { ... }` for each lookup: `source`, `database` path, `target` (ECS `[source][geo]`, `[source][as]`), and `fields` to keep only what you index.
2. **Multiple lookups** — chain separate geoip blocks for city and ASN, and handle multiple IP fields (source vs destination) with distinct targets.
3. **Private/invalid IPs** — guard with a conditional so RFC1918/loopback/invalid IPs skip the lookup (they can't be geolocated) instead of generating `_geoip_lookup_failure` noise; parse `x-forwarded-for` to the real client IP first if needed.
4. **ECS alignment** — map into ECS geo/as fields and ensure `[source][geo][location]` is a proper geo_point for Kibana maps; note the required index mapping/template.
5. **Failure handling** — set `tag_on_failure` and decide how unresolved IPs are treated downstream.
6. **Freshness** — recommend an update cadence and how to detect a stale/missing database at startup.

Output as: (a) the geoip filter config(s) with conditionals, (b) IP-selection and private-IP handling logic, (c) ECS field/mapping notes for geo_point, (d) sample event in/out including a private-IP skip case.

Ask which IP field is the true client and whether x-forwarded-for parsing is needed before finalizing.

Run this prompt with AI

Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.

Related prompts

More Logstash prompts & error guides

Browse every Logstash prompt and troubleshooting guide in one place.

Free download · 368-page PDF

Reading prompts? Get all 500 in one free PDF

500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.

  • 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
  • Instant PDF download — yours free, forever
  • Plus one practical AI-workflow email a week (no spam)

Single opt-in · unsubscribe anytime · no spam.