开发喵星球

若依集成分布式日志(226)

1、切换中文

config/kibana.yml添加

i18n.locale: "zh-CN"

2、日志收集

对应服务器安装logstash,配置规则,例如新建logstash-apache.conf

input {
  file {
    path => "/home/ruoyi/logs/sys-*.log"
    start_position => beginning
    sincedb_path => "/dev/null"
    codec => multiline {
      pattern => "^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}"
      negate => true
      auto_flush_interval => 3
      what => previous
    }
  }
}

filter {
  if [path] =~ "info" {
    mutate { replace => { type => "sys-info" } }
    grok {
      match => { "message" => "%{COMBINEDAPACHELOG}" }
    }
    date {
      match => [ "timestamp" , "dd/MMM/yyyy:HH:mm:ss Z" ]
    }
  } else if [path] =~ "error" {
    mutate { replace => { type => "sys-error" } }
  } else {
    mutate { replace => { type => "random_logs" } }
  }
}

output {
  elasticsearch {
    hosts => '120.78.129.95:9200'
  }
  stdout { codec => rubydebug }
}

启动logstash

./logstash -f logstash-apache.conf

通过kibana可视化检索各个服务日志数据 kibana

   
分类:Java/OOP 作者:无限繁荣, 吴蓉 发表于:2024-05-30 15:49:43 阅读量:120
<<   >>


powered by kaifamiao