I have configured my First KAA Application using Java and MongoDB Log Appenders, able to see in the KAA server DB Logs. But my isssue is how can i retrieve the data from MongoDB Log Appenders to my Local system or Java system.
Tried:
I tried for Calling the POSTMAN service also but not able to find any particular API for that. http://10.110.25.52:8080/kaaAdmin/rest/api/logAppenders/536590273894852265 didn't found any API for content of LogAppneders in it.
I tried for making the database connection through Java using KAA server ip for MongoDb , but unsuccessful. Below code:
public static void main(String[] args) {
try {
MongoClient mongo = new MongoClient("127.0.0.1", 27017);
// if database doesn't exists, MongoDB will create it for you
com.mongodb.DB db = mongo.getDB("Kaa");
System.out.println("db="+db);
DBCollection table = db.getCollection("logs_53659027389148522657");
System.out.println("table="+table);
BasicDBObject searchQuery = new BasicDBObject();
searchQuery.put("temperature", "30");
DBCursor cursor = table.find(searchQuery);
while (cursor.hasNext()) {
System.out.println(cursor.next());
}
System.out.println("Done");
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (MongoException e) {
e.printStackTrace();
}
Solution: In VM change the network type as "Bridge type" and check the ip in ubuntu by "hostname -I" ,set the particular IP to the sandbox default IP ,run your first KAA application. the logs will be generated in MongoDB Log Appender. But to connect that you need to change the Configuration file by running this command "Vim /etc/mongod.conf" Comment out the defualt ip like this "#127.0.0.1" beacuse it can allow only localhost because of this i was not able to connect it outside VM. After changing IP you need to again generate the SDK of your application so that it can connect to that IP , rather than "localhost".
By using roboClient you can easily connect to the mongodb database and do the Analysis.