Note that there are some explanatory texts on larger screens.

plurals
  1. POCalculate time based metrics(hourly)
    text
    copied!<p>How would I calculate time-based metrics (hourly average) based on log file data? </p> <p>let me make this more clear, consider a log file that contains entries as follows: Each UIDs appears only twice in the log. they will be in embeded xml format. And they will likely appear OUT of sequence. And the log file will have data for only one day so only one day records will be there.</p> <p>No of UIDs are 2 millions in log file.</p> <p>I have to find out average hourly reponse time for these requests. Below has request and response in log file. UID is the key to relate b/w request and response. </p> <pre><code>2013-04-03 08:54:19,451 INFO [Logger] &lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;&lt;log-event&gt;&lt;message-time&gt;2013-04-03T08:54:19.448-04:00&lt;/message-time&gt;&lt;caller&gt;PCMC.common.manage.springUtil&lt;/caller&gt;&lt;body&gt;&amp;lt;log-message-body&amp;gt;&amp;lt;headers&amp;gt;&amp;amp;lt;FedDKPLoggingContext id="DKP_DumpDocumentProperties" type="context.generated.FedDKPLoggingContext"&amp;amp;gt;&amp;amp;lt;logFilter&amp;amp;gt;7&amp;amp;lt;/logFilter&amp;amp;gt;&amp;amp;lt;logSeverity&amp;amp;gt;255&amp;amp;lt;/logSeverity&amp;amp;gt;&amp;amp;lt;schemaType&amp;amp;gt;PCMC.MRP.DocumentMetaData&amp;amp;lt;/schemaType&amp;amp;gt;&amp;amp;lt;UID&amp;amp;gt;073104c-4e-4ce-bda-694344ee62&amp;amp;lt;/UID&amp;amp;gt;&amp;amp;lt;consumerSystemId&amp;amp;gt;JTR&amp;amp;lt;/consumerSystemId&amp;amp;gt;&amp;amp;lt;consumerLogin&amp;amp;gt;jbserviceid&amp;amp;lt;/consumerLogin&amp;amp;gt;&amp;amp;lt;logLocation&amp;amp;gt;Beginning of Service&amp;amp;lt;/logLocation&amp;amp;gt;&amp;amp;lt;/fedDKPLoggingContext&amp;amp;gt;&amp;lt;/headers&amp;gt;&amp;lt;payload&amp;gt; &amp;amp;lt;ratedDocument&amp;amp;gt; &amp;amp;lt;objectType&amp;amp;gt;OLB_BBrecords&amp;amp;lt;/objectType&amp;amp;gt; &amp;amp;lt;provider&amp;amp;gt;JET&amp;amp;lt;/provider&amp;amp;gt; &amp;amp;lt;metadata&amp;amp;gt;&amp;amp;amp;lt;BooleanQuery&amp;amp;amp;gt;&amp;amp;amp;lt;Clause occurs=&amp;amp;amp;quot;must&amp;amp;amp;quot;&amp;amp;amp;gt;&amp;amp;amp;lt;TermQuery fieldName=&amp;amp;amp;quot;RegistrationNumber&amp;amp;amp;quot;&amp;amp;amp;gt;44565153050735751&amp;amp;amp;lt;/TermQuery&amp;amp;amp;gt;&amp;amp;amp;lt;/Clause&amp;amp;amp;gt;&amp;amp;amp;lt;/BooleanQuery&amp;amp;amp;gt;&amp;amp;lt;/metadata&amp;amp;gt; &amp;amp;lt;/ratedDocument&amp;amp;gt; &amp;lt;/payload&amp;gt;&amp;lt;/log-message-body&amp;gt;&lt;/body&gt;&lt;/log-event&gt; 2013-04-03 08:54:19,989 INFO [Logger] &lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;&lt;log-event&gt;&lt;message-time&gt;2013-04-03T08:54:19.987-04:00&lt;/message-time&gt;&lt;caller&gt;PCMC.common.manage.springUtil&lt;/caller&gt;&lt;body&gt;&amp;lt;log-message-body&amp;gt;&amp;lt;headers&amp;gt;&amp;amp;lt;fedDKPLoggingContext id="DKP_DumpDocumentProperties" type="context.generated.FedDKPLoggingContext"&amp;amp;gt;&amp;amp;lt;logFilter&amp;amp;gt;7&amp;amp;lt;/logFilter&amp;amp;gt;&amp;amp;lt;logSeverity&amp;amp;gt;255&amp;amp;lt;/logSeverity&amp;amp;gt;&amp;amp;lt;schemaType&amp;amp;gt;PCMC.MRP.DocumentMetaData&amp;amp;lt;/schemaType&amp;amp;gt;&amp;amp;lt;UID&amp;amp;gt;073104c-4e-4ce-bda-694344ee62&amp;amp;lt;/UID&amp;amp;gt;&amp;amp;lt;consumerSystemId&amp;amp;gt;JTR&amp;amp;lt;/consumerSystemId&amp;amp;gt;&amp;amp;lt;consumerLogin&amp;amp;gt;jbserviceid&amp;amp;lt;/consumerLogin&amp;amp;gt;&amp;amp;lt;logLocation&amp;amp;gt;Successful Completion of Service&amp;amp;lt;/logLocation&amp;amp;gt;&amp;amp;lt;/fedDKPLoggingContext&amp;amp;gt;&amp;lt;/headers&amp;gt;&amp;lt;payload&amp;gt;0&amp;lt;/payload&amp;gt;&amp;lt;/log-message-body&amp;gt;&lt;/body&gt;&lt;/log-event&gt; </code></pre> <p>here is the bash script I wrote.</p> <pre><code>uids=cat $i|grep "Service" |awk 'BEGIN {FS="lt;";RS ="gt;"} {print $2;}'| sort -u for uid in ${uids}; do count=`grep "$uid" test.log|wc -l` if [ "${count}" -ne "0" ]; then unique_uids[counter]="$uid" let counter=counter+1 fi done echo ${unique_uids[@]} echo $counter echo " Unique No:" ${#unique_uids[@]} echo uid StartTime EndTime" &gt; $log for unique_uids in ${unique_uids[@]} ; do responseTime=`cat $i|grep "${unique_uids}" |awk '{split($2,Arr,":|,"); print Arr[1]*3600000+Arr[2]*60000+Arr[3]*1000+Arr[4]}'|sort -n` echo $unique_uids $responseTime &gt;&gt; $log done </code></pre> <p>And the output should be like this Operation comes from id, Consumer comes from documentmetadata and hour is the time 08:54:XX So if we have more than one request and response then need to average of the response times for requests came at that hour.</p> <p>Operation Consumer HOUR Avg-response-time(ms)<br> DKP_DumpDocumentProperties MRP 08 538</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload