{
  "version": "Notebook/1.0",
  "items": [
    {
      "type": 1,
      "content": {
        "json": "## OV DGX Cloud Portal - Metrics\n\nReal-time monitoring of portal streaming sessions\n\n---"
      },
      "name": "text - title"
    },
    {
      "type": 12,
      "content": {
        "version": "NotebookGroup/1.0",
        "groupType": "editable",
        "title": "Current Stats",
        "items": [
          {
            "type": 3,
            "content": {
              "version": "KqlItem/1.0",
              "query": "customMetrics\n| where name == \"sessions.active.count\"\n| extend \n    app = tostring(customDimensions[\"session.app\"]),\n    user = tostring(customDimensions[\"session.username\"]),\n    function_id = tostring(customDimensions[\"nvcf.function_id\"]),\n    function_version = tostring(customDimensions[\"nvcf.function_version_id\"])\n| summarize arg_max(timestamp, *) by app, user, function_id, function_version\n| where value > 0\n| distinct user\n| summarize Users = count(user)",
              "size": 3,
              "title": "Current Active Users",
              "queryType": 0,
              "resourceType": "microsoft.insights/components",
              "visualization": "card",
              "statSettings": {
                "valueAggregation": "None",
                "colorSettings": {
                  "type": "static",
                  "mode": "background",
                  "heatmapPalette": "greenRed",
                  "thresholdsGrid": []
                },
                "iconSettings": {
                  "thresholdsGrid": []
                },
                "tagText": "",
                "valueFontStyle": "auto"
              },
              "textSettings": {
                "style": "bignumber"
              }
            },
            "customWidth": "50",
            "name": "query - concurrent users"
          },
          {
            "type": 3,
            "content": {
              "version": "KqlItem/1.0",
              "query": "customMetrics\n| where name == \"sessions.active.count\"\n| extend \n    app = tostring(customDimensions[\"session.app\"]),\n    user = tostring(customDimensions[\"session.user\"]),\n    function_id = tostring(customDimensions[\"nvcf.function_id\"]),\n    function_version = tostring(customDimensions[\"nvcf.function_version_id\"])\n| summarize arg_max(timestamp, *) by app, user, function_id, function_version\n| summarize Value = sum(tolong(value))",
              "size": 3,
              "title": "Current Active Sessions",
              "queryType": 0,
              "resourceType": "microsoft.insights/components",
              "visualization": "card",
              "textSettings": {
                "style": "bignumber"
              }
            },
            "customWidth": "50",
            "name": "query - active sessions"
          },
          {
            "type": 3,
            "content": {
              "version": "KqlItem/1.0",
              "query": "customMetrics\n| where name == \"sessions.start.count\"\n| extend appname = tostring(customDimensions[\"session.app\"])\n| extend function_id = tostring(customDimensions[\"nvcf.function_id\"])\n| where isnotempty(appname)\n| summarize [\"Total Sessions\"] = max(value) by appname\n| project [\"Application Name\"] = appname, [\"Total Sessions\"]\n| top 10 by [\"Total Sessions\"] desc",
              "size": 0,
              "title": "Top 10 Applications by Session Count",
              "queryType": 0,
              "resourceType": "microsoft.insights/components",
              "visualization": "table",
              "gridSettings": {
                "formatters": [
                  {
                    "columnMatch": "Total Sessions",
                    "formatter": 8,
                    "formatOptions": {
                      "palette": "blue"
                    }
                  }
                ]
              }
            },
            "name": "query - top functions - Copy"
          },
          {
            "type": 3,
            "content": {
              "version": "KqlItem/1.0",
              "query": "let activeGpus = customMetrics\n| where name == \"gpu.active.count\"\n| extend cluster = tostring(customDimensions[\"cluster\"])\n| summarize [\"Active GPUs\"] = max(value) by cluster;\n\nlet totalGpus = customMetrics\n| where name == \"gpu.total.count\"\n| extend cluster = tostring(customDimensions[\"cluster\"])\n| summarize [\"Total GPUs\"] = max(value) by cluster;\n\nactiveGpus\n| join kind=leftouter totalGpus on cluster\n| project Cluster = cluster, [\"Active GPUs\"], [\"Total GPUs\"]",
              "size": 0,
              "title": "Current GPU Utilization by Cluster",
              "queryType": 0,
              "resourceType": "microsoft.insights/components",
              "gridSettings": {
                "sortBy": [
                  {
                    "itemKey": "Total GPUs",
                    "sortOrder": 2
                  }
                ]
              },
              "sortBy": [
                {
                  "itemKey": "Total GPUs",
                  "sortOrder": 2
                }
              ]
            },
            "name": "query - 3"
          }
        ]
      },
      "name": "Current Stats",
      "styleSettings": {
        "showBorder": true
      }
    },
    {
      "type": 12,
      "content": {
        "version": "NotebookGroup/1.0",
        "groupType": "editable",
        "title": "Ranged Stats",
        "items": [
          {
            "type": 9,
            "content": {
              "version": "KqlParameterItem/1.0",
              "parameters": [
                {
                  "id": "b859a860-4969-4842-88a8-1dbbf2dd6b47",
                  "version": "KqlParameterItem/1.0",
                  "name": "TimeRange",
                  "type": 4,
                  "isRequired": true,
                  "value": {
                    "durationMs": 14400000
                  },
                  "typeSettings": {
                    "selectableValues": [
                      {
                        "durationMs": 300000
                      },
                      {
                        "durationMs": 900000
                      },
                      {
                        "durationMs": 1800000
                      },
                      {
                        "durationMs": 3600000
                      },
                      {
                        "durationMs": 14400000
                      },
                      {
                        "durationMs": 43200000
                      },
                      {
                        "durationMs": 86400000
                      },
                      {
                        "durationMs": 604800000
                      }
                    ],
                    "allowCustom": true
                  }
                }
              ],
              "style": "pills",
              "queryType": 0,
              "resourceType": "microsoft.insights/components"
            },
            "name": "parameters - time range"
          },
          {
            "type": 3,
            "content": {
              "version": "KqlItem/1.0",
              "query": "customMetrics\r\n| where name == \"sessions.duration\"\r\n| extend sessionDuration = valueSum / valueCount\r\n| summarize AvgSessionDuration = avg(sessionDuration)\r\n| project AvgSessionDuration = iif(isnan(AvgSessionDuration), \"N/A\", strcat(tostring(round(AvgSessionDuration, 2)), \" seconds\"))",
              "size": 3,
              "title": "Average Session Duration",
              "noDataMessage": "N/A",
              "timeContextFromParameter": "TimeRange",
              "queryType": 0,
              "resourceType": "microsoft.insights/components",
              "visualization": "card",
              "textSettings": {
                "style": "bignumber"
              }
            },
            "name": "AvgSessionDuration"
          },
          {
            "type": 3,
            "content": {
              "version": "KqlItem/1.0",
              "query": "customMetrics\r\n| where name == \"sessions.start.count\"\r\n| extend \r\n    app = tostring(customDimensions[\"session.app\"]),\r\n    username = tostring(customDimensions[\"session.username\"])\r\n| summarize TotalSessions = sum(value) by app, timestamp\r\n| summarize\r\n    LatestValue = max(TotalSessions),\r\n    EarliestValue = min(TotalSessions)\r\n    by app\r\n| extend NewSessions = LatestValue - EarliestValue\r\n| where NewSessions > 0\r\n| project app, NewSessions\r\n| top 10 by NewSessions\r\n    ",
              "size": 3,
              "title": "Top 10 Started Applications",
              "timeContextFromParameter": "TimeRange",
              "queryType": 0,
              "resourceType": "microsoft.insights/components",
              "gridSettings": {
                "labelSettings": [
                  {
                    "columnId": "app",
                    "label": "Application"
                  }
                ]
              }
            },
            "name": "Top 10 Started Applications"
          },
          {
            "type": 3,
            "content": {
              "version": "KqlItem/1.0",
              "query": "customMetrics\r\n| where name == \"sessions.start.count\"\r\n| extend \r\n    app = tostring(customDimensions[\"session.app\"]),\r\n    username = tostring(customDimensions[\"session.username\"])\r\n| summarize TotalSessions = sum(value) by username, timestamp\r\n| summarize\r\n    LatestValue = max(TotalSessions),\r\n    EarliestValue = min(TotalSessions)\r\n    by username\r\n| extend NewSessions = LatestValue - EarliestValue\r\n| where NewSessions > 0\r\n| project username, NewSessions\r\n| top 10 by NewSessions\r\n    ",
              "size": 3,
              "title": "Top 10 Users that started new sessions",
              "timeContextFromParameter": "TimeRange",
              "queryType": 0,
              "resourceType": "microsoft.insights/components",
              "gridSettings": {
                "labelSettings": [
                  {
                    "columnId": "username",
                    "label": "Username"
                  },
                  {
                    "columnId": "NewSessions",
                    "label": "New Sessions"
                  }
                ]
              }
            },
            "customWidth": "50",
            "name": "Top 10 Users that started new sessions"
          },
          {
            "type": 3,
            "content": {
              "version": "KqlItem/1.0",
              "query": "customMetrics\n| where name == \"sessions.end.count\"\n| extend reason = tostring(customDimensions[\"session.status\"])\n| order by timestamp desc",
              "size": 0,
              "title": "Session Ending Reason",
              "timeContextFromParameter": "TimeRange",
              "queryType": 0,
              "resourceType": "microsoft.insights/components",
              "visualization": "piechart",
              "chartSettings": {
                "group": "reason",
                "createOtherGroup": null
              }
            },
            "customWidth": "50",
            "name": "query - 7"
          },
          {
            "type": 3,
            "content": {
              "version": "KqlItem/1.0",
              "query": "customMetrics\n| where name == \"sessions.active.count\"\n| extend \n    app = tostring(customDimensions[\"session.app\"]),\n    username = tostring(customDimensions[\"session.username\"]),\n    function_id = tostring(customDimensions[\"nvcf.function_id\"]),\n    function_version = tostring(customDimensions[\"nvcf.function_version_id\"])\n| summarize ActiveCountByTime = take_any(value) by bin(timestamp, 5m), app, username, function_id, function_version\n| summarize ActiveSessions = sum(ActiveCountByTime) by timestamp\n| order by timestamp asc\n| render timechart",
              "size": 0,
              "aggregation": 2,
              "title": "Active Sessions per 5m interval",
              "timeContextFromParameter": "TimeRange",
              "queryType": 0,
              "resourceType": "microsoft.insights/components",
              "chartSettings": {
                "seriesLabelSettings": [
                  {
                    "seriesName": "ActiveSessions",
                    "label": "Active Sessions"
                  }
                ],
                "xSettings": {
                  "label": "Active Sessions per interval"
                },
                "ySettings": {
                  "min": 0,
                  "label": "Sessions"
                }
              }
            },
            "name": "query - 8"
          },
          {
            "type": 3,
            "content": {
              "version": "KqlItem/1.0",
              "query": "customMetrics\n| where name == \"sessions.active.count\"\n| extend \n    app = tostring(customDimensions[\"session.app\"]),\n    username = tostring(customDimensions[\"session.username\"])\n| summarize SessionCount = sum(value) by username, timestamp\n| where SessionCount > 0",
              "size": 0,
              "aggregation": 2,
              "title": "Active User Sessions Over Time",
              "timeContextFromParameter": "TimeRange",
              "queryType": 0,
              "resourceType": "microsoft.insights/components",
              "visualization": "barchart",
              "chartSettings": {
                "ySettings": {
                  "min": 0
                }
              }
            },
            "name": "query - 9"
          },
          {
            "type": 3,
            "content": {
              "version": "KqlItem/1.0",
              "query": "customMetrics\n| where name == \"sessions.active.count\"\n| extend \n    app = tostring(customDimensions[\"session.app\"])\n| summarize SessionCount = sum(value) by app, timestamp\n| where SessionCount > 0",
              "size": 0,
              "aggregation": 2,
              "title": "Active App Sessions Over Time",
              "timeContextFromParameter": "TimeRange",
              "queryType": 0,
              "resourceType": "microsoft.insights/components",
              "visualization": "barchart"
            },
            "name": "query - 9 - Copy"
          }
        ]
      },
      "name": "Ranged Stats",
      "styleSettings": {
        "showBorder": true
      }
    }
  ],
  "$schema": "https://github.com/Microsoft/Application-Insights-Workbooks/blob/master/schema/workbook.json"
}
