ingest-geoip.asciidoc 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. [[ingest-geoip]]
  2. === Ingest Geoip Processor Plugin
  3. The GeoIP processor adds information about the geographical location of IP addresses, based on data from the Maxmind databases.
  4. This processor adds this information by default under the `geoip` field. The `geoip` processor can resolve both IPv4 and
  5. IPv6 addresses.
  6. The ingest-geoip plugin ships by default with the GeoLite2 City and GeoLite2 Country geoip2 databases from Maxmind made available
  7. under the CCA-ShareAlike 3.0 license. For more details see, http://dev.maxmind.com/geoip/geoip2/geolite2/
  8. The GeoIP processor can run with other geoip2 databases from Maxmind. The files must be copied into the geoip config directory,
  9. and the `database_file` option should be used to specify the filename of the custom database. Custom database files must be compressed
  10. with gzip. The geoip config directory is located at `$ES_HOME/config/ingest/geoip` and holds the shipped databases too.
  11. :plugin_name: ingest-geoip
  12. include::install_remove.asciidoc[]
  13. [[using-ingest-geoip]]
  14. ==== Using the Geoip Processor in a Pipeline
  15. [[ingest-geoip-options]]
  16. .Geoip options
  17. [options="header"]
  18. |======
  19. | Name | Required | Default | Description
  20. | `field` | yes | - | The field to get the ip address from for the geographical lookup.
  21. | `target_field` | no | geoip | The field that will hold the geographical information looked up from the Maxmind database.
  22. | `database_file` | no | GeoLite2-City.mmdb | The database filename in the geoip config directory. The ingest-geoip plugin ships with the GeoLite2-City.mmdb.gz and GeoLite2-Country.mmdb.gz files.
  23. | `properties` | no | [`continent_name`, `country_iso_code`, `region_name`, `city_name`, `location`] * | Controls what properties are added to the `target_field` based on the geoip lookup.
  24. | `ignore_missing` | no | `false` | If `true` and `field` does not exist, the processor quietly exits without modifying the document
  25. |======
  26. *Depends on what is available in `database_field`:
  27. * If the GeoLite2 City database is used, then the following fields may be added under the `target_field`: `ip`,
  28. `country_iso_code`, `country_name`, `continent_name`, `region_name`, `city_name`, `timezone`, `latitude`, `longitude`
  29. and `location`. The fields actually added depend on what has been found and which properties were configured in `properties`.
  30. * If the GeoLite2 Country database is used, then the following fields may be added under the `target_field`: `ip`,
  31. `country_iso_code`, `country_name` and `continent_name`. The fields actually added depend on what has been found and which properties were configured in `properties`.
  32. Here is an example that uses the default city database and adds the geographical information to the `geoip` field based on the `ip` field:
  33. [source,js]
  34. --------------------------------------------------
  35. PUT _ingest/pipeline/geoip
  36. {
  37. "description" : "Add geoip info",
  38. "processors" : [
  39. {
  40. "geoip" : {
  41. "field" : "ip"
  42. }
  43. }
  44. ]
  45. }
  46. PUT my_index/my_type/my_id?pipeline=geoip
  47. {
  48. "ip": "8.8.8.8"
  49. }
  50. GET my_index/my_type/my_id
  51. --------------------------------------------------
  52. // CONSOLE
  53. Which returns:
  54. [source,js]
  55. --------------------------------------------------
  56. {
  57. "found": true,
  58. "_index": "my_index",
  59. "_type": "my_type",
  60. "_id": "my_id",
  61. "_version": 1,
  62. "_source": {
  63. "ip": "8.8.8.8",
  64. "geoip": {
  65. "continent_name": "North America",
  66. "country_iso_code": "US",
  67. "region_name": "California",
  68. "city_name": "Mountain View",
  69. "location": { "lat": 37.386, "lon": -122.0838 }
  70. }
  71. }
  72. }
  73. --------------------------------------------------
  74. // TESTRESPONSE
  75. Here is an example that uses the default country database and adds the
  76. geographical information to the `geo` field based on the `ip` field`. Note that
  77. this database is included in the plugin download. So this:
  78. [source,js]
  79. --------------------------------------------------
  80. PUT _ingest/pipeline/geoip
  81. {
  82. "description" : "Add geoip info",
  83. "processors" : [
  84. {
  85. "geoip" : {
  86. "field" : "ip",
  87. "target_field" : "geo",
  88. "database_file" : "GeoLite2-Country.mmdb.gz"
  89. }
  90. }
  91. ]
  92. }
  93. PUT my_index/my_type/my_id?pipeline=geoip
  94. {
  95. "ip": "8.8.8.8"
  96. }
  97. GET my_index/my_type/my_id
  98. --------------------------------------------------
  99. // CONSOLE
  100. returns this:
  101. [source,js]
  102. --------------------------------------------------
  103. {
  104. "found": true,
  105. "_index": "my_index",
  106. "_type": "my_type",
  107. "_id": "my_id",
  108. "_version": 1,
  109. "_source": {
  110. "ip": "8.8.8.8",
  111. "geo": {
  112. "continent_name": "North America",
  113. "country_iso_code": "US",
  114. }
  115. }
  116. }
  117. --------------------------------------------------
  118. // TESTRESPONSE
  119. Not all IP addresses find geo information from the database, When this
  120. occurs, no `target_field` is inserted into the document.
  121. Here is an example of what documents will be indexed as when information for "93.114.45.13"
  122. cannot be found:
  123. [source,js]
  124. --------------------------------------------------
  125. PUT _ingest/pipeline/geoip
  126. {
  127. "description" : "Add geoip info",
  128. "processors" : [
  129. {
  130. "geoip" : {
  131. "field" : "ip"
  132. }
  133. }
  134. ]
  135. }
  136. PUT my_index/my_type/my_id?pipeline=geoip
  137. {
  138. "ip": "93.114.45.13"
  139. }
  140. GET my_index/my_type/my_id
  141. --------------------------------------------------
  142. // CONSOLE
  143. Which returns:
  144. [source,js]
  145. --------------------------------------------------
  146. {
  147. "found": true,
  148. "_index": "my_index",
  149. "_type": "my_type",
  150. "_id": "my_id",
  151. "_version": 1,
  152. "_source": {
  153. "ip": "93.114.45.13"
  154. }
  155. }
  156. --------------------------------------------------
  157. // TESTRESPONSE
  158. [[ingest-geoip-settings]]
  159. ===== Node Settings
  160. The geoip processor supports the following setting:
  161. `ingest.geoip.cache_size`::
  162. The maximum number of results that should be cached. Defaults to `1000`.
  163. Note that these settings are node settings and apply to all geoip processors, i.e. there is one cache for all defined geoip processors.