oldboy es和logstash
logstash:
input:https://www.elastic.co/guide/en/logstash/current/input-plugins.html
input {
file {
path =>"/var/log/messages"
type => "system"
start_position =>"beginning"
}
file {
path =>"/var/log/elasticsearch/alex.log"
type => "es-error"
start_position =>"beginning"
}
}
output:https://www.elastic.co/guide/en/logstash/current/output-plugins.html
output {
if [type] == "system" {
elasticsearch {
hosts=>["192.168.1.1:9200"]
index=>"system-%{+YYYY.MM.dd}"
}
}
if [type] == "es-error" {
elasticsearch {
hosts=>["192.168.1.1:9200"]
index=>"es-error-%{+YYYY.MM.dd}"
}
}
}
收集java报错堆栈信息,(多行报错)
需要codec plugin
input {
stdin {
codec => multiline {
pattern => "regexp"
negate => "true or false"
what =>"previous or next"//合并到上一行还是下一行
}
}
}
例子1:
input {
stdin {
codec => multiline {
pattern => "^\["
negate => "true"
what =>"previous"
}
}
}
output {
stdout {
codec => "rubydebug"
}
}
案例2:
input {
file {
path =>"/var/log/messages"
type => "system"
start_position =>"begining"
}
file {
path =>"/var/log/elasticsearch/alex.log"
type => "es-error"
start_position =>"beginning"
codec => multiline {
pattern => "^\["
negate => "true"
what =>"previous"//合并到上一行还是下一行
}
}
}
output {
if [type] == "system" {
elasticsearch {
hosts=>["192.168.1.1:9200"]
index=>"system-%{+YYYY.MM.dd}"
}
}
if [type] == "es-error" {
elasticsearch {
hosts=>["192.168.1.1:9200"]
index=>"es-error-%{+YYYY.MM.dd}"
}
}
}
syslog的监听:
logstash-syslog.conf
input {
syslog {
type => "system-syslog"
host => "192.168.56.11"
port => "514" //开启一个进程,并打开514端口
}
}
output {
stdout {
codec => "rubydebug"
}
}
vim /etc/rsyslog.conf
*.* @@192.168.56.11:514 //把所有日志发送到192.168.56.11的514端口
logstash监听tcp端口:
logstash-tcp.conf
input {
tcp {
host => "192.168.56.11"
port => "6666" //监听了6666端口
}
}
output {
stdout {
codec => "rubydebug"
}
}
如果我们用nc,就可以收到
nc 192.168.56.11 6666 < /etc/resolv.conf
或者:echo "alex" > /dev/tcp/192.168.56.11/6666
logstash收集日志和grok
filter块
vim logstash-grok.conf
input {
stdin { }
}
filter {
grok {
match => { "message" => "%{IP:client} %{WORD:method} %{URIPATHPARAM:request} %{NUMBER:bytes} %{NUMBER:duration}" }
}
}
output {
stdout {
codec => "rubydebug"
}
}
logstash收集slowlog日志和grok
logstash-mysql-slow.conf
input {
file {
path =>"/root/slow.log"
type => "msyql-slowlog"
codec => multiline {
pattern =>"^# User@Host:"
negate => true
what => "previous"
}
}
}
filter {
//太多了 没抄完,中间grok
}
output{
stdout =>"rubydebug"
}
logstash 传送到redis,然后另一个logstash从redis取:
input {
stdin{}
}
output {
redis {
host =>"192.168.56.11"
port => "6379"
db =>"6"
data_type=>"list"
key=>"demo"
}
}
在redis中 keys * 可以看到demo
然后 LINDEX demo -1 就能取出来。
llen demo 能知道这个列表里有多少条数据
最后在其他logstash读出来:
input {
redis {
host =>"192.168.56.11"
port => "6379"
db =>"6"
data_type=>"list"
key=>"demo"
}
}
output{
elasticsearch {
hosts=>["192.168.1.1:9200"]
index=>"redis-demo-%{+YYYY.MM.dd}"
}
}
oldboy es和logstash的更多相关文章
- es redis logstash 日志收集系统排错
用logstash收集日志并发送到redis,然后通过logstash取redis数据写入到es集群,最近kibana显示日志总是中断,日志收集不过来,客户端重启发现报错: Failed to sen ...
- es,logstash各版本对应要求的JDK版本,操作系统对应示意图
官网地址:https://www.elastic.co/cn/support/matrix
- Elasticsearch + logstash中文指南
http://kibana.logstash.es/content/logstash/examples/nginx-access.html http://es.xiaoleilu.com/030_Da ...
- Logstash日志搜集
软件准备: logstash-2.1.0.zip elasticsearch-2.1.0.zip kibana-4.3.0-windows.zip Redis-x64-2.8.2104.msi 下载地 ...
- ELK-filebeat收集日志到Kafka,并转存ES
https://blog.51cto.com/tryingstuff/2052271 场景需求 在有些不需要安装java环境的服务器如Nginx,php等为主的web 应用可以使用filebeat来对 ...
- 第四章 logstash - type与tags属性
参考:http://kibana.logstash.es/content/logstash/plugins/input/stdin.html 最常用法: input { stdin { tags =& ...
- ELK学习笔记之CentOS 7下ELK(6.2.4)++LogStash+Filebeat+Log4j日志集成环境搭建
0x00 简介 现在的公司由于绝大部分项目都采用分布式架构,很早就采用ELK了,只不过最近因为额外的工作需要,仔细的研究了分布式系统中,怎么样的日志规范和架构才是合理和能够有效提高问题排查效率的. 经 ...
- Logstash 算术运算操作
需求:input为json,output为ES,需使用filter提取json中的某个字段,并执行加法.加法.乘法等算法操作 思路:mutate过滤器+ruby过滤器实现 避坑:根据ES及Logsta ...
- 一个logstash引发的连环案,关于logstash提示:Reached open files limit: 4095, set by the 'max_open_files' option or default, files yet to open: 375248
不多说,直接上问题.版本logstash-2.4.0,启动后提示错误: !!! Please upgrade your java version, the current version '1.7.0 ...
随机推荐
- Vim使用技巧:撤销与恢复撤销
在使用VIM的时候,难免会有输错的情况,这个时候我们应该如何撤销,然后回到输错之前的状态呢?答案:使用u(小写,且在命令模式下)命令. 但如果有时我们一不小心在命令模式下输入了u,然后刚输入的一大片代 ...
- Python包中__init__.py作用
在创建python包的过程中,IDE都会在包根目录下创建一个__init__.py文件,该Python文件默认是空的.目录结构如下: Pycharm下的package树结构: 在Finder中的目录结 ...
- NSE: known a priori estimate
1. Leray-Hopf $u\in L^\infty(0,T;L^2(\bbR^3))\cap L^2(0,T;H^1(\bbR^3))$. See [Leray, Jean. Sur le mo ...
- Mathematica 求出解后代入变量
Solve[2 x - 3 == 0, x] x = x //. %[[1]]
- iTOP-开发板-MiniLinux-C程序调用shell命令
本文档介绍的是在 linux 系统环境下 linux-C 调用 shell 命令实验步骤,和文档压缩包一起的“iTOP-开发板-MiniLinux-SHELL_V1.0.zip”是 c 程序源码.Li ...
- 【easy】234. Palindrome Linked List
ques: 判断一个链表是否回文 Could you do it in O(n) time and O(1) space? method:先将链表分为两部分,将后半部分反转,最后从前往后判断是否相等. ...
- 【原创】大数据基础之Drill(2)Drill1.14+Hive2.1.1运行
问题 Drill最新版本是1.14,从1.13开始Drill支持hive的版本升级到2.3.2,详见1.13的release notes The Hive client for Drill is up ...
- 第一章:OEL6.8之虚拟机安装
一.在 Windows 上安装 VMware Workstation 具体安装请参考<VMware Workstation 15 Pro 永久激活密钥 下载> 二.创建虚拟机 1:选 ...
- Linux系统xinetd服务启动不了
Linux系统xinetd服务启动不了 xinetd服务时发现xinetd服务启动不了,并出现错误提示xinetd:unrecognized service,当出现这个错误提示的时候说明系统未安装xi ...
- Penettation testing with the bush Shell
1. Network Reconnaissance first we can use the command to gather the site information by whois eg : ...