1. input{
    2. rabbitmq {
    3. host => "rabbitmq:5672" # rabbitmq地址
    4. user=>"root"
    5. password=>"NP123456"
    6. queue => "log.queue" # 数据源队列名称
    7. key => "log.routingkey" # 数据源队列key
    8. exchange => "log.exchange" #
    9. durable => true # 持续性
    10. subscription_retry_interval_seconds => 10000 # 出现错误时5秒后重试
    11. }
    12. }
    13. output{
    14. if [title]{
    15. elasticsearch{
    16. hosts=> ["elasticsearch:9200"]
    17. index => "genoany-operate-log-%{+yyyyMMdd}"
    18. }
    19. }
    20. else if [userId]{
    21. elasticsearch{
    22. hosts=> ["elasticsearch:9200"]
    23. index => "%{[serviceName]}-log-%{+YYYY}"
    24. }
    25. }
    26. else{
    27. elasticsearch{
    28. hosts=> ["elasticsearch:9200"]
    29. index => "other-log-%{+YYYY}"
    30. }
    31. }
    32. stdout{codec => rubydebug}
    33. }
    1. input{
    2. rabbitmq {
    3. host => "rabbitmq:5672" # rabbitmq地址
    4. user=>"root"
    5. password=>"NP123456"
    6. queue => "operation.log.queue" # 数据源队列名称
    7. key => "operation.log.routingkey" # 数据源队列key
    8. exchange => "operation.log.exchange" #
    9. durable => true # 持续性
    10. subscription_retry_interval_seconds => 10000 # 出现错误时5秒后重试
    11. }
    12. }
    13. output{
    14. if [logType]== "OperationLog"{
    15. jdbc {
    16. driver_jar_path => "/usr/share/logstash/mysql/mysql-connector-java-8.0.19.jar"
    17. driver_class => "com.mysql.jdbc.Driver"
    18. connection_string => "jdbc:mysql://mysql:3306/genoany_log?useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&user=root&password=NP123456"
    19. 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"]
    20. }
    21. } else if [logType]== "OperationDetailLog"{
    22. jdbc {
    23. driver_jar_path => "/usr/share/logstash/mysql/mysql-connector-java-8.0.19.jar"
    24. driver_class => "com.mysql.jdbc.Driver"
    25. connection_string => "jdbc:mysql://mysql:3306/genoany_log?useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&user=root&password=NP123456"
    26. 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"]
    27. }
    28. }
    29. stdout{codec => rubydebug}
    30. }
    1. input {
    2. rabbitmq {
    3. host => "rabbitmq:5672" # rabbitmq地址
    4. user => "root"
    5. password => "NP123456"
    6. queue => "log.queue" # 数据源队列名称
    7. key => "log.routingkey" # 数据源队列key
    8. exchange => "log.exchange" #
    9. durable => true # 持续性
    10. subscription_retry_interval_seconds => 10000 # 出现错误时5秒后重试
    11. }
    12. }
    13. output {
    14. if [requestId] {
    15. if[serviceName] {
    16. elasticsearch {
    17. hosts => ["elasticsearch:9200"]
    18. index => "genoany-service-running-log-%{+yyyyMMdd}"
    19. }
    20. mongodb {
    21. codec => "json"
    22. uri => "mongodb://root:NP123456@mongo:27017"
    23. database => "Log"
    24. collection => "serviceRunning"
    25. }
    26. jdbc {
    27. driver_jar_path => "/usr/share/logstash/mysql/mysql-connector-java-8.0.19.jar"
    28. driver_class => "com.mysql.jdbc.Driver"
    29. connection_string => "jdbc:mysql://mysql:3306/genoany?useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&user=root&password=NP123456"
    30. statement => ["insert into sys_log_service( log_message,log_data,log_leave,request_id,service_name,method_name,method_in_args,method_out_arg,
    31. method_class_name,app_code,company_id,creator_id,creator,create_time) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)","[message]","[data]","[level]","[requestId]","[serviceName]","[methodInfo][methodName]",
    32. "[methodInfo][inArgs]","[methodInfo][outArg]","[methodInfo][className]","[appCode]","[companyId]","[userId]","[userName]","[createTime]"]
    33. }
    34. file {
    35. path => "../logstash/data/log/%{[level]}/serviceRunning%{+yyyyMMdd}.log"
    36. }
    37. }else {
    38. elasticsearch {
    39. hosts => ["elasticsearch:9200"]
    40. index => "genoany-user-operate-log-%{+yyyyMMdd}"
    41. }
    42. mongodb {
    43. codec => "json"
    44. uri => "mongodb://root:NP123456@mongo:27017"
    45. database => "Log"
    46. collection => "userOperate"
    47. }
    48. jdbc {
    49. driver_jar_path => "/usr/share/logstash/mysql/mysql-connector-java-8.0.19.jar"
    50. driver_class => "com.mysql.jdbc.Driver"
    51. connection_string => "jdbc:mysql://mysql:3306/genoany?useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&user=root&password=NP123456"
    52. 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]"]
    53. }
    54. file {
    55. path => "../logstash/data/var/log/%{[level]}/userOperate%{+yyyyMMdd}.log"
    56. }
    57. }
    58. }else if [title] {
    59. elasticsearch {
    60. hosts => ["elasticsearch:9200"]
    61. index => "genoany-operate-log-%{+yyyyMMdd}"
    62. }
    63. }else if [userId] {
    64. elasticsearch {
    65. hosts => ["elasticsearch:9200"]
    66. index => "%{[serviceName]}-log-%{+YYYY}"
    67. }
    68. }else {
    69. elasticsearch {
    70. hosts => ["elasticsearch:9200"]
    71. index => "other-log-%{+YYYY}"
    72. }
    73. }
    74. stdout {codec => rubydebug}
    75. }