tomcat 格式化输出到kafka
cat /data/tomcat/conf/server.xml
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s" />
<Context docBase="/data/webserver/" path="/" reloadable="false" />
输出格式如下:
172.16.200.16 - - [21/Oct/2016:16:55:03 +0800] "GET /static/My97DatePicker/skin/WdatePicker.css HTTP/1.1" 304
- input {
- file {
- path => "/data/tomcat/logs/localhost_access_log.2016-10-24.txt"
- start_position => "beginning"
- type => "tomcat_access"
- }
- }
- filter {
- if [type] == "tomcat_access" {
- grok{
- match => { "message" => "%{IPORHOST:clientip} %{USER:ident} %{USER:auth} \[%{HTTPDATE:timestamp}\] \"(?:%{WORD:verb} %{URIPATHPARAM:request}(?: HTTP/%{NUMBER:httpversion})?|-)\" %{NUMBER:response}"}
- }
- }
- }
- output {
- if [type] == "tomcat_access" {
- kafka {
- bootstrap_servers => "kafka1:9092,kafka2:9092,kafka3:9092"
- topic_id => "tomcat_access.log"
- compression_type => "snappy"
- }
- }
- }
logstash 服务器端
- input {
- if [type] == "haproxy_http" {
- kafka {
- zk_connect => "zookeeper1:2181,zookeeper2:2181,zookeeper3:2181"
- topic_id => "haproxy_http.log"
- reset_beginning => false
- consumer_threads =>
- decorate_events => true
- }
- } else if [type] == "haproxy_tcp" {
- kafka {
- zk_connect => "zookeeper1:2181,zookeeper2:2181,zookeeper3:2181"
- topic_id => "haproxy_tcp.log"
- reset_beginning => false
- consumer_threads =>
- decorate_events => true
- }
- } else if [type] == "tomcat_access" {
- kafka {
- zk_connect => "zookeeper1:2181,zookeeper2:2181,zookeeper3:2181"
- topic_id => "tomcat_access.log"
- reset_beginning => false
- consumer_threads =>
- decorate_events => true
- }
- }
- }
- output {
- if [type] == "haproxy_http" {
- elasticsearch {
- hosts => ["es1:9200","es2:9200","es3:9200"]
- manage_template => true
- index => "logstash-haproxy-http.log-%{+YYYY-MM-dd}"
- }
- }
- if [type] == "haproxy_tcp" {
- elasticsearch {
- hosts => ["es1:9200","es2:9200","es3:9200"]
- manage_template => true
- index => "logstash-haproxy-tcp.log-%{+YYYY-MM-dd}"
- }
- }
- if [type] == "tomcat_access" {
- elasticsearch {
- hosts => ["es1:9200","es2:9200","es3:9200"]
- manage_template => true
- index => "logstash-tomcat_access.log-%{+YYYY-MM-dd}"
- }
- }
- }
tomcat 格式化输出到kafka的更多相关文章
- tomcat及nginx相关,格式化输出,配置及日志解析
1.https://www.cnblogs.com/jingmoxukong/p/8258837.html?utm_source=gold_browser_extension Tomcat ...
- Python自动化运维之4、格式化输出、文件对象
Python格式化输出: Python的字符串格式化有两种方式: 百分号方式.format方式 百分号的方式相对来说比较老,而format方式则是比较先进的方式,企图替换古老的方式,目前两者并存.[P ...
- Golang:将日志以Json格式输出到Kafka
在上一篇文章中我实现了一个支持Debug.Info.Error等多个级别的日志库,并将日志写到了磁盘文件中,代码比较简单,适合练手.有兴趣的可以通过这个链接前往:https://github.com/ ...
- python的print函数的格式化输出
使用print函数的时候,可以像C一样格式化输出,同时还支持参数化输出 print('%s' % ("CooMark")) print('整数|%d|' % (123)) prin ...
- python学习笔记(基础二:注释、用户输入、格式化输出)
注释 单行:# 多行:上下各用3个连续单引号或双引号 3个引号除了多行注释,还可以打印多行 举例: msg = ''' name = "Alex Li" name2 = name ...
- cout 格式化输出
一直习惯于C语言的printf函数来打印,突然有一天要用cout来打印,发现有点不适应. 原来cout也是有格式化输出的. 首先要引入头文件 #include<iostream> // 在 ...
- Python 格式化输出
转载 今天写程序又记不清格式化输出细节了--= =索性整理一下. 注意: 与C/C++ 不同的是这里括号后面不需要加' , '号. python print格式化输出. 1. 打印字符串 print ...
- Python格式化输出
今天写程序又记不清格式化输出细节了……= =索性整理一下. python print格式化输出. 1. 打印字符串 print ("His name is %s"%("A ...
- Javascript实现格式化输出
前两天看面试题,其中有一道要实现js的格式化输出,具体给出的是: Javascript实现格式化输出,比如输入999999999,输出为999,999,999 我的实现方式是 function for ...
随机推荐
- 【leetcode】Perfect Squares (#279)
Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 1 ...
- [转]js 将图片连接转换称base64格式
参考:http://blog.csdn.net/wyyfwm/article/details/45917255 我们把图像文件的内容直接写在了HTML 文件中,这样做的好处是,节省了一个HTTP 请求 ...
- ubuntu wifi连接不上或经常断网,重启就好
问题1.知道wifi密码,驱动也有,可以点击连接,总是提示"连接断开,您现在处于离线状态". 1.打开终端"ctrl+alt+T" 2.输入: sudo vim ...
- activity 、window与view的关系(下)
在activity的attacth方法中,通过policymanager 的makenewwindow来创建window 而window的具体实现是phonewindow 接下来通过setconten ...
- 服务器响应HTTP的类型ContentType大全
".*"="application/octet-stream" ".001"="application/x-001" & ...
- CentOS利用inotify+rsync实现文件同步
1.环境部署 inotify-master 10.10.6.208 inotify-slave 10.10.6.149 2.两台服务器都安装rsync yum install -y rsync 3.i ...
- Codeforces Round #FF(255) DIV2
A - DZY Loves Hash 水题,开辟一个数组即可 #include <iostream> #include <vector> #include <algori ...
- Main 程序的入口要做哪些事情
Main 程序的入口要做哪些事: 1.从主类中实例化程序(UIApplication)对象 2.如果有委托的话,从给定的类实例化委托和设置程序(UIApplication) 的代理. 3.开启主事件的 ...
- H5开发中的问题总结
最近公司做了一个出行日记的项目,里面的页面十多页,天天加班,做到吐血.总体来说,写页面的时候虽然是十多个页面,其实难度还是在每个页面的特效上.公司是易到用车,出行日记的页面在APP里有生成入口,有兴趣 ...
- 李洪强iOS经典面试题147-WebView与JS交互
李洪强iOS经典面试题147-WebView与JS交互 WebView与JS交互 iOS中调用HTML 1. 加载网页 NSURL *url = [[NSBundle mainBundle] UR ...