Skip to content
Please update to the latest release 0.77.3 to address Multiple CVEs.
Server.Enrichment.GeoIP

Server.Enrichment.GeoIP

A utility artifact that enriches an IP address with country, state, and city information from a MaxMind GeoIP database.

You will need to provide a valid licensed GeoIP database.

You can obtain a free to use (gratis but not libre) database from https://www.maxmind.com/ or you can pay for their more accurate offerings.

After storing the database file somewhere on your server, you should store the database path in the server metadata under the key “GeoIPDB” (for example /usr/shared/GeoLite2-City_20210803/GeoLite2-City.mmdb)

As an alternative to calling this artifact, you can import this artifact to gain access to the utility functions (or just copy them into your own artifact).


name: Server.Enrichment.GeoIP
description: |
  A utility artifact that enriches an IP address with country, state,
  and city information from a MaxMind GeoIP database.

  You will need to provide a valid licensed GeoIP database.

  You can obtain a free to use (gratis but not libre) database from
  https://www.maxmind.com/ or you can pay for their more accurate
  offerings.

  After storing the database file somewhere on your server, you should
  store the database path in the server metadata under the key
  "GeoIPDB" (for example
  `/usr/shared/GeoLite2-City_20210803/GeoLite2-City.mmdb`)

  As an alternative to calling this artifact, you can import this
  artifact to gain access to the utility functions (or just copy them
  into your own artifact).

export: |
  LET DB = server_metadata().GeoIPDB
  LET Country(IP) = geoip(db=DB, ip=IP).country.names.en
  LET State(IP) = geoip(db=DB, ip=IP).subdivisions[0].names.en
  LET City(IP) = geoip(db=DB, ip=IP).city.names.en

parameters:
  - name: IP
    description: An IP to lookup

type: SERVER

sources:
  - query: |
      SELECT Country(IP=_value) AS Country,
             State(IP=_value) AS State,
             City(IP=_value) AS City
      FROM foreach(row=IP)