README.md in fluent-plugin-geoip-0.3.0 vs README.md in fluent-plugin-geoip-0.3.1
- old
+ new
@@ -22,18 +22,21 @@
$ sudo apt-get install libgeoip-dev
```
## Installation
-install with `gem` or `fluent-gem` command as:
+install with `gem` or td-agent provided command as:
```bash
# for fluentd
$ gem install fluent-plugin-geoip
# for td-agent
$ sudo /usr/lib64/fluent/ruby/bin/fluent-gem install fluent-plugin-geoip
+
+# for td-agent2
+$ sudo td-agent-gem install fluent-plugin-geoip
```
## Usage
```xml
@@ -43,24 +46,24 @@
# Specify one or more geoip lookup field which has ip address (default: host)
# in the case of accessing nested value, delimit keys by dot like 'host.ip'.
geoip_lookup_key host
# Specify optional geoip database (using bundled GeoLiteCity databse by default)
- geoip_database '/path/to/your/GeoIPCity.dat'
+ geoip_database "/path/to/your/GeoIPCity.dat"
# Set adding field with placeholder (more than one settings are required.)
<record>
- city ${city['host']}
- latitude ${latitude['host']}
- longitude ${longitude['host']}
- country_code3 ${country_code3['host']}
- country_code2 ${country_code2['host']}
- country ${country_code['host']}
- country_name ${country_name['host']}
- dma ${dma_code['host']}
- area ${area_code['host']}
- region ${region['host']}
+ city ${city["host"]}
+ latitude ${latitude["host"]}
+ longitude ${longitude["host"]}
+ country_code3 ${country_code3["host"]}
+ country_code2 ${country_code2["host"]}
+ country ${country_code["host"]}
+ country_name ${country_name["host"]}
+ dma ${dma_code["host"]}
+ area ${area_code["host"]}
+ region ${region["host"]}
</record>
# Settings for tag
remove_tag_prefix access.
tag geoip.${tag}
@@ -78,44 +81,61 @@
```xml
<match access.apache>
type geoip
geoip_lookup_key user1_host, user2_host
<record>
- user1_city ${city['user1_host']}
- user2_city ${city['user2_host']}
+ user1_city ${city["user1_host"]}
+ user2_city ${city["user2_host"]}
</record>
remove_tag_prefix access.
tag geoip.${tag}
</match>
```
#### Advanced config samples
-It is a sample to get friendly geo point recdords for elasticsearch with Yajl (JSON) parser.
+It is a sample to get friendly geo point recdords for elasticsearch with Yajl (JSON) parser.<br />
+
```
-<match input.access>
+<match access.apache>
type geoip
geoip_lookup_key host
<record>
# lat lon as properties
# ex. {"lat" => 37.4192008972168, "lon" => -122.05740356445312 }
- location_properties { "lat":${latitude['host']}, "lon":${longitude['host']}}
+ location_properties { "lat" : ${latitude["host"]}, "lon" : ${longitude["host"]} }
# lat lon as string
# ex. "37.4192008972168,-122.05740356445312"
- location_string ${latitude['host']},${longitude['host']}
+ location_string ${latitude["host"]},${longitude["host"]}
# lat lon as array (it is useful for Kibana's bettermap.)
# ex. [-122.05740356445312, 37.4192008972168]
- location_array [${longitude['host']},${latitude['host']}]
+ location_array [${longitude["host"]},${latitude["host"]}]
</record>
remove_tag_prefix access.
tag geoip.${tag}
</match>
```
+On the case of using td-agent2 (v1-config), it have to quote `{ ... }` or `[ ... ]` block with quotation like below.
+
+```
+<match access.apache>
+ type geoip
+ geoip_lookup_key host
+ <record>
+ location_properties '{ "lat" : ${latitude["host"]}, "lon" : ${longitude["host"]} }'
+ location_string ${latitude["host"]},${longitude["host"]}
+ location_array '[${longitude["host"]},${latitude["host"]}]'
+ </record>
+ remove_tag_prefix access.
+ tag geoip.${tag}
+</match>
+```
+
## Tutorial
#### configuration
```xml
@@ -130,12 +150,12 @@
</store>
<store>
type geoip
geoip_lookup_key host
<record>
- city ${city['host']}
- lat ${latitude['host']}
- lon ${longitude['host']}
+ city ${city["host"]}
+ lat ${latitude["host"]}
+ lon ${longitude["host"]}
</record>
remove_tag_prefix test.
tag debug.${tag}
</store>
</match>