1
0

ingest-geoip.asciidoc 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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, GeoLite2 Country and GeoLite2 ASN geoip2 databases from Maxmind made available
  7. under the CCA-ShareAlike 4.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 stored
  10. uncompressed. 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, GeoLite2-Country.mmdb and GeoLite2-ASN.mmdb files.
  23. | `properties` | no | [`continent_name`, `country_iso_code`, `region_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_iso_code`, `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
  32. were configured in `properties`.
  33. * If the GeoLite2 ASN database is used, then the following fields may be added under the `target_field`: `ip`,
  34. `asn`, and `organization_name`. The fields actually added depend on what has been found and which properties were configured
  35. in `properties`.
  36. Here is an example that uses the default city database and adds the geographical information to the `geoip` field based on the `ip` field:
  37. [source,js]
  38. --------------------------------------------------
  39. PUT _ingest/pipeline/geoip
  40. {
  41. "description" : "Add geoip info",
  42. "processors" : [
  43. {
  44. "geoip" : {
  45. "field" : "ip"
  46. }
  47. }
  48. ]
  49. }
  50. PUT my_index/_doc/my_id?pipeline=geoip
  51. {
  52. "ip": "8.8.8.8"
  53. }
  54. GET my_index/_doc/my_id
  55. --------------------------------------------------
  56. // CONSOLE
  57. Which returns:
  58. [source,js]
  59. --------------------------------------------------
  60. {
  61. "found": true,
  62. "_index": "my_index",
  63. "_type": "_doc",
  64. "_id": "my_id",
  65. "_version": 1,
  66. "_source": {
  67. "ip": "8.8.8.8",
  68. "geoip": {
  69. "continent_name": "North America",
  70. "country_iso_code": "US",
  71. "location": { "lat": 37.751, "lon": -97.822 }
  72. }
  73. }
  74. }
  75. --------------------------------------------------
  76. // TESTRESPONSE
  77. Here is an example that uses the default country database and adds the
  78. geographical information to the `geo` field based on the `ip` field`. Note that
  79. this database is included in the plugin download. So this:
  80. [source,js]
  81. --------------------------------------------------
  82. PUT _ingest/pipeline/geoip
  83. {
  84. "description" : "Add geoip info",
  85. "processors" : [
  86. {
  87. "geoip" : {
  88. "field" : "ip",
  89. "target_field" : "geo",
  90. "database_file" : "GeoLite2-Country.mmdb"
  91. }
  92. }
  93. ]
  94. }
  95. PUT my_index/_doc/my_id?pipeline=geoip
  96. {
  97. "ip": "8.8.8.8"
  98. }
  99. GET my_index/_doc/my_id
  100. --------------------------------------------------
  101. // CONSOLE
  102. returns this:
  103. [source,js]
  104. --------------------------------------------------
  105. {
  106. "found": true,
  107. "_index": "my_index",
  108. "_type": "_doc",
  109. "_id": "my_id",
  110. "_version": 1,
  111. "_source": {
  112. "ip": "8.8.8.8",
  113. "geo": {
  114. "continent_name": "North America",
  115. "country_iso_code": "US",
  116. }
  117. }
  118. }
  119. --------------------------------------------------
  120. // TESTRESPONSE
  121. Not all IP addresses find geo information from the database, When this
  122. occurs, no `target_field` is inserted into the document.
  123. Here is an example of what documents will be indexed as when information for "80.231.5.0"
  124. cannot be found:
  125. [source,js]
  126. --------------------------------------------------
  127. PUT _ingest/pipeline/geoip
  128. {
  129. "description" : "Add geoip info",
  130. "processors" : [
  131. {
  132. "geoip" : {
  133. "field" : "ip"
  134. }
  135. }
  136. ]
  137. }
  138. PUT my_index/_doc/my_id?pipeline=geoip
  139. {
  140. "ip": "80.231.5.0"
  141. }
  142. GET my_index/_doc/my_id
  143. --------------------------------------------------
  144. // CONSOLE
  145. Which returns:
  146. [source,js]
  147. --------------------------------------------------
  148. {
  149. "found": true,
  150. "_index": "my_index",
  151. "_type": "_doc",
  152. "_id": "my_id",
  153. "_version": 1,
  154. "_source": {
  155. "ip": "80.231.5.0"
  156. }
  157. }
  158. --------------------------------------------------
  159. // TESTRESPONSE
  160. [[ingest-geoip-settings]]
  161. ===== Node Settings
  162. The geoip processor supports the following setting:
  163. `ingest.geoip.cache_size`::
  164. The maximum number of results that should be cached. Defaults to `1000`.
  165. Note that these settings are node settings and apply to all geoip processors, i.e. there is one cache for all defined geoip processors.