我的grok过滤器(工作)的一部分抓取以下两个字段:
%{NUMBER:XCent}%{NUMBER:YCent}
这是拉特,长点.
我正在尝试添加一个位置引脚,但是当我在配置文件上使用--debug标志时,仍然会出现配置失败
在我到达本节之前,我的所有配置都有效.
if [XCent] and [YCent] {
mutate {
add_field => {
"[location][lat]" => "%{XCent}"
"[location][lon]" => "%{YCent}"
}
}
mutate {
convert => {
"[location][lat]" => "float"
"[location][lon]" => "float"
}
}
mutate {
convert => {"[location]", "geo_point"}
}
}
Run Code Online (Sandbox Code Playgroud)
我的想法是,这基本上是logstash 1.4的弹性文档所建议的
https://www.elastic.co/guide/en/elasticsearch/reference/1.4/mapping-geo-point-type.html
编辑:找到更好的方法在过滤器,更新的代码中应用配置.
我有以下形式的nginx错误日志: -
2015/09/30 22:19:38 [错误] 32317#0:*23 [lua] responses.lua:61:handler():Cassandra错误:UNIQUE检查错误:Cassandra错误:连接被拒绝,客户端:127.0. 0.1,server :, request:"POST/consumers/HTTP/1.1",host:"localhost:8001"
如上所述,我能够解析这些日志.
我的过滤器配置如下: -
filter {
grok {
match => {
"message" => [
"%{DATESTAMP:mydate} \[%{DATA:severity}\] (%{NUMBER:pid:int}#%{NUMBER}: \*%{NUMBER}|\*%{NUMBER}) %{GREEDYDATA:mymessage}",
"%{DATESTAMP:mydate} \[%{DATA:severity}\] %{GREEDYDATA:mymessage}",
"%{DATESTAMP:mydate} %{GREEDYDATA:mymessage}"
]
}
add_tag => ["nginx_error_pattern"]
}
if ("nginx_error_pattern" in [tags]) {
grok {
match => {
"mymessage" => [
"server: %{DATA:[request_server]},"
]
}
}
grok {
match => {
"mymessage" => [
"host: \"%{IPORHOST:[request_host]}:%{NUMBER:[port]}\""
]
}
}
grok {
match => {
"mymessage" => …Run Code Online (Sandbox Code Playgroud) 我想使用Elastic Stack进行日志聚合以从10台计算机中获取日志。我希望在10台计算机上安装Filebeat,并从每台计算机上获取日志,然后将其发送到安装在单独计算机上的集中式Logstash服务器。在单独的计算机上,安装了Logstash Elasticsearch&Kibana。我需要Logstash,因为我想在使用Beats收集日志后进行数据的处理和解析。
按照这种体系结构,我面临一些标识和解析日志的问题。如何使Logstash标识一次从多个Beats服务器收集日志?我可以在logstash-beats插件中指定多个主机,以便Logstash一次解析10台计算机上的所有日志吗?
我是否应该在所有10台机器中定义单独的document_type作为Filebeat Configuration的一部分,以后可以在Logstash中利用它,以便在过滤器插件中定义多种类型(使用通配符-tomcat *)。
单机设置的示例Filebeat配置:-
################### Filebeat Configuration Example #########################
############################# Filebeat ####################################
filebeat:
prospectors:
-
paths:
- /location/to/file/catalina.out
document_type: tomcat1
scan_frequency: 5s
input_type: log
output:
logstash:
hosts: ["<host-of-the-machine-on-which-logstash-is-installed>:5044"]
console:
pretty: true
shipper:
logging:
files:
rotateeverybytes: 10485760 # = 10MB
Run Code Online (Sandbox Code Playgroud)
这种设置类型将在所有10台机器上完成,其中document_type的值仅会更改。
单机的Logstash示例配置:-
input {
beats {
host => "ip/of/machine/1"
port => 5044
}
}
filter {
........................
........................
........................
}
output{
elasticsearch {
hosts => "localhost:9200"
index => "logs-%{+YYYY.MM.dd}"
}
stdout { codec => rubydebug }
} …Run Code Online (Sandbox Code Playgroud) elasticsearch logstash kibana-4 logstash-configuration filebeat
我有以下类型的json与我一起使用filebeat在弹性搜索中转储 {"@timestamp":"2017-02-10T06:30:51.424Z","beat":{"hostname":"myhostname","name":"mydevice-logger","version":"5.2.0"},"fields":{"device_type":"mydevice","env":"staging"},"metricset":{"module":"system","name":"cpu","rtt":211},"system":{"cpu":{"cores":4,"idle":{"pct":0.000000},"iowait":{"pct":0.000000},"irq":{"pct":0.000000},"nice":{"pct":0.000000},"softirq":{"pct":0.000000},"steal":{"pct":0.000000},"system":{"pct":0.000000},"user":{"pct":0.000000}}},"tags":["automata","box"],"type":"metricbeat-test-log"}
我的logstash(版本5.1.1)配置包含,输入,过滤器和输出如下 -
input {
beats {
port => 5046
codec => json
}
}
filter {
if ...{}
else if [type] == "metricbeat-test-log" {
date {
match => ["@timestamp", "ISO8601"]
}
}
}
}
output {
if ...{}
else if [type] == "metricbeat-test-log" {
stdout { codec => rubydebug }
}
}
Run Code Online (Sandbox Code Playgroud)
类型是正确的但是日期过滤器不起作用.在@timestamp最后还以当前的时间戳始终.我想用@timestampjson中的原始礼物替换它.
elasticsearch logstash logstash-configuration filebeat metricbeat
我正在使用 Logstash 处理一些流数据。现在我在使用条件标记数据时遇到了一个问题。
如果我在logstash配置中写下以下内容
if [myfield] == "abc"{ mutate { add_tag => ["mytag"] } }
else { mutate { add_tag => ["not_working"] } }
Run Code Online (Sandbox Code Playgroud)
一切正常,但现在我想使用一个列表
if [myfield] is in ["abc"]{ mutate { add_tag => ["mytag"] } }
else { mutate { add_tag => ["not_working"] } }
Run Code Online (Sandbox Code Playgroud)
并且只得到一个 not_working 标签。
有什么建议?提前致谢!
我试图让logstash解析来自我的ELB日志文件的HTTP get请求中的键值对.
请求字段看起来像
http://aaa.bbb/get?a=1&b=2
我想那里是一个领域a,并b在上面的日志行,而我无法计算出来.
我的logstash conf(为清晰起见而格式化)低于该值不会加载任何其他关键字段.我假设我需要拆分URI的地址部分,但还没想出来.
input {
file {
path => "/home/ubuntu/logs/**/*.log"
type => "elb"
start_position => "beginning"
sincedb_path => "log_sincedb"
}
}
filter {
if [type] == "elb" {
grok {
match => [ "message", "%{TIMESTAMP_ISO8601:timestamp}
%{NOTSPACE:loadbalancer} %{IP:client_ip}:%{NUMBER:client_port:int}
%{IP:backend_ip}:%{NUMBER:backend_port:int}
%{NUMBER:request_processing_time:float}
%{NUMBER:backend_processing_time:float}
%{NUMBER:response_processing_time:float}
%{NUMBER:elb_status_code:int}
%{NUMBER:backend_status_code:int}
%{NUMBER:received_bytes:int} %{NUMBER:sent_bytes:int}
%{QS:request}" ]
}
date {
match => [ "timestamp", "ISO8601" ]
}
kv {
field_split => "&?"
source => "request"
exclude_keys => ["callback"]
}
}
}
output …Run Code Online (Sandbox Code Playgroud) 我在 Windows 7 机器上本地安装了 Logstash 和 Elasticsearch。我在 Logstash 中安装了logstash-input-jdbc。
我在 MySql 数据库中有数据,我使用 Logstash 将这些数据发送到 Elasticsearch,以便我可以生成一些报告。
执行此操作的 Logstash 配置文件。
input {
jdbc {
jdbc_driver_library => "C:/logstash/lib/mysql-connector-java-5.1.37-bin.jar"
jdbc_driver_class => "com.mysql.jdbc.Driver"
jdbc_connection_string => "jdbc:mysql://127.0.0.1:3306/test"
jdbc_user => "root"
jdbc_password => ""
statement => "SELECT * FROM transport.audit"
jdbc_paging_enabled => "true"
jdbc_page_size => "50000"
}
}
output {
elasticsearch {
hosts => ["localhost:9200"]
index => "transport-audit-%{+YYYY.mm.dd}"
}
}
Run Code Online (Sandbox Code Playgroud)
这有效,Logstash 在我运行时将数据发送到 Elasticsearch:
bin\logstash agent -f \logstash\conf\01_input.conf
Run Code Online (Sandbox Code Playgroud)
这是该命令的响应
io/console not supported; tty will not be …Run Code Online (Sandbox Code Playgroud) 我使用的是logstash的RPM安装。因此,logstash 作为 Linux 服务运行。我想调试管道并需要查看其中的内容
output {
stdout { codec => rubydebug }
}
Run Code Online (Sandbox Code Playgroud)
但是,由于 Logstash 是作为服务启动的 - 您在哪里/如何查看标准输出?有没有办法将 rubydebug 的内容通过管道传输到日志文件中/var/log/logstash/logstash.log?
内森
我有两个URL(由于安全问题,我将使用虚拟解释)
a> https://xyz.company.com/ui/api/token
b> https://xyz.company.com/request/transaction?date=2016-01-21&token=<tokeninfo>
Run Code Online (Sandbox Code Playgroud)
当您点击'a'中提到的url时,它将生成一个令牌,让它成为一个包含16个字符的字符串
然后该令牌应该用于在令牌参数中进行点'b'的第二次请求
The second url response is important to me i.e is a JSON response, I need
to filter the json data and extract required data and output it to standard
output and elastic search.
Run Code Online (Sandbox Code Playgroud)
有没有办法在logstash中使用插件"http_poller"或任何其他插件.
注意:这些请求URL应该一个接一个地执行,即点"a"url应该首先执行,并且"b"url应该在接收到新令牌后执行.
请建议.
[2018-02-12 09:15:43] development.WARNING: home page
[2018-02-12 09:15:43] development.INFO: home page
[2018-02-12 10:22:50] development.WARNING: home page
[2018-02-12 10:22:50] development.INFO: home page
[2018-02-12 10:22:50] development.ERROR: Call to undefined function vie() {"exception":"[object](Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Call to undefined function vie() at /var/www/html/routes/web.php:16
[stacktrace]
#0 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Route.php(198): Illuminate\\Routing\\Router->{closure}()
#1 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Route.php(172): Illuminate\\Routing\\Route->runCallable()
#2 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(658): Illuminate\\Routing\\Route->run()
#3 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#4 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(41): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#5 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle(Object(Illuminate\\Http\\Request), Object(Closure))
.....
.....
.....
#45 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#46 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))
#47 /var/www/html/public/index.php(55): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#48{main}
"}
Run Code Online (Sandbox Code Playgroud)
上面是我的 Laravel monolog 示例日志数据。我正在使用 Logstash 读取日志数据并将其发送到 Elasticsearch。下面是我的logstash.conf 文件
input …Run Code Online (Sandbox Code Playgroud) elasticsearch logstash logstash-grok logstash-configuration elastic-stack