piyushmnnit06 has asked for the wisdom of the Perl Monks concerning the following question:
0317 09:53:14.865+0000 {12772} INFO [pm-worker-exec slot-Task:id=8274 +,env=12772,type=11][c.s.w.t.f.s.PostExecutionStage ] Loaded {child r +unId vs completion type}: {8286-SUCCESSFUL}{8287-SUCCESSFUL}{8288-SUC +CESSFUL}{8289-SUCCESSFUL}{8290-SUCCESSFUL}{8291-SUCCESSFUL}{8292-SUCC +ESSFUL}{8293-SUCCESSFUL}{8294-SUCCESSFUL}{8295-SUCCESSFUL}{8296-SUCCE +SSFUL} 0317 09:54:12.498+0000 {12772} INFO [pm-worker-exec slot-Task:id=8273 +,env=12772,type=55][edProcessInputBatchKafkaProducer] Started produci +ng records on topic 12772_8286_20170317_IN_0 0317 09:54:13.428+0000 {12772} INFO [pm-worker-exec slot-Task:id=8273 +,env=12772,type=55][edProcessInputBatchKafkaProducer] Started produci +ng records on topic 12772_8287_20170317_IN_0 0317 09:55:13.027+0000 {12772} INFO [pm-worker-exec slot-Task:id=8273 +,env=12772,type=55][edProcessInputBatchKafkaProducer] Done with produ +cing records on topic 12772_8286_20170317_IN_0 0317 09:55:15.027+0000 {12772} INFO [pm-worker-exec slot-Task:id=8273 +,env=12772,type=55][edProcessInputBatchKafkaProducer] Done with produ +cing records on topic 12772_8287_20170317_IN_0
So in above log structure first I need to fetch all successful child runID(i.e 8286,8287....8296) for parent id 8274.Now for each runID i have to get started producing records time stamp and done with producing records time stamp
I tried below logic but thats messed up.Could you please help me regarding this logic
desired output is below
topic,start_time,Endtime 12772_8286_20170317_IN_0,09:54:12.498+0000,09:55:13.027+0000 12772_8287_20170317_IN_0,09:54:13.428+0000,09:55:15.027+0000
Below is my code
open (MYFILE, '>data.CSV'); $LOGFILE = "worker.log"; open(LOGFILE) or die("Could not open log file."); $LOGFILE1 = "worker.log"; open(LOGFILE1) or die("Could not open log file."); $taskid=8274; foreach $line (<LOGFILE>) { chomp($line); if ( $line =~ m/$taskid.*child runId vs completion type/) { @Task_id = $line =~ /\{(\d+)-/g; } } foreach $line (<LOGFILE1>) { chomp($line); foreach $childid(@Task_id) { if ( $line =~ m/Started producing records on topic (\d+)_($childid +)_(\d+)_IN_(\d+)/) { $envId=$1; $timestamp=$3; $input=$4; my @fields = split / /, $line; $data1="$envId\_$childid\_$timestamp\_IN\_$input\,$fields[1]"; $data2="$envId\_$childid\_$timestamp\_IN\_$input"; push @data9,$data1 ; print "$data1\n"; } if ( $line =~ m/Done with producing records on topic (\d+)_($chil +did)_(\d+)_IN_(\d+)/) { $envId=$1; $timestamp=$3; $input=$4; my @fields = split / /, $line; $data3="$envId\_$childid\_$timestamp\_IN\_$input\,$fields[1]"; $data4="$envId\_$childid\_$timestamp\_IN\_$input"; push @data9,$data3 ; print "$data3\n"; } } } foreach (@data9) { print MYFILE "$_\n"; } close LOGFILE; close LOGFILE1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Log Parsing
by tybalt89 (Monsignor) on Apr 02, 2017 at 20:17 UTC | |
by piyushmnnit06 (Novice) on Apr 03, 2017 at 06:09 UTC | |
by tybalt89 (Monsignor) on Apr 03, 2017 at 07:35 UTC | |
by piyushmnnit06 (Novice) on Apr 03, 2017 at 08:04 UTC | |
by tybalt89 (Monsignor) on Apr 03, 2017 at 08:09 UTC | |
| |
|
Re: Log Parsing
by poj (Abbot) on Apr 02, 2017 at 19:08 UTC | |
by piyushmnnit06 (Novice) on Apr 03, 2017 at 05:56 UTC | |
by poj (Abbot) on Apr 03, 2017 at 06:08 UTC | |
by piyushmnnit06 (Novice) on Apr 03, 2017 at 06:29 UTC | |
by poj (Abbot) on Apr 03, 2017 at 06:58 UTC | |
| |
|
Re: Log Parsing
by LanX (Saint) on Apr 02, 2017 at 18:55 UTC | |
|
Re: Log Parsing
by stevieb (Canon) on Apr 02, 2017 at 13:53 UTC | |
by piyushmnnit06 (Novice) on Apr 02, 2017 at 15:57 UTC |