logstash 各种时间转换
<pre name="code" class="html">日期格式转换: /***** nginx 访问日志
[elk@zjtest7-frontend config]$ cat stdin02.conf
input {
stdin {
}
}
filter {
grok {
match => ["message", "%{IPORHOST:clientip} \[%{HTTPDATE:time}\]"]
}
#date {
# match => ["time", "dd/MMM/yyyy:HH:mm:ss Z"]
#}
}
output {
stdout {
codec=>rubydebug{}
}
} [elk@zjtest7-frontend config]$ ../bin/logstash -f stdin02.conf
Settings: Default pipeline workers: 1
Pipeline main started
10.171.246.184 [22/Sep/2016:00:13:59 +0800] "GET /resources/css/base.css?06212016 HTTP/1.1" - 200 12638 "https://www.zjcap.cn/"
{
"message" => " 10.171.246.184 [22/Sep/2016:00:13:59 +0800] \"GET /resources/css/base.css?06212016 HTTP/1.1\" - 200 12638 \"https://www.zjcap.cn/\" ",
"@version" => "1",
"@timestamp" => "2016-09-22T00:54:17.154Z",
"host" => "0.0.0.0",
"clientip" => "10.171.246.184",
"time" => "22/Sep/2016:00:13:59 +0800"
} 打开时间转换:
[elk@zjtest7-frontend config]$ ../bin/logstash -f stdin02.conf
Settings: Default pipeline workers: 1
Pipeline main started
10.171.246.184 [22/Sep/2016:00:13:59 +0800] "GET /resources/css/base.css?06212016 HTTP/1.1" - 200 12638 "https://www.zjcap.cn/"
{
"message" => " 10.171.246.184 [22/Sep/2016:00:13:59 +0800] \"GET /resources/css/base.css?06212016 HTTP/1.1\" - 200 12638 \"https://www.zjcap.cn/\" ",
"@version" => "1",
"@timestamp" => "2016-09-21T16:13:59.000Z",
"host" => "0.0.0.0",
"clientip" => "10.171.246.184",
"time" => "22/Sep/2016:00:13:59 +0800"
} /***** nginx 错误日志
[elk@zjtest7-frontend config]$ cat stdin02.conf
input {
stdin {
}
}
filter {
grok {
match => ["message", "(?<time>%{YEAR}[./-]%{MONTHNUM}[./-]%{MONTHDAY}[- ]%{TIME})"]
}
#date {
# match => ["time", "yyyy/MM/dd HH:mm:ss"]
#}
}
output {
stdout {
codec=>rubydebug{}
}
} 关闭date插件:
[elk@zjtest7-frontend config]$ ../bin/logstash -f stdin02.conf
Settings: Default pipeline workers: 1
Pipeline main started
2016/09/22 08:36:55 [error] 14486#0: *55574 open() "/var/www/zjzc-web-frontEnd/apple-app-site-association"
{
"message" => " 2016/09/22 08:36:55 [error] 14486#0: *55574 open() \"/var/www/zjzc-web-frontEnd/apple-app-site-association\"",
"@version" => "1",
"@timestamp" => "2016-09-22T01:47:28.405Z",
"host" => "0.0.0.0",
"time" => "2016/09/22 08:36:55"
} 开启date插件: [elk@zjtest7-frontend config]$ cat stdin02.conf
input {
stdin {
}
}
filter {
grok {
match => ["message", "(?<time>%{YEAR}[./-]%{MONTHNUM}[./-]%{MONTHDAY}[- ]%{TIME})"]
}
date {
match => ["time", "yyyy/MM/dd HH:mm:ss"]
}
}
output {
stdout {
codec=>rubydebug{}
}
} [elk@zjtest7-frontend config]$ ../bin/logstash -f stdin02.conf
Settings: Default pipeline workers: 1
Pipeline main started
2016/09/22 08:36:55 [error] 14486#0: *55574 open() "/var/www/zjzc-web-frontEnd/apple-app-site-association"
{
"message" => " 2016/09/22 08:36:55 [error] 14486#0: *55574 open() \"/var/www/zjzc-web-frontEnd/apple-app-site-association\"",
"@version" => "1",
"@timestamp" => "2016-09-22T00:36:55.000Z",
"host" => "0.0.0.0",
"time" => "2016/09/22 08:36:55"
} /******tomcat access 日志
[elk@zjtest7-frontend config]$ cat stdin02.conf
input {
stdin {
}
}
filter {
grok {
match => ["message", "\s*%{IPORHOST:clientip}\s+\-\s+\-\s+\[%{HTTPDATE:time}\]"]
}
date {
match => ["time", "dd/MMM/yyyy:HH:mm:ss Z"]
}
}
output {
stdout {
codec=>rubydebug{}
}
} [elk@zjtest7-frontend config]$ ../bin/logstash -f stdin02.conf
Settings: Default pipeline workers: 1
Pipeline main started
10.171.246.184 - - [22/Sep/2016:07:59:04 +0800] "POST /api/notice/page HTTP/1.1" 200 1194 0.055 121.40.169.62
{
"message" => "10.171.246.184 - - [22/Sep/2016:07:59:04 +0800] \"POST /api/notice/page HTTP/1.1\" 200 1194 0.055 121.40.169.62",
"@version" => "1",
"@timestamp" => "2016-09-21T23:59:04.000Z",
"host" => "0.0.0.0",
"clientip" => "10.171.246.184",
"time" => "22/Sep/2016:07:59:04 +0800"
} /**********tomcat catalina.out 日志 elk@zjtest7-frontend config]$ cat stdin02.conf
input {
stdin {
}
} filter {
grok {
match => ["message", "(?m)\s*%{TIMESTAMP_ISO8601:time}\s+(?<Level>(\S+)).*"]
}
date {
match => ["time", "yyyy-MM-dd HH:mm:ss,SSS"]
}
}
output {
stdout {
codec=>rubydebug{}
}
} [elk@zjtest7-frontend config]$ ../bin/logstash -f stdin02.conf
Settings: Default pipeline workers: 1
Pipeline main started
2016-09-21 19:10:01,538 INFO com.zjzc.common.utils.HttpUtil
{
"message" => "2016-09-21 19:10:01,538 INFO com.zjzc.common.utils.HttpUtil",
"@version" => "1",
"@timestamp" => "2016-09-21T11:10:01.538Z",
"host" => "0.0.0.0",
"time" => "2016-09-21 19:10:01,538",
"Level" => "INFO"
} /************mysql slow log
logstash 各种时间转换的更多相关文章
- Logstash:Data转换,分析,提取,丰富及核心操作
Logstash:Data转换,分析,提取,丰富及核心操作 Logstash plugins Logstash是一个非常容易进行扩张的框架.它可以对各种的数据进行分析处理.这依赖于目前提供的超过200 ...
- [jquery]将当前时间转换成yyyymmdd格式
如题: function nowtime(){//将当前时间转换成yyyymmdd格式 var mydate = new Date(); var str = "" + mydate ...
- MySQL 日期、时间转换函数
MySQL 日期.时间转换函数:date_format(date,format), time_format(time,format) 能够把一个日期/时间转换成各种各样的字符串格式.它是 str_to ...
- java时间类型的转换/获取当前时间/将时间转换成String/将String转换成时间
对于我的脑子,我已经服气了...写了N遍的东西,就是记不住...既然记不住那就记下来... 利用java获取当前的时间(String类型,年-月-日 时:分:秒) //我要获取当前的日期 Date d ...
- inner join ,left join ,right join 以及java时间转换
1.inner join ,left join 与 right join (from 百度知道) 例表aaid adate1 a12 a23 a3表bbid bdate1 ...
- Python基本时间转换
时间转换 python中处理时间的时候,最常用的就是字符形式与时间戳之间的转换. 把最基本的转换在这里记下来 string -> timestamp import time import dat ...
- Date类型时间转换
/* 时间转换start */ public static void main(String args[]) { Date nowTime = new Date(); System.out.print ...
- unix环境C编程之日期时间转换
1.理清概念 1.1.日历时间: 含义:国际标准时间1970年1月1日00:00:00以来经过的秒数. 数据类型:time_t.实际上是long的别名. 1.2.tm结构时间: 含义:结构 ...
- php时间转换unix时间戳
本文介绍了php编程中unix时间戳转换的小例子,有关php时间转换.php时间戳的实例代码,有需要的朋友参考下. 第一部分,php 时间转换unix 时间戳实现代码. 复制代码代码示例: <? ...
随机推荐
- CoreText学习(一)Base Objects of Core Text
最近要做一个读入Word,PDF格式等的文件并且加以编辑的程序,本来以为使用Text Kit结合Text View来打开doc文件是完全没问题的,结果用了各种方法打开要么是数据是nil,要么打开的文字 ...
- [Qt] CFlip 翻页功能实现
由于需要给table制作翻页功能,所以写了一个翻页的类. 看上去总体效果感觉还是不错的,哈哈. //flip.h #ifndef CFLIP_H #define CFLIP_H #include &l ...
- 11636 - Hello World! (贪心法)
Problem A Hello World! Input: Standard Input Output: Standard Output When you first made the comput ...
- 玩转iOS开发 - 数据缓存
Why Cache 有时候.对同一个URL请求多次,返回的数据可能都是一样的,比方server上的某张图片.不管下载多少次,返回的数据都是一样的. 上面的情况会造成下面问题 (1)用户流量的浪费 (2 ...
- Win8.1OS64位oracle11安装配置及PL/SQL Developer怎样连接64位oracle
Oracle 为什么选择oracle 1.oracle可以在主流的平台上执行,而相对于sql server仅仅支持windows,而windows在wr手里攥着呢,所以你懂的.在安全性上来讲,非常多地 ...
- Linux学习笔记01:Linux下的drwxr-xr-x
1. drwxr-xr-x 第1字母:表示文件类型 d ------- 表示文件目录(directory) - ------- 表示二进制文件 l ------ ...
- linux中文乱码问题及locale详解
一.修改系统默认语言及中文乱码问题记录系统默认使用语言的文件是/etc/sysconfig/i18n,如果默认安装的是中文的系统,i18n的内容如下: LANG="zh_CN.UTF-8&q ...
- Eclipse Removing obsolete files from server 问题
今天在修改server.xml调试程序时,遇到下面这个问题,clean,重启都不好使. Removing obsolete files from server.. ...
- Set Windows IP by Batch
netsh interface ip set address name="Local" static 192.168.1.55 255.255.255.0 192.168.1.1 ...
- FineUI添加隐藏标题
添加隐藏标题 窗体前台: <x:Button ID="btnShowHideHeader" runat="server" Icon="Secti ...