zoukankan      html  css  js  c++  java
  • rsyslog 新配置语法

    发送端:
    
    [root@node01 log]# cat /etc/rsyslog.conf
    module(load="imfile")
    #template(name="remote" type="string"    string="%msg%
    ")
    template(name="remote" type="list") {
        constant(value="<")
        property(name="pri")
        constant(value=">")
        property(name="timestamp" dateFormat="rfc3339")
        constant(value=" ")
        property(name="hostname")
        constant(value=" ")
        property(name="syslogtag" position.from="1" position.to="32")
        property(name="msg" spifno1stsp="on" )
        property(name="msg")
         constant(value=",")
         property(name="$!metadata!filename")
        }
    
    input (
     type="imfile"
     File="/root/log/a2.log"
     Tag="testlog02"
     PersistStateInterval="10"
     reopenOnTruncate="on"
     Severity="info"
     Facility="local5"
     ruleset="chat"
     addMetadata ="on"
    )
    
    
    input (
     type="imfile"
     File="/root/log/a1.log"
     Tag="testlog01"
     PersistStateInterval="10"
     reopenOnTruncate="on"
     Severity="info"
     Facility="local5"
     ruleset="chat"
     addMetadata ="on"
    )
    
    
    
    
    
    ruleset (name="chat"){
       action(type="omfwd" Target="192.168.137.3" Port="514" Protocol="tcp" template="remote")
    }
    
    
    接收端:
    
    ##%msg:2:$%为去掉日志开头的空格
    template (name="DynFile" type="string" string="%msg%,%fromhost-ip%
    ")
    if ($syslogtag == "testlog01") then {
       action(type="omfile" FileOwner="elk" FileGroup="elk"  file="/root/log/testlog01.log" template="DynFile")
    }
    
    
    if ($syslogtag == "testlog02") then {
       action(type="omfile" FileOwner="elk" FileGroup="elk"  file="/root/log/testlog02.log" template="DynFile")
    }

  • 相关阅读:
    FTPUtil工具类
    maven配置默认jdk版本
    IDEA 使用lombok
    当前时间是否在区间范围内
    获取剩余的秒数
    java类执行顺序
    java8 关于Set集合的线程安全使用
    反射之设置对象字段值以及根据字段获取对象字段值
    ES方法使用注意
    java导出标题多行且合并单元格的EXCEL
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349631.html
Copyright © 2011-2022 走看看