-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates. Removed filename, row number. Added more visuals to Power BI…
… including time brush
- Loading branch information
Joy George Kunjikkuru
authored and
Joy George Kunjikkuru
committed
Sep 25, 2019
1 parent
5ad75ed
commit 5954b2b
Showing
6 changed files
with
407,894 additions
and
14 deletions.
There are no files selected for viewing
Binary file modified
BIN
-2.14 MB
(73%)
web/iis/log-analysis/Power BI/PBI-Template/IIS Analysis Template for PBI Aug2019.pbix
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 20 additions & 13 deletions
33
web/iis/log-analysis/Power BI/prep-powershell/IIS to CSV.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,35 @@ | ||
cls | ||
$input = "<folder which contains .log files>" | ||
$inputPath = "<folder which contains .log files>" | ||
$outExt = ".csv" | ||
Get-ChildItem $input -Filter *.log | | ||
$pathToLogParser= "C:\Program Files (x86)\Log Parser 2.2\logparser" | ||
Get-ChildItem $inputPath -Filter *.log | | ||
Foreach-Object { | ||
$inFile = $_.FullName | ||
#$inFile | ||
|
||
"Starting " + $inFile | ||
$outFile = $_.FullName -replace "\.log",".csv" | ||
$outFile | ||
$cmd = "SELECT Logfilename,date,OUT_ROW_NUMBER() AS RowNumber, time, s-ip, cs-method, cs-uri-stem, cs-uri-query, s-port, cs-username, c-ip, cs(User-Agent) as cs-user-agent, sc-status, sc-substatus, sc-win32-status,sc-bytes,cs-bytes, time-taken INTO '"+$outFile+"' FROM '"+$inFile+"'" | ||
$cmd = "SELECT date, time, s-ip, cs-method, cs-uri-stem, cs-uri-query, s-port, cs-username, c-ip, cs(User-Agent) as cs-user-agent, sc-status, sc-substatus, sc-win32-status,sc-bytes,cs-bytes, time-taken INTO '"+$outFile+"' FROM '"+$inFile+"'" | ||
#$cmd | ||
$output = & "C:\Program Files (x86)\Log Parser 2.2\logparser" -i:W3C -o:csv $cmd | Out-String | ||
"output is " +$output.Length | ||
# Hack in case the log file dont have sc-bytes or cs-bytes columns as those are not enabled by default. | ||
"Output of first conversion " +$output.Length + ". If it is 0, it will rerun with less fields. This takes long time based on log size. Make sure sc-bytes or cs-bytes columns available in IISLogs." | ||
|
||
# Hack in case the log file dont have as those are not enabled by default. | ||
# TODO move the default logic to PowerBI if possible. | ||
# Warning The below step takes time if the log size > 100 MB as PowerShell take time to write. Better make sure the IIS log files have cs-bytes & sc-bytes | ||
|
||
if ($output.Length -eq 0) { | ||
#There may be missing columns such as sc-bytes, cs-bytes. Rerun without those fields & Add default value 0 | ||
$cmd = "SELECT Logfilename,date,OUT_ROW_NUMBER() AS RowNumber, time, s-ip, cs-method, cs-uri-stem, cs-uri-query, s-port, cs-username, c-ip, cs(User-Agent) as cs-user-agent, sc-status, sc-substatus, sc-win32-status, time-taken INTO '"+$outFile+"' FROM '"+$inFile+"'" | ||
$output = & "C:\Program Files (x86)\Log Parser 2.2\logparser" -i:W3C -o:csv $cmd | Out-String | ||
"output of rerun is " +$output.Length | ||
$cmd = "SELECT date, time, s-ip, cs-method, cs-uri-stem, cs-uri-query, s-port, cs-username, c-ip, cs(User-Agent) as cs-user-agent, sc-status, sc-substatus, sc-win32-status, time-taken INTO '"+$outFile+"' FROM '"+$inFile+"'" | ||
$output = & $pathToLogParser -i:W3C -o:csv $cmd | Out-String | ||
"output of rerun is " +$output.Length + ". Starting addition of missing columns" | ||
$csv = Import-Csv -Path $outFile | ||
$csv = $csv | Select-Object LogFileName,RowNumber,time,date, s-ip,cs-method,cs-uri-stem, cs-uri-query, s-port, cs-username, c-ip, cs-User-Agent, sc-status, sc-substatus, sc-win32-status,sc-bytes,cs-bytes,time-taken | ||
"Parsed CSV into PowerShell" | ||
$csv = $csv | Select-Object date,time, s-ip,cs-method,cs-uri-stem, cs-uri-query, s-port, cs-username, c-ip, cs-User-Agent, sc-status, sc-substatus, sc-win32-status,sc-bytes,cs-bytes,time-taken | ||
"Added missing columns" | ||
$csv | Export-Csv $outFile -NoTypeInformation | ||
"Completed column addition " + $inFile | ||
|
||
}else { | ||
"Completed file " + $inFile | ||
} | ||
} | ||
"completed" | ||
"completed all files" |
Oops, something went wrong.
5954b2b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes #1, #2 , #3 #4