Skip to content

Obtain the IPIP library from OSS and enrich IP address data

You can use the data transformation feature of Simple Log Service to obtain the IPIP library from Object Storage Service (OSS) and use the library to identify the city, state, and country to which an IP address belongs.

Scenarios

  • Raw log entries

    ip: 1.2.3.4
  • Transformation rule

    python
    e_set("geo",
      geo_parse(v("ip"),
        ip_db=res_oss_file(
          endpoint='http://oss-cn-hangzhou.aliyuncs.com',
          ak_id=res_local("AK_ID"),
          ak_key=res_local("AK_KEY"),
          bucket='your bucket',
          file='ipipfree.ipdb',
          format='binary',
          change_detect_interval=200
        )
      )
    )

    The following table describes the fields in the res_oss_file function.

    fieldNote
    endpointThe endpoint that is used to access the OSS bucket.The endpoint that is used to access the OSS bucket.For more information, see Regions and endpoints.
    ak_idThe AccessKey secret that has read permissions on OSS. For security concerns, we recommend that you set the value to res_local("AK_KEY") in the Advanced Parameter Settings field. For more information, see Create a data transformation job.
    ak_keyFor security concerns, we recommend that you set the value to res_local("AK_KEY") in the Advanced Parameter Settings field.
    bucketThe OSS bucket used to store the IP address library.
    fileThe name of the IP address library that you have uploaded.
    formatThe format of the data obtained from the IP address library. Set the value to format='binary'。