> For the complete documentation index, see [llms.txt](https://docs.fluentbit.io/manual/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.fluentbit.io/manual/data-pipeline/filters/geoip2-filter.md).

# GeoIP2 filter

Look up Geo data from IP.

{% hint style="info" %}
**Supported event types:** `logs`
{% endhint %}

The GeoIP2 filter lets you enrich the incoming data stream with location data from the GeoIP2 database.

The `GeoLite2-City.mmdb` database is available from [MaxMind's official site](https://dev.maxmind.com/geoip/geolite2-free-geolocation-data/).

## Configuration parameters

This plugin supports the following configuration parameters:

| Key          | Description                                                         |
| ------------ | ------------------------------------------------------------------- |
| `database`   | Path to the GeoIP2 database.                                        |
| `lookup_key` | Field name to process. Multiple `lookup_key` entries are supported. |
| `record`     | Defines the `KEY LOOKUP_KEY VALUE` triplet.                         |

## Get started

The following configuration processes the incoming `remote_addr` and appends country information retrieved from the GeoLite2 database.

{% tabs %}
{% tab title="fluent-bit.yaml" %}

```yaml
pipeline:
  inputs:
    - name: dummy
      dummy: '{"remote_addr": "8.8.8.8"}'

  filters:
    - name: geoip2
      match: '*'
      database: GeoLite2-City.mmdb
      lookup_key: remote_addr
      record:
        - country remote_addr %{country.names.en}
        - isocode remote_addr %{country.iso_code}

  outputs:
    - name: stdout
      match: '*'
```

{% endtab %}

{% tab title="fluent-bit.conf" %}

```
[INPUT]
  Name   dummy
  Dummy  {"remote_addr": "8.8.8.8"}

[FILTER]
  Name geoip2
  Match *
  Database GeoLite2-City.mmdb
  Lookup_Key remote_addr
  Record country remote_addr %{country.names.en}
  Record isocode remote_addr %{country.iso_code}

[OUTPUT]
  Name   stdout
  Match  *
```

{% endtab %}
{% endtabs %}

Each `record` parameter specifies the following triplet:

* `country`: The field name to be added to records.
* `remote_addr`: The lookup key to process.
* `%{country.names.en}`: The GeoIP2 database query.

By running Fluent Bit with this configuration, you will see the following output:

```
{"remote_addr": "8.8.8.8", "country": "United States", "isocode": "US"}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.fluentbit.io/manual/data-pipeline/filters/geoip2-filter.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `build a script that syncs our docs to a CMS` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
