I have several logs files with hundreds of lines in the following format:
{"time": 0800, "service":"A service", "id": 5, "error":"bad"}
{"time": 0900, "service":"B service", "id": 6, "error":"good"}
I'd like to be able run through each file and output a table with a count of each unique error message .. something like this:
Error "bad" came up 5 times
Error "good" came up 3 times
I'm not sure if converting the content to JSON makes sense in this situation, but I have done the following so far to at least identify unique strings:
Get-Childitem -path "\path" | Select-string -Pattern "good"
and that gives me all the "good" messages.
It would seem to me that using a loop with a counter to capture unique events could be used. What would be the best way to achieve all of this with PowerShell?
Measure-Objectand it will return you the number of lines.