filter {
grok {
match =>[
"message","%{IPORHOST:clientip} \[%{HTTPDATE:time}\] \"%{WORD:verb} %{URIPATHPARAM:request}\?.* HTTP/%{NUMBER:httpversion}\" \- %{NUMBER:http_status_code} %{NUMBER:bytes} \"(? <http_referer>\S+)\" \"(?<http_user_agent>(\S+\s+)*\S+)\" (%{BASE16FLOAT:request_time}) (%{IPORHOST:http_x_forwarded_for}|-)",
"message" , "%{IPORHOST:clientip} \[%{HTTPDATE:time}\] \"%{WORD:verb} %{URIPATHPARAM:request} HTTP/%{NUMBER:httpversion}\" \- %{NUMBER:http_status_code} %{NUMBER:bytes} \"(? <http_referer>\S+)\" \"(?<http_user_agent>(\S+\s+)*\S+)\" (%{BASE16FLOAT:request_time}) (%{IPORHOST:http_x_forwarded_for}|-)" ]
}
geoip {
source => "http_x_forwarded_for"
target => "geoip"
database => "/usr/local/logstash-2.3.4/etc/GeoLiteCity.dat"
add_field => [ "[geoip][coordinates]", "%{[geoip][longitude]}" ]
add_field => [ "[geoip][coordinates]", "%{[geoip][latitude]}" ]
}
mutate {
convert => [ "[geoip][coordinates]", "float"]
} } /******************* zjtest7-frontend:/usr/local/logstash-2.3.4/config# cat geoip.conf
input {stdin {} } filter {
geoip {
source =>"message"
}
} output {
stdout {
codec => rubydebug{}
}
} zjtest7-frontend:/usr/local/logstash-2.3.4/config# ../bin/logstash -f geoip.conf
Settings: Default pipeline workers: 1
Pipeline main started
202.101.172.35
{
"message" => "202.101.172.35",
"@version" => "1",
"@timestamp" => "2016-09-11T02:54:11.116Z",
"host" => "0.0.0.0",
"geoip" => {
"ip" => "202.101.172.35",
"country_code2" => "CN",
"country_code3" => "CHN",
"country_name" => "China",
"continent_code" => "AS",
"latitude" => 35.0,
"longitude" => 105.0,
"location" => [
[0] 105.0,
[1] 35.0
]
}
} /*******************添加字段
zjtest7-frontend:/usr/local/logstash-2.3.4/config# cat geoip.conf
input {stdin {} } filter {
geoip {
source =>"message"
add_field => [ "[geoip][scantest]", "%{[geoip][location][0]}" ]
}
} output {
stdout {
codec => rubydebug{}
}
} zjtest7-frontend:/usr/local/logstash-2.3.4/config# ../bin/logstash -f geoip.conf
Settings: Default pipeline workers: 1
Pipeline main started
202.101.172.35
{
"message" => "202.101.172.35",
"@version" => "1",
"@timestamp" => "2016-09-11T02:57:07.832Z",
"host" => "0.0.0.0",
"geoip" => {
"ip" => "202.101.172.35",
"country_code2" => "CN",
"country_code3" => "CHN",
"country_name" => "China",
"continent_code" => "AS",
"latitude" => 35.0,
"longitude" => 105.0,
"location" => [
[0] 105.0,
[1] 35.0
],
"scantest" => 105.0
}
}

grok 添加字段的更多相关文章

  1. Sql动态添加字段的正确姿势

    如何给指定表动态添加字段? 一.创建一张表[Tbl_AutoFileds] (tableName表名,fieldName字段名,dataType数据类型,length长度  isnull 是否允许为n ...

  2. paip.解决 数据库mysql增加列 字段很慢添加字段很慢

    paip.解决 数据库mysql增加列 字段很慢添加字段很慢 #环境如下: mysql5.6    数据仅仅3w alter table xxx add column yyy int default ...

  3. MySQL添加字段和删除字段

    MySQL添加字段应该如何实现呢?这是很多刚刚接触MySQL数据库的新人都提到过的问题,下面就为您介绍MySQL添加字段和删除字段的方法,希望对您能有所启迪. MySQL添加字段: alter tab ...

  4. 向已写好的多行插入sql语句中添加字段和值

    #region 添加支款方式--向已写好的多行插入sql语句中添加字段和值 public int A_ZhifuFS(int diqu) { ; string strData = @"SEL ...

  5. mysql 添加字段、删除字段、调整字段顺序 转

    ALTER TABLE — 更改表属性添加字段: alter table `user_movement_log`Add column GatewayId int  not null default 0 ...

  6. PHPCMS v9栏目添加字段及描述编辑器修改方法

    为PHPCMS v9栏目添加字段和把描述的textarea编辑器变成fceditor编辑器的方法.如下: 1. 添加数据库字段:description1,添加位置:v9_catetory表 2. 在c ...

  7. oracle数据库的建表,删除字段,添加字段,修改字段,修改字段......

    1. 使用oracle创建一张表: SQL> create table loginuser( id ,), username ), password ), email ), descriable ...

  8. Sql 语句添加字段、修改字段类型、默认值语法

    Sql 语句添加字段 ,) not null --修改类型 alter Table bbs ) Sql 语句修改默认值 alter table 表名 drop constraint 约束名字 --删除 ...

  9. ArcEngine 添加字段

    private void AddField(IFeatureClass pFeatureClass, string name, string aliasName, esriFieldType Fiel ...

随机推荐

  1. 转:Android 测试 Appium、Robotium、monkey等框架或者工具对比

    原文地址:http://demo.netfoucs.com/u012565107/article/details/36419297# 1. Appium测试 (功能测试,用户接受度测试,黑盒测试) - ...

  2. hdu1023:卡特兰数

    火车进站问题 卡特兰数引入的例子. 卡特兰数递推公式:h(n)=h(n-1)*(4*n-2)/(n+1) 通项公式:h(n)=c(2n,n)/(n+1)... 这题需要高精度,刚好学了一下java.. ...

  3. Bubble Sort 冒泡排序

    //Bubble Sort ( O(n²)) public class TestBubbleSort { public int[] bubbleSortArray(int[] arr){ ; i &l ...

  4. c指针点滴2之比大小

    #include <stdio.h> #include <stdlib.h> void main2() { ]={,,,4.5}; ]; ]; if(p1<p2) { p ...

  5. myeclipse实现Servlet实例(1) 通过继承servlet接口实现

    1.在myeclipse新建web project,配置Tomcat(在myeclipse的Window--preferences) 2.然后在src新建servlet文件( 此处放在com.tsin ...

  6. Eclipse调试时出现source not found的问题

    Eclipse中新加载了一个java项目,打断点debug时,Debug小窗口显示source not found,网搜找到了解决办法,在此记录一下. 原文地址:http://blog.csdn.ne ...

  7. jps命令使用

    jps工具 jps(Java Virtual Machine Process Status Tool)是JDK 1.5提供的一个显示当前全部java进程pid的命令,简单有用,很适合在linux/un ...

  8. LRU Cache的简单c++实现

    什么是 LRU LRU Cache是一个Cache的置换算法,含义是“最近最少使用”,把满足“最近最少使用”的数据从Cache中剔除出去,并且保证Cache中第一个数据是最近刚刚访问的,因为这样的数据 ...

  9. 学习selenium所须要具备的技术

    学习selenium所须要具备的知识或技术 1.selenium进行的自己主动化測试是基于ui层面的,所以html,css,javascript基本上是不可缺少的,至于javascript,有非常多的 ...

  10. c++11 : range-based for loop

    0. 形式 for ( declaration : expression ) statement 0.1 根据标准将会扩展成这样的形式: 1   { 2     auto&& __ra ...