[rsyslog-notify] Forum Thread: Template to store Rsyslog logs with MongoDB - (Mode 'post')

noreply at adiscon.com noreply at adiscon.com
Thu Sep 3 09:54:08 CEST 2015


User: felix.veysseyre 
Forumlink: http://kb.monitorware.com/viewtopic.php?p=25884#p25884

Message: 
----------
Hello,

I am trying to insert the logs coming from RSyslog to a MongoDB database.

The logs stored into MongoDB have to respect the following structure :

[code:rq3kjhfa]{
    "_id" : ObjectId("55b8c845a671d907a0ab9e0b"),
    "receptionTime" : "2015-06-12 14:29:45",
    "reportedTime" : "2015-06-12 14:29:45",
    "priority" : "6",
    "facility" : "23",
    "host" : "uacm3-3a-fscr01",
    "service" : "apacheaccess",
    "message" : "My messsage",
    "syslogTag" : "apache-access-fscr:"
}[/code:rq3kjhfa]

According to Rsyslog documentation (<!-- m --><a class="postlink"
href="http://www.rsyslog.com/doc/v8-stable/configuration/templates.html#standard-template-for-writing-to-files">http://www.rsyslog.com/doc/v8-stable/co
... g-to-files</a><!-- m -->) , I have designed the following template :

[code:rq3kjhfa]template(name="BSON" type="list") {
    constant(value="\"receptionTime\": \"")
    property(name="timegenerated")
    constant(value="\", \"reportedTime\": \"")
    property(name="timereported")
    constant(value="\", \"priority\": \"")
    property(name="syslogseverity")
    constant(value="\", \"facility\": \"")
    property(name="syslogfacility")
    constant(value="\", \"host\": \"")
    property(name="hostname")
    constant(value="\", \"service\": \"")
    property(name="programname")
    constant(value="\", \"message\": \"")
    property(name="msg")
    constant(value="\", \"syslogTag\": \"")
    property(name="syslogtag")
    constant(value="\"")
    }[/code:rq3kjhfa]

Unfortunately, the logs stored in MongoDB do not respect the required
structure at all. Here is what is stored :

[code:rq3kjhfa]{
    "_id" : ObjectId("55e715b25ea0c0a9fbbf8b0f"),
    "timegenerated" : "Sep  2 17:28:50",
    "timereported" : "Sep  2 15:27:57",
    "syslogseverity" : "5",
    "syslogfacility" : "21",
    "hostname" : "uacm3-3b-acd01",
    "programname" : "Sep",
    "msg" : "Some message",
    "syslogtag" : "Sep"
}[/code:rq3kjhfa]

Do you have any idea about what I am doing wrong ? Thanks !


More information about the rsyslog-notify mailing list