For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/logs/log_configuration/processors/geoip_parser.md. A documentation index is available at /llms.txt.

Overview

The geoIP parser takes an IP address attribute and extracts continent, country, subdivision, or city information (if available) in the target attribute path.

GeoIP Processor

Most elements contain a name and iso_code (or code for continent) attribute. subdivision is the first level of subdivision that the country uses such as “States” for the United States or “Departments” for France.

For example, the geoIP parser extracts location from the network.client.ip attribute and stores it into the network.client.geoip attribute:

GeoIP example

Use cases

The most common use case is detecting the location of a specific user. For example, the GeoIP Parser is used for iOS logs to provide the location of the user identified in the logs.

Before and after state of logs

Before:

{
  "network": {
    "client": {
      "ip": "203.0.113.42"
    }
  },
  "http": {
    "method": "GET",
    "url": "/checkout",
    "status_code": 200
  }
}

GeoIP Parser

Create a GeoIP Parser with source attribute network.client.ip and a target root attribute: network.client.geoip.

After processing:

{
  "network": {
    "client": {
      "ip": "203.0.113.42",
      "geoip": {
        "country": {
          "iso_code": "US",
          "name": "United States"
        },
        "city": {
          "name": "New York"
        },
        "location": {
          "lat": 40.7128,
          "lon": -74.0060
        }
      }
    }
  },
  "http": {
    "method": "GET",
    "url": "/checkout",
    "status_code": 200
  }
}

API

Use the Datadog Log Pipeline API endpoint with the following geoIP parser JSON payload:

{
  "type": "geo-ip-parser",
  "name": "Parse the geolocation elements from network.client.ip attribute.",
  "is_enabled": true,
  "sources": ["network.client.ip"],
  "target": "network.client.geoip"
}
ParameterTypeRequiredDescription
typeStringYesType of the processor.
nameStringNoName of the processor.
is_enabledBooleanNoIf the processor is enabled or not. Default: false.
sourcesArray of stringsNoArray of source attributes. Default: network.client.ip.
targetStringYesName of the parent attribute that contains all the extracted details from the sources. Default: network.client.geoip.

Further reading

Additional helpful documentation, links, and articles: