Skip to content

Instantly share code, notes, and snippets.

@sunnyc7
Last active January 21, 2018 16:44
Show Gist options
  • Save sunnyc7/094fd6ec1064409e5aa06985e0501b56 to your computer and use it in GitHub Desktop.
Save sunnyc7/094fd6ec1064409e5aa06985e0501b56 to your computer and use it in GitHub Desktop.
// LogAnalytics function to query a performance counter (CounterName), in computer, starting on date Sart for a 30d period
// Copy paste the query in LogAnalytics window
// Define custom Loganalytics function
let PerfCountWithin30dRange = (start:date, CounterName:string, CompName:string) {
let period = 30d;
Perf
| where (TimeGenerated > start and TimeGenerated < start + period)
| where (Computer contains CompName)
| where CounterName == "User Count"
| summarize percentiles(CounterValue, 95) by bin(TimeGenerated, 15m)
| render timechart
};
// VARIABLES
let start = ago(60d);
let comp = 'SERVERNAME';
let perfcountername = "User Count";
// Call the functions
PerfCountWithin30dRange(start, perfcountername, comp);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment