社区微信群开通啦,扫一扫抢先加入社区官方微信群
社区微信群
日志平台背景:
日志的分析和监控在系统开发中占非常重要的地位,系统越复杂,日志的分析和监控就越重要,常见的需求有:
很多团队在日志方面可能遇到的一些问题有:
input {
input {
redis {
codec => json
host => "127.0.0.1"
port => 8098
key => "logstash"
data_type => "list"
threads => 10
}
}
filter {
json {
source => "message"
}
if ([message] =~ "^(?!.*?xx_data_logs_type).*$") {
drop {}
}
}
output {
if [message] =~ "xx_data_logs_type" and [message] =~ "xx_error" {
elasticsearch {
hosts => ["localhost:9200"]
index => "xx_app_error_%{+YYYY.MM.dd}"
}
}
if [message] =~ "xx_data_logs_type" and [message] =~ "xx_request_info" {
elasticsearch {
hosts => ["localhost:9200"]
index => "xx_app_request_info_%{+YYYY.MM.dd}"
}
}
if [message] =~ "xx_data_logs_type" and [message] =~ "xx_sql_info" {
elasticsearch {
hosts => ["localhost:9200"]
index => "xx_app_sql_info_%{+YYYY.MM.dd}"
}
}
if [message] =~ "xx_data_logs_type" and [message] =~ "xx_info" {
elasticsearch {
hosts => ["localhost:9200"]
index => "xx_app_info_%{+YYYY.MM.dd}"
}
}
stdout {
codec => dots
}
}
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="LOGSTASH" class="com.cwbase.logback.RedisAppender">
<host>127.0.0.1</host>
<port>8098</port>
<key>logstash</key>
</appender>
<appender name="ASYNC" class="ch.qos.logback.classic.AsyncAppender">
<!-- 不丢失日志.默认的,如果队列的80%已满,则会丢弃TRACT、DEBUG、INFO级别的日志 -->
<discardingThreshold>0</discardingThreshold>
<!-- 更改默认的队列的深度,该值会影响性能.默认值为256 -->
<queueSize>5120</queueSize>
<appender-ref ref="LOGSTASH" />
</appender>
<logger name="com.xx" level="info">
<appender-ref ref="ASYNC"/>
</logger>
</configuration>
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!