Skip to main content

Geo-Enrich Events

This guide shows how to use the GeoIP node to add geographic information (country, city) to events that contain an IP address field.

TypeStream bundles a MaxMind GeoLite2 database -- no external API keys or services needed.

Prerequisites

  • TypeStream installed and running
  • A topic with records containing an IP address field (the demo web_visits topic works)

Enrich with GeoIP

The GeoIP node takes two parameters:

  • ipField -- the name of the field containing the IP address
  • outputField -- the name of the new field to add with the geographic result
cat /dev/kafka/local/topics/web_visits | enrich { visit -> http "https://api.country.is/#{$visit.ip_address}" }
note

The CLI DSL uses the enrich operator with a block expression for HTTP-based enrichment. The built-in GeoIP node is available in config-as-code and the GUI.

Schema behavior

The GeoIP node validates at compile time that the ipField exists in the input schema. It adds the outputField (type: string) to the output schema, so downstream nodes can reference it.

For example, you can chain a filter after enrichment:

{
"id": "filter-1",
"filter": {
"expression": ".country_code == \"US\""
}
}

See also