Kaa releases
Shortcuts
Skip to end of metadata
Go to start of metadata

 

The MongoDB log appender is responsible for transferring logs from the Operations server to the MongoDB database. The logs are stored in the table named logs_$applicationToken, where $applicationToken matches the token of the current application.

Creating MongoDB log appender in Admin UI

The easiest way to create a MongoDB log appender for your application is by using Admin UI.

Creating MongoDB log appender with REST API

It is also possible to create a MongoDB log appender for your application by using REST API. The following example illustrates how to provision the MongoDB log appender for the Cell Monitor demo application available in Kaa Sandbox.

Configuration

The MongoDB log appender configuration should match the following Avro schema.

 Click here to expand...
 

Fields of avro schema:

  • MongoDB nodes - list of MongoDB hosts.
  • Authentication credentials - credentials used to authenticate on MongoDB cluster
  • Other fields which configure of connection to MongoDB
     

    namedescription
    dbName
    name of database
    connectionsPerHost
    Max number of connections on per host
    maxWaitTime
    Max wait time for connection(ms)
    connectionTimeout
    Connection timeout (ms)
    socketTimeout
    Socket timeout (ms)
    socketKeepalive
    Turn on socket keep alive (boolean value)
    includeClientProfile
    Include or not client profile data (boolean value)
    includeServerProfile
    Include or not server profile data (boolean value)

The following configuration taken from the Cell Monitor demo matches the previous schema.

 Click here to expand...

 

Administration

The following REST API call example illustrates how to create a new MongoDB log appender.

 Example result

Using with MongoDB log appender

We'll use Data collection demo from Kaa Sendbox. Our example will send data to Kaa and then persist it to MongoDB. Also, we'll do selection queries on persisted data.

We have next log schema: 

 Click here to expand...

 

{
"type":"record",
 "name":"LogData",
 "namespace":"org.kaaproject.kaa.schema.sample.logging",
 "fields":[
{
"name":"level",
 "type":{
"type":"enum",
 "name":"Level",
 "symbols":[
"KAA_DEBUG",
 "KAA_ERROR",
 "KAA_FATAL",
 "KAA_INFO",
 "KAA_TRACE",
 "KAA_WARN"
 ]
}
},
 {
"name":"tag",
 "type":"string"
 },
 {
"name":"message",
 "type":"string"
 }
]
}

Display string

 Click here to expand...

"Schema": { "Name": ""LogData"", "Namespace": ""org.kaaproject.kaa.schema.sample.logging"", "Display name": "null", "Fields": Field (3 rows) }

 

The following JSON example matches the previous schema.

 Click here to expand...

{
"level" : "KAA_INFO",
"tag" : "TEST_TAG",
"message" : "My simple message"
}

 

Go to Data collection demos in Sandbox.

 

Next, in the Admin UI follow to Data collection demo application

 

 

There can be was same one. You can add new with your parameters

Enter name of the new appender 

Select MongoDB appender type.

Add new node in the Configuration section (localhost:27017)

Also you can add some Authentication credentials

And other important parameters of configuration. You can change them or use default.

 

Now click Add button on the top of the screen to create and deploy appender.

Verify that newly created appender has appeared in list.

Now run Data collection demo application. Verify that logs have been successfully sent to Kaa

 

Run the application using the following command in the console:

Let's verify that our logs have been persisted in MongoDB. Go to Sandbox VM and run next command to connect MongoDB:

 

You should observe similar output:

 

 

 


Copyright © 2014-2015, CyberVision, Inc.

  • No labels