Skip to content

geoip2 :The lookup path does not match the data #11287

@lake2

Description

@lake2

Bug Report

Describe the bug
cannot get subdivision from geoip2 filter

To Reproduce

pipeline:
    inputs:
        - name: dummy
          dummy: '{"remote_addr": "171.217.41.222"}'

    filters:
        - name: geoip2
          match: '*'
          database: GeoLite2-City.mmdb
          lookup_key: remote_addr
          # https://github.com/jclo/jgeoip
          record:
              - country      remote_addr %{country.names.zh-CN}
              - province     remote_addr %{subdivision.0.names.en}
              - city         remote_addr %{city.names.zh-CN}

    outputs:
        - name: stdout
          match: '*'

output:

{"remote_addr"=>"171.217.41.222", "country"=>"中国", "province"=>nil, "city"=>"成都"}

the province is incorrect. The compelete data is :

{
  continent: {
    code: 'AS',
    geonameId: 6255147,
    names: {
      de: 'Asien',
      en: 'Asia',
      es: 'Asia',
      fr: 'Asie',
      ja: 'アジア',
      'pt-BR': 'Ásia',
      ru: 'Азия',
      'zh-CN': '亚洲'
    }
  },
  country: {
    geonameId: 1814991,
    isoCode: 'CN',
    names: {
      de: 'China',
      en: 'China',
      es: 'China',
      fr: 'Chine',
      ja: '中国',
      'pt-BR': 'China',
      ru: 'Китай',
      'zh-CN': '中国'
    }
  },
  maxmind: undefined,
  registeredCountry: {
    geonameId: 1814991,
    isoCode: 'CN',
    names: {
      de: 'China',
      en: 'China',
      es: 'China',
      fr: 'Chine',
      ja: '中国',
      'pt-BR': 'China',
      ru: 'Китай',
      'zh-CN': '中国'
    },
    isInEuropeanUnion: false
  },
  representedCountry: undefined,
  traits: {
    isAnonymous: false,
    isAnonymousProxy: false,
    isAnonymousVpn: false,
    isAnycast: false,
    isHostingProvider: false,
    isLegitimateProxy: false,
    isPublicProxy: false,
    isResidentialProxy: false,
    isSatelliteProvider: false,
    isTorExitNode: false,
    ipAddress: '171.217.41.222',
    network: '171.217.0.0/17'
  },
  city: {
    geonameId: 1815286,
    names: {
      de: 'Chengdu',
      en: 'Chengdu',
      es: 'Chengdú',
      fr: 'Chengdu',
      ja: '成都市',
      'pt-BR': 'Chengdu',
      ru: 'Чэнду',
      'zh-CN': '成都'
    }
  },
  location: {
    accuracyRadius: 10,
    latitude: 30.6667,
    longitude: 104.0667,
    timeZone: 'Asia/Shanghai'
  },
  postal: undefined,
  subdivisions: [
    {
      geonameId: 1794299,
      isoCode: 'SC',
      names: {
        de: 'Sichuan',
        en: 'Sichuan',
        es: 'Sichuan',
        fr: 'Sichuan',
        'pt-BR': 'Sujuão',
        ru: 'Сычуань',
        'zh-CN': '四川'
      }
    }
  ]
}

Expected behavior

{"remote_addr"=>"171.217.41.222", "country"=>"中国", "province"=>"Sichuan", "city"=>"成都"}

Screenshots

Your Environment

  • Version used:
  • Configuration: 4.2.0
  • Environment name and version (e.g. Kubernetes? What version?): docker 4.2.0
  • Server type and version:
  • Operating System and version: mac m3 pro
  • Filters and plugins:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions