Hello,
Thank you for your ideas. I've done some reading up on log4j and settings and I have a question:
Can I specify a custom layout in the Denodo Monitor ConfigurationParameters.properties? That properties file looks a LOT like a log4j.properties file.
I ask because I found out how to write a custom layout and I can now log the hostname from within the $DENODO_HOME/conf/vdp/log4j.xml settings. Since I have my custom PatternLayout, I was hoping to use that same layout in the Denodo Monitor (since that is based on log4j, and my custom layout extends org.apache.log4j.PattenLayout).
If you could let me know about custom layouts in Denodo Monitor, that'd be great.
So, with my custom layout and the log4j.xml file, I can push that single file to ALL my servers and the hostname gets properly logged. I can now use the JDBC Appender or use a batch/scheduler job to read the existing log files and insert them into a database.
HOWEVER, I'm trying to keep this simple ;-) Both of those options feel too complicated right now (and the JDBC Appender has to be done carefully so performance doesn't suffer)
So, in an effort to keep things simple and not jeopardize Denodo performance...I'm thinking about just using Denodo Monitor...I already have Denodo Monitor running on all my servers... and I can use Denodo Monitor to insert to a database (and it is my understanding that Denodo monitor is separate from Denodo)...I'd only need to update one line in each Denodo Monitor configuration file by adding "myhostname" as one of the columns in the insert statement:
vdpqueries.jdbcagent.insertStatement=INSERT INTO request_notification values(%X{Id}, myhostname, %X{Database}, %X{UserName}, %X{NotificationType}, %X{SessionId}, to_timestamp(%X{StartTime},'YYYY-MM-DD"T"HH24:MI:SS.FF3'), to_timestamp(%X{EndTime},'YYYY-MM-DD"T"HH24:MI:SS.FF3'), %X{Duration}, %X{WaitingTime}, %X{NumRows}, %X{State}, %X{Completed}, %X{Cache}, %X{Query}, %X{RequestType}, %X{Elements})
AND The only thing I'll need to do is write a script as part of my denodo-monitor deployments to keep that hostname up-to-date on each server (not too bad).
With Denodo Monitor running on all my servers and all of them inserting the query history into a database, this feels reasonable for me right now. If we add servers, I just need to deploy the denodo monitor setup to the new servers.
I'll give this a try for awhile to see how things go.
Again, please let me know if it is possible to add my own layout to the Denodo Monitor configuration.
Thanks~!
Here is my custom layout:
//taken from http://lifeinide.blogspot.com/2011/06/host-and-user-name-in-log4j-logs.html
package com.company.denodo.log4j;
import java.net.InetAddress;
import java.net.UnknownHostException;
import org.apache.log4j.PatternLayout;
import org.apache.log4j.helpers.PatternConverter;
import org.apache.log4j.helpers.PatternParser;
import org.apache.log4j.spi.LoggingEvent;
public class ContextPatternLayout extends PatternLayout {
protected String host;
protected String getHostname(){
if(host==null){
try{
InetAddress addr = InetAddress.getLocalHost();
this.host = addr.getHostName();
} catch (UnknownHostException e){
this.host = "localhost";
}
}
return host;
}
@Override
protected PatternParser createPatternParser(String pattern){
return new PatternParser(pattern){
@Override
protected void finalizeConverter(char c){
PatternConverter pc = null;
switch(c){
case 'h':
pc = new PatternConverter(){
@Override
protected String convert(LoggingEvent event){
return getHostname();
}
};
break;
}//switch
if (pc == null)
super.finalizeConverter(c);
else
addConverter(pc);
}//finalizeConverter
}; //return new
}//createPatternParser
}//class ContextPatternLayout