Last active
June 2, 2024 18:34
-
-
Save AdamNaj/bd0c56251049fe2aeea452e2a51e83eb to your computer and use it in GitHub Desktop.
Most executed Solr queries from latest Sitecore logs
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
# Gets the latest 30 log files, filters only solr query lines from them, groups them by query content and orders by most executed, | |
# Letting you find things that are most effective to cache. | |
Set-HostProperty -HostWidth 2000 | |
$logFileFilter = "azure.log.*" | |
$logfileCountToAnalyse = 30 | |
$minQueryOccurence = 20 | |
Get-ChildItem $SitecoreLogFolder -Recurse -Filter $logFileFilter ` | |
| Sort -Property LastWriteTime -Descending ` | |
| Select -first $logfileCountToAnalyse ` | |
| Get-Content ` | |
| ? {$_.Contains("INFO Solr Query - ?") } ` | |
| % { $_.Substring($_.IndexOf("Solr Query - ?")+13) } ` | |
| Group-Object ` | |
| ? { $_.Count -gt $minQueryOccurence } ` | |
| Sort-Object -Property Count -Descending ` | |
| ft Count, Name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment