github.com/GuanceCloud/cliutils@v1.1.21/pipeline/ptinput/funcs/md/geoip.en.md (about)

     1  ### `geoip()` {#fn-geoip}
     2  
     3  Function prototype: `fn geoip(ip: str)`
     4  
     5  Function description: Append more IP information to IP. `geoip()` will generate additional fields, such as:
     6  
     7  - `isp`: operator
     8  - `city`: city
     9  - `province`: province
    10  - `country`: country
    11  
    12  Function parameters:
    13  
    14  - `ip`: The extracted IP field supports both IPv4 and IPv6
    15  
    16  Example:
    17  
    18  ```python
    19  # input data: {"ip":"1.2.3.4"}
    20  
    21  # script
    22  json(_, ip)
    23  geoip(ip)
    24  
    25  # result
    26  {
    27    "city"     : "Brisbane",
    28    "country"  : "AU",
    29    "ip"       : "1.2.3.4",
    30    "province" : "Queensland",
    31    "isp"      : "unknown"
    32    "message"  : "{\"ip\": \"1.2.3.4\"}",
    33  }
    34  ```