input{
rabbitmq {
host => "rabbitmq:5672" # rabbitmq地址
user=>"root"
password=>"NP123456"
queue => "log.queue" # 数据源队列名称
key => "log.routingkey" # 数据源队列key
exchange => "log.exchange" #
durable => true # 持续性
subscription_retry_interval_seconds => 10000 # 出现错误时5秒后重试
}
}
output{
if [title]{
elasticsearch{
hosts=> ["elasticsearch:9200"]
index => "genoany-operate-log-%{+yyyyMMdd}"
}
}
else if [userId]{
elasticsearch{
hosts=> ["elasticsearch:9200"]
index => "%{[serviceName]}-log-%{+YYYY}"
}
}
else{
elasticsearch{
hosts=> ["elasticsearch:9200"]
index => "other-log-%{+YYYY}"
}
}
stdout{codec => rubydebug}
}
input{
rabbitmq {
host => "rabbitmq:5672" # rabbitmq地址
user=>"root"
password=>"NP123456"
queue => "operation.log.queue" # 数据源队列名称
key => "operation.log.routingkey" # 数据源队列key
exchange => "operation.log.exchange" #
durable => true # 持续性
subscription_retry_interval_seconds => 10000 # 出现错误时5秒后重试
}
}
output{
if [logType]== "OperationLog"{
jdbc {
driver_jar_path => "/usr/share/logstash/mysql/mysql-connector-java-8.0.19.jar"
driver_class => "com.mysql.jdbc.Driver"
connection_string => "jdbc:mysql://mysql:3306/genoany_log?useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&user=root&password=NP123456"
statement => ["INSERT INTO log_operation(id,user_id,user_name,create_time,app_code,company_id,request_id,ip_address,page_route,component_name,event_name) VALUES(?,?,?,?,?,?,?,?,?,?,?)", "id","userId","userName","createTime","appCode","companyId","requestId","ipAddress","pageRoute","componentName","eventName"]
}
} else if [logType]== "OperationDetailLog"{
jdbc {
driver_jar_path => "/usr/share/logstash/mysql/mysql-connector-java-8.0.19.jar"
driver_class => "com.mysql.jdbc.Driver"
connection_string => "jdbc:mysql://mysql:3306/genoany_log?useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&user=root&password=NP123456"
statement => ["INSERT INTO log_operation_detail(operation_log_id,level,request_id,service_name,class_name,method_name,in_args,message,create_time) VALUES(?,?,?,?,?,?,?,?,?)", "operationLogId","level","requestId","serviceName","className","methodName","inArgs","message","createTime"]
}
}
stdout{codec => rubydebug}
}
input {
rabbitmq {
host => "rabbitmq:5672" # rabbitmq地址
user => "root"
password => "NP123456"
queue => "log.queue" # 数据源队列名称
key => "log.routingkey" # 数据源队列key
exchange => "log.exchange" #
durable => true # 持续性
subscription_retry_interval_seconds => 10000 # 出现错误时5秒后重试
}
}
output {
if [requestId] {
if[serviceName] {
elasticsearch {
hosts => ["elasticsearch:9200"]
index => "genoany-service-running-log-%{+yyyyMMdd}"
}
mongodb {
codec => "json"
uri => "mongodb://root:NP123456@mongo:27017"
database => "Log"
collection => "serviceRunning"
}
jdbc {
driver_jar_path => "/usr/share/logstash/mysql/mysql-connector-java-8.0.19.jar"
driver_class => "com.mysql.jdbc.Driver"
connection_string => "jdbc:mysql://mysql:3306/genoany?useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&user=root&password=NP123456"
statement => ["insert into sys_log_service( log_message,log_data,log_leave,request_id,service_name,method_name,method_in_args,method_out_arg,
method_class_name,app_code,company_id,creator_id,creator,create_time) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)","[message]","[data]","[level]","[requestId]","[serviceName]","[methodInfo][methodName]",
"[methodInfo][inArgs]","[methodInfo][outArg]","[methodInfo][className]","[appCode]","[companyId]","[userId]","[userName]","[createTime]"]
}
file {
path => "../logstash/data/log/%{[level]}/serviceRunning%{+yyyyMMdd}.log"
}
}else {
elasticsearch {
hosts => ["elasticsearch:9200"]
index => "genoany-user-operate-log-%{+yyyyMMdd}"
}
mongodb {
codec => "json"
uri => "mongodb://root:NP123456@mongo:27017"
database => "Log"
collection => "userOperate"
}
jdbc {
driver_jar_path => "/usr/share/logstash/mysql/mysql-connector-java-8.0.19.jar"
driver_class => "com.mysql.jdbc.Driver"
connection_string => "jdbc:mysql://mysql:3306/genoany?useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&user=root&password=NP123456"
statement => ["insert into sys_log_opration(log_title,log_message,log_tag,log_leave,operate_type,request_id,app_code,company_id,creator_id,creator,create_time) values(?,?,?,?,?,?,?,?,?,?,?)","[title]","[message]","[tag]","[level]","[operateType]","[requestId]","[appCode]","[companyId]","[userId]","[userName]","[createTime]"]
}
file {
path => "../logstash/data/var/log/%{[level]}/userOperate%{+yyyyMMdd}.log"
}
}
}else if [title] {
elasticsearch {
hosts => ["elasticsearch:9200"]
index => "genoany-operate-log-%{+yyyyMMdd}"
}
}else if [userId] {
elasticsearch {
hosts => ["elasticsearch:9200"]
index => "%{[serviceName]}-log-%{+YYYY}"
}
}else {
elasticsearch {
hosts => ["elasticsearch:9200"]
index => "other-log-%{+YYYY}"
}
}
stdout {codec => rubydebug}
}