Skip to content

Instantly share code, notes, and snippets.

@kkazala
Created February 23, 2023 11:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kkazala/36d48bdae610089179c8058a97070cb6 to your computer and use it in GitHub Desktop.
Save kkazala/36d48bdae610089179c8058a97070cb6 to your computer and use it in GitHub Desktop.
Gallery Template for Application Insights Workbook. Displays Page views by calendar week/week day rendered as a Heatmap
{
"version": "Notebook/1.0",
"items": [
{
"type": 9,
"content": {
"version": "KqlParameterItem/1.0",
"parameters": [
{
"id": "efdcbd97-a282-49a4-97c2-0d1f3618a086",
"version": "KqlParameterItem/1.0",
"name": "TimeRange",
"type": 4,
"typeSettings": {
"selectableValues": [
{
"durationMs": 1800000
},
{
"durationMs": 3600000
},
{
"durationMs": 43200000
},
{
"durationMs": 86400000
},
{
"durationMs": 172800000
},
{
"durationMs": 259200000
},
{
"durationMs": 604800000
},
{
"durationMs": 1209600000
},
{
"durationMs": 2419200000
},
{
"durationMs": 2592000000
},
{
"durationMs": 5184000000
},
{
"durationMs": 7776000000
}
]
},
"timeContext": {
"durationMs": 86400000
},
"value": {
"durationMs": 2419200000
}
}
],
"style": "pills",
"queryType": 0,
"resourceType": "microsoft.insights/components"
},
"name": "parameters "
},
{
"type": 3,
"content": {
"version": "KqlItem/1.0",
"query": "let start = startofweek({TimeRange:start});\nlet end= endofweek({TimeRange:end});\nlet dow = dynamic([\"Sun\", \"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\", \"Sat\"]);\npageViews\n| where timestamp >= start\n| where client_Type == 'Browser'\n| make-series Metric=sum(itemCount) default=0 on timestamp in range(start, end, 1d)\n| mvexpand timestamp to typeof(datetime), Metric to typeof(long)\n| extend WeekDay = toint(dayofweek(timestamp) / 1d), KW=week_of_year(timestamp)\n| extend WeekDayName=tostring(dow[WeekDay])\n| order by timestamp asc\n| project-away timestamp,WeekDay\n| evaluate pivot(WeekDayName, sum(Metric))\n| project KW,column_ifexists(\"Mon\",\"\"),column_ifexists(\"Tue\",\"\"),column_ifexists(\"Wed\",\"\"),column_ifexists(\"Thu\",\"\"),column_ifexists(\"Fri\",\"\"),column_ifexists(\"Sat\",\"\"),column_ifexists(\"Sun\",\"\")\n",
"size": 2,
"title": "Page Views by Calendar Week",
"timeContextFromParameter": "TimeRange",
"queryType": 0,
"resourceType": "microsoft.insights/components",
"gridSettings": {
"formatters": [
{
"columnMatch": "Mon|Tue|Wed|Thu|Fri|Sat|Sun",
"formatter": 8,
"formatOptions": {
"min": 0,
"palette": "blue",
"customColumnWidthSetting": "9ch"
}
}
]
}
},
"name": "query"
}
],
"fallbackResourceIds": [
"/subscriptions/9733fd99-1122-46e0-9482-732c52b24906/resourcegroups/rsgr_hokpok_letexams_build_svc/providers/microsoft.insights/components/build-letexams-appinsights"
],
"$schema": "https://github.com/Microsoft/Application-Insights-Workbooks/blob/master/schema/workbook.json"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment