【发布时间】:2021-11-09 19:36:35
【问题描述】:
我有以下logstash.conf
input {
tcp {
port => 5000
# codec => json { charset=>"UTF-8" }
}
stdin {}
}
filter {
if "userId" not in [contextMap] {
drop {}
}
json {
source => "message"
}
}
output {
elasticsearch {
hosts => ["localhost:9200"]
index => "logs"
user => "user"
password => "password"
}
stdout {}
}
我在 logstash 中打印了 json 请求
{
"message" => " testing ,essage",
"instant" => {
"nanoOfSecond" => 267000000,
"epochSecond" => 1631632671
},
"thread" => "http-nio-8080-exec-1",
"level" => "INFO",
"loggerFqcn" => "org.apache.logging.slf4j.Log4jLogger",
"loggerName" => "",
"endOfBatch" => false,
"@version" => "1",
"@timestamp" => 2021-09-14T15: 17: 51.504Z,
"threadPriority" => 5,
"hostname" => "hostname",
"contextMap" => {
"requestId" => "f6f65bab-bdd1-4cca-ba09-ff0d06d16e41",
"userId" => "bc1289cd-d3ed-43ec-87ba-9c5ff9c5f205",
"moduleName" => "LOGGER_SERVICE",
},
"host" => "hostname",
"threadId" => 139,
"port" => 55555
}
我想要实现的是 contextMap 字段没有 userId 字段的地方,应该删除日志。
有人能告诉我我做错了吗?
【问题讨论】:
标签: elasticsearch logstash kibana