diff --git a/plugins/MicrosoftCopilot/v1/configValidation.json b/plugins/MicrosoftCopilot/v1/configValidation.json new file mode 100644 index 00000000..8138b5a5 --- /dev/null +++ b/plugins/MicrosoftCopilot/v1/configValidation.json @@ -0,0 +1,31 @@ +{ + "steps": [ + { + "displayName": "Licence access", + "dataStream": { + "name": "validationLicences" + }, + "required": true, + "success": "Successfully read licences.", + "error": "Cannot read licences. Check the tenant ID, client ID and secret, and grant the 'LicenseAssignment.Read.All' application permission in Microsoft Entra ID." + }, + { + "displayName": "Usage report access", + "dataStream": { + "name": "validationUsageReports" + }, + "required": false, + "success": "Successfully read Microsoft 365 Copilot usage reports.", + "error": "Cannot read Microsoft 365 Copilot usage reports. Grant the 'Reports.Read.All' application permission in Microsoft Entra ID." + }, + { + "displayName": "Copilot Studio access", + "dataStream": { + "name": "validationPowerPlatform" + }, + "required": false, + "success": "Successfully read Copilot Studio credit capacity.", + "error": "Cannot read Copilot Studio credit capacity. Register the app as a Power Platform management app, as described in the setup guide." + } + ] +} diff --git a/plugins/MicrosoftCopilot/v1/correlationRules/relate-agent-to-owner.json b/plugins/MicrosoftCopilot/v1/correlationRules/relate-agent-to-owner.json new file mode 100644 index 00000000..00d4d1b0 --- /dev/null +++ b/plugins/MicrosoftCopilot/v1/correlationRules/relate-agent-to-owner.json @@ -0,0 +1,20 @@ +{ + "displayName": "Agent is owned by Copilot User", + "source": { + "types": "Agent" + }, + "target": { + "types": "User" + }, + "conditions": [ + { + "sourceProperty": "ownerIds", + "operator": "equals", + "targetProperty": "entraObjectId" + } + ], + "labels": { + "forward": "is owned by", + "reverse": "owns" + } +} diff --git a/plugins/MicrosoftCopilot/v1/custom_types.json b/plugins/MicrosoftCopilot/v1/custom_types.json new file mode 100644 index 00000000..b860279f --- /dev/null +++ b/plugins/MicrosoftCopilot/v1/custom_types.json @@ -0,0 +1,23 @@ +[ + { + "name": "User", + "sourceType": "User", + "icon": "user", + "singular": "Copilot User", + "plural": "Copilot Users" + }, + { + "name": "Environment", + "sourceType": "Environment", + "icon": "layer-group", + "singular": "Environment", + "plural": "Environments" + }, + { + "name": "Agent", + "sourceType": "Agent", + "icon": "robot", + "singular": "Agent", + "plural": "Agents" + } +] diff --git a/plugins/MicrosoftCopilot/v1/dataStreams/adoptionSummary.json b/plugins/MicrosoftCopilot/v1/dataStreams/adoptionSummary.json new file mode 100644 index 00000000..29710d38 --- /dev/null +++ b/plugins/MicrosoftCopilot/v1/dataStreams/adoptionSummary.json @@ -0,0 +1,38 @@ +{ + "name": "adoptionSummary", + "displayName": "Copilot Adoption", + "description": "Enabled and active Copilot users by app over the chosen period", + "tags": ["Adoption", "Usage"], + "baseDataSourceName": "httpRequestUnscoped", + "config": { + "httpMethod": "get", + "endpointPath": "beta/copilot/reports/getMicrosoft365CopilotUserCountSummary(period='{{period || 'D28'}}')", + "postRequestScript": "adoptionSummary.js" + }, + "matches": "none", + "timeframes": false, + "ui": [ + { + "type": "radio", + "name": "period", + "label": "Period", + "defaultValue": "D28", + "options": [ + { "value": "D7", "label": "7 days" }, + { "value": "D28", "label": "28 days" }, + { "value": "D90", "label": "90 days" }, + { "value": "D180", "label": "180 days" } + ] + } + ], + "metadata": [ + { "name": "app", "displayName": "App", "shape": "string", "role": "label" }, + { "name": "enabledUsers", "displayName": "Enabled users", "shape": "number" }, + { "name": "activeUsers", "displayName": "Active users", "shape": "number" }, + { "name": "activeRate", "displayName": "Active rate", "shape": ["percent", { "decimalPlaces": 1 }] }, + { "name": "totalPrompts", "displayName": "Total prompts", "shape": "number" }, + { "name": "averagePrompts", "displayName": "Average prompts per user", "shape": ["number", { "decimalPlaces": 1 }] }, + { "name": "periodDays", "displayName": "Period (days)", "shape": "number" }, + { "name": "reportRefreshDate", "displayName": "Report refresh date", "shape": "date" } + ] +} diff --git a/plugins/MicrosoftCopilot/v1/dataStreams/adoptionTrend.json b/plugins/MicrosoftCopilot/v1/dataStreams/adoptionTrend.json new file mode 100644 index 00000000..f65b364f --- /dev/null +++ b/plugins/MicrosoftCopilot/v1/dataStreams/adoptionTrend.json @@ -0,0 +1,72 @@ +{ + "name": "adoptionTrend", + "displayName": "Copilot Adoption Trend", + "description": "Daily enabled and active Copilot users by app", + "tags": [ + "Adoption", + "Usage" + ], + "baseDataSourceName": "httpRequestUnscoped", + "config": { + "httpMethod": "get", + "endpointPath": "beta/copilot/reports/getMicrosoft365CopilotUserCountTrend(period='{{period || 'D28'}}')", + "postRequestScript": "adoptionTrend.js" + }, + "matches": "none", + "timeframes": false, + "ui": [ + { + "type": "radio", + "name": "period", + "label": "Period", + "defaultValue": "D28", + "options": [ + { + "value": "D7", + "label": "7 days" + }, + { + "value": "D28", + "label": "28 days" + }, + { + "value": "D90", + "label": "90 days" + }, + { + "value": "D180", + "label": "180 days" + } + ] + } + ], + "metadata": [ + { + "name": "reportDate", + "displayName": "Date", + "shape": "date", + "role": "timestamp" + }, + { + "name": "app", + "displayName": "App", + "shape": "string", + "role": "label" + }, + { + "name": "enabledUsers", + "displayName": "Enabled users", + "shape": "number" + }, + { + "name": "activeUsers", + "displayName": "Active users", + "shape": "number" + }, + { + "name": "promptsSubmitted", + "displayName": "Prompts submitted", + "shape": "number" + } + ] +} diff --git a/plugins/MicrosoftCopilot/v1/dataStreams/agentDetails.json b/plugins/MicrosoftCopilot/v1/dataStreams/agentDetails.json new file mode 100644 index 00000000..4aa3e906 --- /dev/null +++ b/plugins/MicrosoftCopilot/v1/dataStreams/agentDetails.json @@ -0,0 +1,103 @@ +{ + "name": "agentDetails", + "displayName": "Agent Usage", + "description": "Active users, sessions, run time and exceptions over the last 30 days, last use and sharing for an agent in the Microsoft Agent 365 registry (needs Microsoft Agent 365)", + "tags": [ + "Agents", + "Adoption" + ], + "baseDataSourceName": "httpRequestScopedSingle", + "config": { + "httpMethod": "get", + "endpointPath": "v1.0/copilot/admin/catalog/packages/{{object.rawId}}", + "postRequestScript": "agentDetails.js" + }, + "matches": { + "sourceType": { + "type": "oneOf", + "values": [ + "Agent" + ] + } + }, + "timeframes": false, + "metadata": [ + { + "name": "displayName", + "displayName": "Agent", + "shape": "string", + "role": "label" + }, + { + "name": "activeUsers", + "displayName": "Active users (30 days)", + "shape": "number" + }, + { + "name": "totalSessions", + "displayName": "Sessions (30 days)", + "shape": "number" + }, + { + "name": "totalRunTimeInHours", + "displayName": "Run time, hours (30 days)", + "shape": [ + "number", + { + "decimalPlaces": 1 + } + ] + }, + { + "name": "lastUsedDateTime", + "displayName": "Last used", + "shape": "date" + }, + { + "name": "daysSinceUsed", + "displayName": "Days since used", + "shape": "number" + }, + { + "name": "exceptions", + "displayName": "Exceptions (30 days)", + "shape": "number" + }, + { + "name": "sensitivity", + "displayName": "Sensitivity", + "shape": "string" + }, + { + "name": "categories", + "displayName": "Categories", + "shape": [ + "array", + { + "itemShape": "string" + } + ] + }, + { + "name": "sharedWithCount", + "displayName": "Shared with (users and groups)", + "shape": "number" + }, + { + "name": "allowedCount", + "displayName": "Allowed users and groups", + "shape": "number" + }, + { + "name": "longDescription", + "displayName": "Description", + "shape": "string" + }, + { + "name": "id", + "displayName": "Package ID", + "shape": "string", + "visible": false + } + ] +} diff --git a/plugins/MicrosoftCopilot/v1/dataStreams/agents.json b/plugins/MicrosoftCopilot/v1/dataStreams/agents.json new file mode 100644 index 00000000..1b9da94e --- /dev/null +++ b/plugins/MicrosoftCopilot/v1/dataStreams/agents.json @@ -0,0 +1,178 @@ +{ + "name": "agents", + "displayName": "Agents", + "description": "Agents in the Microsoft Agent 365 registry, with type, platform, publisher, availability, blocking and owners (needs Microsoft Agent 365)", + "tags": [ + "Agents", + "Governance" + ], + "baseDataSourceName": "httpRequestUnscoped", + "config": { + "httpMethod": "get", + "endpointPath": "v1.0/copilot/admin/catalog/packages", + "postRequestScript": "agents.js", + "paging": { + "mode": "nextUrl", + "pageSize": { + "realm": "none" + }, + "in": { + "realm": "payload", + "path": "@odata.nextLink" + } + } + }, + "matches": "none", + "timeframes": false, + "ui": [ + { + "type": "objects", + "name": "agents", + "label": "Agent (optional)", + "matches": { + "sourceType": { + "type": "oneOf", + "values": [ + "Agent" + ] + } + } + } + ], + "metadata": [ + { + "name": "displayName", + "displayName": "Agent", + "shape": "string", + "role": "label" + }, + { + "name": "ownershipState", + "displayName": "Ownership state", + "shape": [ + "state", + { + "map": { + "success": [ + "success" + ], + "error": [ + "error" + ] + } + } + ] + }, + { + "name": "ownershipStatus", + "displayName": "Ownership", + "shape": "string" + }, + { + "name": "agentType", + "displayName": "Type", + "shape": "string" + }, + { + "name": "platform", + "displayName": "Platform", + "shape": "string" + }, + { + "name": "publisher", + "displayName": "Publisher", + "shape": "string" + }, + { + "name": "availableTo", + "displayName": "Available to", + "shape": "string" + }, + { + "name": "deployedTo", + "displayName": "Deployed to", + "shape": "string" + }, + { + "name": "isBlocked", + "displayName": "Blocked", + "shape": "boolean" + }, + { + "name": "ownerIds", + "displayName": "Owners", + "shape": [ + "array", + { + "itemShape": "string" + } + ], + "sourceType": "User", + "sourceLookup": { + "property": "entraObjectId" + } + }, + { + "name": "ownerCount", + "displayName": "Owner count", + "shape": "number" + }, + { + "name": "createdDateTime", + "displayName": "Created", + "shape": "date" + }, + { + "name": "lastModifiedDateTime", + "displayName": "Last updated", + "shape": "date" + }, + { + "name": "daysSinceModified", + "displayName": "Days since updated", + "shape": "number" + }, + { + "name": "elementTypes", + "displayName": "Element types", + "shape": [ + "array", + { + "itemShape": "string" + } + ] + }, + { + "name": "supportedHosts", + "displayName": "Supported hosts", + "shape": [ + "array", + { + "itemShape": "string" + } + ] + }, + { + "name": "shortDescription", + "displayName": "Description", + "shape": "string" + }, + { + "name": "version", + "displayName": "Version", + "shape": "string" + }, + { + "name": "appId", + "displayName": "App ID", + "shape": "string", + "visible": false + }, + { + "name": "id", + "displayName": "Package ID", + "shape": "string", + "visible": false + } + ] +} diff --git a/plugins/MicrosoftCopilot/v1/dataStreams/aiAppPermissions.json b/plugins/MicrosoftCopilot/v1/dataStreams/aiAppPermissions.json new file mode 100644 index 00000000..73116834 --- /dev/null +++ b/plugins/MicrosoftCopilot/v1/dataStreams/aiAppPermissions.json @@ -0,0 +1,92 @@ +{ + "name": "aiAppPermissions", + "displayName": "AI App Permissions", + "description": "Permissions held by AI apps people sign in to with Microsoft Entra: delegated grants for all users or individual users, and application permissions, with the API each is granted on and whether it goes beyond sign-in", + "tags": [ + "Security", + "Governance" + ], + "baseDataSourceName": "httpRequestUnscoped", + "config": { + "httpMethod": "get", + "endpointPath": "beta/reports/getAzureADApplicationSignInSummary(period='D30')", + "postRequestScript": "aiAppPermissions.js" + }, + "matches": "none", + "timeframes": false, + "metadata": [ + { + "name": "appDisplayName", + "displayName": "App", + "shape": "string", + "role": "label" + }, + { + "name": "aiVendor", + "displayName": "AI vendor", + "shape": "string" + }, + { + "name": "publisher", + "displayName": "Publisher", + "shape": "string" + }, + { + "name": "verifiedPublisher", + "displayName": "Verified publisher", + "shape": "boolean" + }, + { + "name": "resource", + "displayName": "Granted on", + "shape": "string" + }, + { + "name": "permissionType", + "displayName": "Permission type", + "shape": "string" + }, + { + "name": "grantedTo", + "displayName": "Granted to", + "shape": "string" + }, + { + "name": "userDisplayName", + "displayName": "User", + "shape": "string" + }, + { + "name": "userPrincipalName", + "displayName": "User principal name", + "shape": "string" + }, + { + "name": "permissions", + "displayName": "Permissions", + "shape": [ + "array", + { + "itemShape": "string" + } + ] + }, + { + "name": "beyondSignIn", + "displayName": "Access beyond sign-in", + "shape": "boolean" + }, + { + "name": "principalId", + "displayName": "User ID", + "shape": "string", + "visible": false + }, + { + "name": "appId", + "displayName": "Application (client) ID", + "shape": "string", + "visible": false + } + ] +} diff --git a/plugins/MicrosoftCopilot/v1/dataStreams/appSignIns.json b/plugins/MicrosoftCopilot/v1/dataStreams/appSignIns.json new file mode 100644 index 00000000..de0f5f1b --- /dev/null +++ b/plugins/MicrosoftCopilot/v1/dataStreams/appSignIns.json @@ -0,0 +1,105 @@ +{ + "name": "appSignIns", + "displayName": "AI App Sign-ins", + "description": "Microsoft Entra sign-ins per application over the period, with AI apps and their vendor picked out by name (apps that sign in with Microsoft Entra only)", + "tags": [ + "Adoption", + "Security" + ], + "baseDataSourceName": "httpRequestUnscoped", + "config": { + "httpMethod": "get", + "endpointPath": "beta/reports/getAzureADApplicationSignInSummary(period='{{period || 'D30'}}')", + "postRequestScript": "appSignIns.js", + "paging": { + "mode": "nextUrl", + "pageSize": { + "realm": "none" + }, + "in": { + "realm": "payload", + "path": "@odata.nextLink" + } + } + }, + "matches": "none", + "timeframes": false, + "ui": [ + { + "type": "radio", + "name": "period", + "label": "Period", + "defaultValue": "D30", + "options": [ + { + "value": "D7", + "label": "7 days" + }, + { + "value": "D30", + "label": "30 days" + } + ] + }, + { + "type": "radio", + "name": "apps", + "label": "Apps", + "defaultValue": "ai", + "options": [ + { + "value": "ai", + "label": "AI apps" + }, + { + "value": "all", + "label": "All apps" + } + ] + } + ], + "metadata": [ + { + "name": "appDisplayName", + "displayName": "App", + "shape": "string", + "role": "label" + }, + { + "name": "aiVendor", + "displayName": "AI vendor", + "shape": "string" + }, + { + "name": "successfulSignInCount", + "displayName": "Successful sign-ins", + "shape": "number" + }, + { + "name": "failedSignInCount", + "displayName": "Failed sign-ins", + "shape": "number" + }, + { + "name": "totalSignInCount", + "displayName": "Sign-ins", + "shape": "number" + }, + { + "name": "successPercentage", + "displayName": "Success %", + "shape": [ + "percent", + { + "decimalPlaces": 1 + } + ] + }, + { + "name": "appId", + "displayName": "Application (client) ID", + "shape": "string", + "visible": false + } + ] +} diff --git a/plugins/MicrosoftCopilot/v1/dataStreams/budgets.json b/plugins/MicrosoftCopilot/v1/dataStreams/budgets.json new file mode 100644 index 00000000..42cfed0e --- /dev/null +++ b/plugins/MicrosoftCopilot/v1/dataStreams/budgets.json @@ -0,0 +1,146 @@ +{ + "name": "budgets", + "displayName": "Cost Budgets", + "description": "Cost Management budgets at the Cost Management scope, with spend and forecast against each budget this period", + "tags": [ + "Cost" + ], + "baseDataSourceName": "httpRequestUnscoped", + "config": { + "httpMethod": "get", + "baseUrl": "https://management.azure.com", + "endpointPath": "{{dataSource.costScope}}/providers/Microsoft.Consumption/budgets", + "getArgs": [ + { + "key": "api-version", + "value": "2023-05-01" + } + ], + "paging": { + "mode": "nextUrl", + "in": { + "realm": "payload", + "path": "nextLink" + } + }, + "errorHandling": { + "type": "script", + "script": "errorHandling/costManagement.js" + }, + "postRequestScript": "budgets.js" + }, + "matches": "none", + "timeframes": false, + "metadata": [ + { + "name": "name", + "displayName": "Budget", + "shape": "string", + "role": "label" + }, + { + "name": "budgetState", + "displayName": "State", + "shape": [ + "state", + { + "map": { + "success": [ + "success" + ], + "warning": [ + "warning" + ], + "error": [ + "error" + ], + "unknown": [ + "unknown" + ] + } + } + ] + }, + { + "name": "amount", + "displayName": "Budget amount", + "shape": "number" + }, + { + "name": "currentSpend", + "displayName": "Spent", + "shape": "number" + }, + { + "name": "forecastSpend", + "displayName": "Forecast (period end)", + "shape": "number" + }, + { + "name": "currency", + "displayName": "Currency", + "shape": "string" + }, + { + "name": "percentUsed", + "displayName": "Used %", + "shape": [ + "percent", + { + "decimalPlaces": 1 + } + ] + }, + { + "name": "percentForecast", + "displayName": "Forecast % (period end)", + "shape": [ + "percent", + { + "decimalPlaces": 1 + } + ] + }, + { + "name": "timeGrain", + "displayName": "Reset period", + "shape": "string" + }, + { + "name": "category", + "displayName": "Category", + "shape": "string" + }, + { + "name": "filters", + "displayName": "Filters", + "shape": [ + "array", + { + "itemShape": "string" + } + ] + }, + { + "name": "periodStart", + "displayName": "Period start", + "shape": "date" + }, + { + "name": "periodEnd", + "displayName": "Period end", + "shape": "date" + }, + { + "name": "endDate", + "displayName": "Budget expires", + "shape": "date" + }, + { + "name": "id", + "displayName": "Budget ID", + "shape": "string", + "visible": false + } + ] +} diff --git a/plugins/MicrosoftCopilot/v1/dataStreams/creditCapacity.json b/plugins/MicrosoftCopilot/v1/dataStreams/creditCapacity.json new file mode 100644 index 00000000..079e0041 --- /dev/null +++ b/plugins/MicrosoftCopilot/v1/dataStreams/creditCapacity.json @@ -0,0 +1,96 @@ +{ + "name": "creditCapacity", + "displayName": "Copilot Credit Capacity", + "description": "Prepaid and pay-as-you-go Copilot Credit usage for the tenant this month", + "tags": [ + "Capacity", + "Cost" + ], + "baseDataSourceName": "httpRequestUnscoped", + "config": { + "httpMethod": "get", + "baseUrl": "https://api.powerplatform.com", + "endpointPath": "licensing/entitlements/MCSMessages", + "pathToData": "entitlement", + "getArgs": [ + { + "key": "api-version", + "value": "2024-10-01" + } + ], + "expandInnerObjects": true + }, + "matches": "none", + "timeframes": false, + "metadata": [ + { + "name": "capacity.entitled.value", + "displayName": "Prepaid credits", + "shape": "number" + }, + { + "name": "capacity.consumed.value", + "displayName": "Prepaid consumed", + "shape": "number" + }, + { + "name": "capacity.allocated.value", + "displayName": "Allocated to environments", + "shape": "number" + }, + { + "name": "capacity.availableQuantity", + "displayName": "Available", + "shape": "number" + }, + { + "name": "prepaidPercentConsumed", + "displayName": "Prepaid consumed %", + "shape": [ + "percent", + { + "decimalPlaces": 1 + } + ], + "computed": true, + "valueExpression": "{{ Number($['capacity.entitled.value']) > 0 ? (Number($['capacity.consumed.value']) / Number($['capacity.entitled.value'])) * 100 : null }}" + }, + { + "name": "capacityState", + "displayName": "Capacity state", + "shape": [ + "state", + { + "map": { + "success": [ + "WithinCapacity" + ], + "warning": [ + "CoveredOverage" + ], + "error": [ + "Overage" + ] + } + } + ], + "computed": true, + "valueExpression": "{{ $['capacity.status'] }}" + }, + { + "name": "capacity.status", + "displayName": "Capacity status", + "shape": "string" + }, + { + "name": "payGo.consumed.value", + "displayName": "Pay-as-you-go consumed", + "shape": "number" + }, + { + "name": "capacity.consumed.lastUpdatedOn", + "displayName": "Last updated", + "shape": "date" + } + ] +} diff --git a/plugins/MicrosoftCopilot/v1/dataStreams/emissions.json b/plugins/MicrosoftCopilot/v1/dataStreams/emissions.json new file mode 100644 index 00000000..2fea3a62 --- /dev/null +++ b/plugins/MicrosoftCopilot/v1/dataStreams/emissions.json @@ -0,0 +1,100 @@ +{ + "name": "emissions", + "displayName": "Copilot Emissions", + "description": "Monthly carbon emissions from Microsoft 365 Copilot use, by datacenter region and emissions scope (Microsoft Graph beta)", + "tags": [ + "Sustainability" + ], + "baseDataSourceName": "httpRequestUnscoped", + "config": { + "httpMethod": "get", + "endpointPath": "beta/copilot/reports/getMicrosoft365CopilotEmissions", + "pathToData": "value", + "paging": { + "mode": "nextUrl", + "pageSize": { + "realm": "none" + }, + "in": { + "realm": "payload", + "path": "@odata.nextLink" + } + } + }, + "matches": "none", + "timeframes": false, + "metadata": [ + { + "name": "monthStart", + "displayName": "Month", + "shape": "date", + "role": "timestamp", + "computed": true, + "valueExpression": "{{ $['month'] ? $['month'] + '-01T00:00:00Z' : null }}" + }, + { + "name": "region", + "displayName": "Region", + "shape": "string", + "role": "label" + }, + { + "name": "totalEmissions", + "displayName": "Total emissions (location-based)", + "shape": [ + "number", + { + "decimalPlaces": 6 + } + ], + "computed": true, + "valueExpression": "{{ Number($['scope1Emissions'] || 0) + Number($['scope2LocationBasedEmissions'] || 0) + Number($['scope3Emissions'] || 0) }}" + }, + { + "name": "scope1Emissions", + "displayName": "Scope 1", + "shape": [ + "number", + { + "decimalPlaces": 6 + } + ] + }, + { + "name": "scope2LocationBasedEmissions", + "displayName": "Scope 2 (location-based)", + "shape": [ + "number", + { + "decimalPlaces": 6 + } + ] + }, + { + "name": "scope2MarketBasedEmissions", + "displayName": "Scope 2 (market-based)", + "shape": [ + "number", + { + "decimalPlaces": 6 + } + ] + }, + { + "name": "scope3Emissions", + "displayName": "Scope 3", + "shape": [ + "number", + { + "decimalPlaces": 6 + } + ] + }, + { + "name": "month", + "displayName": "Month (raw)", + "shape": "string", + "visible": false + } + ] +} diff --git a/plugins/MicrosoftCopilot/v1/dataStreams/environmentCapacity.json b/plugins/MicrosoftCopilot/v1/dataStreams/environmentCapacity.json new file mode 100644 index 00000000..72ff27fb --- /dev/null +++ b/plugins/MicrosoftCopilot/v1/dataStreams/environmentCapacity.json @@ -0,0 +1,61 @@ +{ + "name": "environmentCapacity", + "displayName": "Environment Credit Allocations", + "description": "Capacity allocated to each environment, by currency", + "tags": [ + "Capacity", + "Environment" + ], + "baseDataSourceName": "httpRequestScoped", + "config": { + "httpMethod": "get", + "baseUrl": "https://api.powerplatform.com", + "endpointPath": "licensing/tenantCapacity/currencyReports", + "getArgs": [ + { + "key": "api-version", + "value": "2024-10-01" + } + ], + "postRequestScript": "environmentCapacity.js" + }, + "matches": { + "sourceType": { + "type": "oneOf", + "values": [ + "Environment" + ] + } + }, + "timeframes": false, + "metadata": [ + { + "name": "environmentName", + "displayName": "Environment", + "shape": "string", + "role": "label" + }, + { + "name": "environmentId", + "displayName": "Environment ID", + "shape": "string", + "visible": false + }, + { + "name": "currency", + "displayName": "Currency", + "shape": "string" + }, + { + "name": "allocated", + "displayName": "Allocated", + "shape": "number" + }, + { + "name": "currencyType", + "displayName": "Currency type", + "shape": "string", + "visible": false + } + ] +} diff --git a/plugins/MicrosoftCopilot/v1/dataStreams/environments.json b/plugins/MicrosoftCopilot/v1/dataStreams/environments.json new file mode 100644 index 00000000..c3506ff6 --- /dev/null +++ b/plugins/MicrosoftCopilot/v1/dataStreams/environments.json @@ -0,0 +1,33 @@ +{ + "name": "environments", + "displayName": "Environments", + "description": "Power Platform environments, where Copilot Studio agents are built", + "tags": ["Environment"], + "baseDataSourceName": "httpRequestUnscoped", + "config": { + "httpMethod": "get", + "baseUrl": "https://api.bap.microsoft.com", + "endpointPath": "providers/Microsoft.BusinessAppPlatform/scopes/admin/environments", + "pathToData": "value", + "expandInnerObjects": true, + "getArgs": [{ "key": "api-version", "value": "2021-04-01" }], + "paging": { + "mode": "nextUrl", + "in": { "realm": "payload", "path": "nextLink" } + } + }, + "matches": "none", + "timeframes": false, + "visibility": { "type": "hidden" }, + "metadata": [ + { "name": "name", "displayName": "Environment ID", "shape": "string", "visible": false }, + { "name": "properties.displayName", "displayName": "Name", "shape": "string", "role": "label" }, + { "name": "properties.environmentSku", "displayName": "Type", "shape": "string" }, + { "name": "location", "displayName": "Geography", "shape": "string" }, + { "name": "properties.azureRegion", "displayName": "Azure region", "shape": "string" }, + { "name": "properties.isDefault", "displayName": "Default", "shape": "boolean" }, + { "name": "properties.states.management.id", "displayName": "Status", "shape": "string" }, + { "name": "properties.linkedEnvironmentMetadata.instanceUrl", "displayName": "Dataverse URL", "shape": "url" }, + { "name": "properties.createdTime", "displayName": "Created", "shape": "date" } + ] +} diff --git a/plugins/MicrosoftCopilot/v1/dataStreams/licences.json b/plugins/MicrosoftCopilot/v1/dataStreams/licences.json new file mode 100644 index 00000000..8fad0330 --- /dev/null +++ b/plugins/MicrosoftCopilot/v1/dataStreams/licences.json @@ -0,0 +1,27 @@ +{ + "name": "licences", + "displayName": "Copilot Licences", + "description": "Copilot licences purchased and assigned in the tenant", + "tags": ["Licence"], + "baseDataSourceName": "httpRequestUnscoped", + "config": { + "httpMethod": "get", + "endpointPath": "v1.0/subscribedSkus", + "postRequestScript": "licences.js" + }, + "matches": "none", + "timeframes": false, + "metadata": [ + { "name": "skuPartNumber", "displayName": "SKU", "shape": "string", "role": "label" }, + { "name": "skuId", "displayName": "SKU ID", "shape": "guid", "visible": false }, + { "name": "purchased", "displayName": "Purchased", "shape": "number" }, + { "name": "assigned", "displayName": "Assigned", "shape": "number" }, + { "name": "available", "displayName": "Available", "shape": "number" }, + { "name": "utilisation", "displayName": "Utilisation", "shape": ["percent", { "decimalPlaces": 1 }] }, + { "name": "suspended", "displayName": "Suspended", "shape": "number" }, + { "name": "warning", "displayName": "Warning", "shape": "number" }, + { "name": "capabilityStatus", "displayName": "Capability status", "shape": "string" }, + { "name": "copilotPlans", "displayName": "Copilot service plans", "shape": ["array", { "itemShape": "string" }] }, + { "name": "pattern", "pattern": ".*", "visible": false } + ] +} diff --git a/plugins/MicrosoftCopilot/v1/dataStreams/scripts/adoptionSummary.js b/plugins/MicrosoftCopilot/v1/dataStreams/scripts/adoptionSummary.js new file mode 100644 index 00000000..ca5b03e3 --- /dev/null +++ b/plugins/MicrosoftCopilot/v1/dataStreams/scripts/adoptionSummary.js @@ -0,0 +1,34 @@ +// One row per app. Prompt totals are tenant-level, so they are only set on the "Any app" row. +const APPS = [ + ["microsoftTeams", "Teams"], + ["word", "Word"], + ["excel", "Excel"], + ["powerPoint", "PowerPoint"], + ["outlook", "Outlook"], + ["oneNote", "OneNote"], + ["loop", "Loop"], + ["copilotChatWork", "Copilot Chat (work)"], + ["copilotChatWeb", "Copilot Chat (web)"], + ["copilotChat", "Copilot Chat (all)"], + ["m365App", "Microsoft 365 app"], + ["edge", "Edge"], + ["anyApp", "Any app"], +]; +const report = (data && data.value && data.value[0]) || {}; +const a = (report.adoptionByProduct && report.adoptionByProduct[0]) || {}; +const days = parseInt(String(a.reportPeriod || "").replace(/[^0-9]/g, ""), 10); +result = APPS.filter(([key]) => a[key + "EnabledUsers"] !== undefined).map(([key, name]) => { + const enabled = a[key + "EnabledUsers"]; + const active = a[key + "ActiveUsers"]; + const isAny = key === "anyApp"; + return { + app: name, + enabledUsers: enabled, + activeUsers: active, + activeRate: enabled > 0 ? (active / enabled) * 100 : null, + totalPrompts: isAny ? a.totalPromptsSubmitted : null, + averagePrompts: isAny ? a.averagePromptsSubmitted : null, + periodDays: Number.isNaN(days) ? null : days, + reportRefreshDate: report.reportRefreshDate, + }; +}); diff --git a/plugins/MicrosoftCopilot/v1/dataStreams/scripts/adoptionTrend.js b/plugins/MicrosoftCopilot/v1/dataStreams/scripts/adoptionTrend.js new file mode 100644 index 00000000..0e9d7b49 --- /dev/null +++ b/plugins/MicrosoftCopilot/v1/dataStreams/scripts/adoptionTrend.js @@ -0,0 +1,28 @@ +// One row per report date x app. Tenant-level prompts are only set on the "Any app" row. +const APPS = [ + ["microsoftTeams", "Teams"], + ["word", "Word"], + ["excel", "Excel"], + ["powerPoint", "PowerPoint"], + ["outlook", "Outlook"], + ["oneNote", "OneNote"], + ["loop", "Loop"], + ["copilotChatWork", "Copilot Chat (work)"], + ["copilotChatWeb", "Copilot Chat (web)"], + ["copilotChat", "Copilot Chat (all)"], + ["m365App", "Microsoft 365 app"], + ["edge", "Edge"], + ["anyApp", "Any app"], +]; +const days = ((data && data.value && data.value[0] && data.value[0].adoptionByDate) || []) + .slice() + .sort((a, b) => String(a.reportDate).localeCompare(String(b.reportDate))); +result = days.flatMap((day) => + APPS.filter(([key]) => day[key + "EnabledUsers"] !== undefined).map(([key, name]) => ({ + reportDate: day.reportDate, + app: name, + enabledUsers: day[key + "EnabledUsers"], + activeUsers: day[key + "ActiveUsers"], + promptsSubmitted: key === "anyApp" ? day.promptsSubmitted : null, + })), +); diff --git a/plugins/MicrosoftCopilot/v1/dataStreams/scripts/agentDetails.js b/plugins/MicrosoftCopilot/v1/dataStreams/scripts/agentDetails.js new file mode 100644 index 00000000..b24f9f14 --- /dev/null +++ b/plugins/MicrosoftCopilot/v1/dataStreams/scripts/agentDetails.js @@ -0,0 +1,23 @@ +// One row for the agent: the registry's usage figures for it, each over the last 30 days. +// Despite its name, exceptionRate is the number of exceptions in that time (Microsoft's docs). +const DAY = 86400000; +const p = data || {}; +const used = p.lastUsedDateTime ? new Date(p.lastUsedDateTime) : null; +const count = (v) => (Array.isArray(v) ? v.length : null); +result = [ + { + id: p.id, + displayName: p.displayName || p.id, + activeUsers: typeof p.activeUsers === "number" ? p.activeUsers : null, + totalSessions: typeof p.totalSessions === "number" ? p.totalSessions : null, + totalRunTimeInHours: typeof p.totalRunTimeInHours === "number" ? p.totalRunTimeInHours : null, + lastUsedDateTime: p.lastUsedDateTime || null, + daysSinceUsed: used ? Math.floor((Date.now() - used) / DAY) : null, + exceptions: typeof p.exceptionRate === "number" ? p.exceptionRate : null, + sensitivity: p.sensitivity || null, + categories: p.categories || [], + sharedWithCount: count(p.sharedWithUsersAndGroups), + allowedCount: count(p.allowedUsersAndGroups), + longDescription: p.longDescription || p.shortDescription || null, + }, +]; diff --git a/plugins/MicrosoftCopilot/v1/dataStreams/scripts/agents.js b/plugins/MicrosoftCopilot/v1/dataStreams/scripts/agents.js new file mode 100644 index 00000000..f8e58b33 --- /dev/null +++ b/plugins/MicrosoftCopilot/v1/dataStreams/scripts/agents.js @@ -0,0 +1,38 @@ +// One row per agent in the Microsoft Agent 365 registry. Owners arrive as directory IDs and are +// kept as a list: they link to imported Copilot Users (by Entra object ID) where the owner holds +// a Copilot licence. Optional `agents` object picker narrows the rows to the selected agents. +const DAY = 86400000; +const unwrap = (v) => (Array.isArray(v) ? v[0] : v); +const selected = (context.config && context.config.agents) || []; +const wanted = new Set(selected.map((o) => String(unwrap(o.rawId) ?? "")).filter(Boolean)); + +result = ((data && data.value) || []) + .filter((p) => !wanted.size || wanted.has(String(p.id))) + .map((p) => { + const ownerIds = [ + ...new Set([p.ownerId, ...(p.owners || []).map((o) => o && o.resourceId)].filter(Boolean)), + ]; + const modified = p.lastModifiedDateTime ? Date.parse(p.lastModifiedDateTime) : NaN; + return { + id: p.id, + displayName: p.displayName || p.id, + ownershipStatus: ownerIds.length ? "OK" : "No owner", + ownershipState: ownerIds.length ? "success" : "error", + agentType: p.type || null, + platform: p.platform || null, + publisher: p.publisher || null, + shortDescription: p.shortDescription || null, + isBlocked: typeof p.isBlocked === "boolean" ? p.isBlocked : null, + availableTo: p.availableTo || null, + deployedTo: p.deployedTo || null, + elementTypes: p.elementTypes || [], + supportedHosts: p.supportedHosts || [], + ownerIds, + ownerCount: ownerIds.length, + createdDateTime: p.createdDateTime || null, + lastModifiedDateTime: p.lastModifiedDateTime || null, + daysSinceModified: isNaN(modified) ? null : Math.floor((Date.now() - modified) / DAY), + version: p.version || null, + appId: p.appId || null, + }; + }); diff --git a/plugins/MicrosoftCopilot/v1/dataStreams/scripts/aiAppPermissions.js b/plugins/MicrosoftCopilot/v1/dataStreams/scripts/aiAppPermissions.js new file mode 100644 index 00000000..4a5cbb13 --- /dev/null +++ b/plugins/MicrosoftCopilot/v1/dataStreams/scripts/aiAppPermissions.js @@ -0,0 +1,196 @@ +// What AI apps have been allowed to do with Microsoft 365 data. The first request, the +// application sign-in summary for the last 30 days, finds the AI apps people use (by name, as in +// AI App Sign-ins). For each, its service principal (Application.Read.All) gives the publisher +// and the application permissions it holds, and its delegated permission grants +// (DelegatedPermissionGrant.Read.All) show whether it was consented for everyone or by +// individual users (User.Read.All resolves who). One row per grant. +// Matching avoids regex escapes (templating strips backslashes): names are split into words. +const VENDORS = [ + ["GitHub Copilot", { text: ["github copilot"] }], + ["Microsoft Copilot", { text: ["copilot"] }], + ["Anthropic", { text: ["claude", "anthropic"] }], + ["OpenAI", { text: ["openai", "chatgpt", "codex"], words: ["gpt"] }], + ["Google", { text: ["gemini", "notebooklm"], words: ["bard"] }], + ["Perplexity", { text: ["perplexity"] }], + ["Mistral", { text: ["mistral"] }], + ["xAI", { words: ["grok", "xai"] }], + ["DeepSeek", { text: ["deepseek"] }], + ["Cursor", { words: ["cursor"] }], + ["Glean", { words: ["glean"] }], + ["Other AI", { words: ["ai", "llm", "agent", "agents"], suffix: [".ai"] }], +]; +const vendorOf = (name) => { + const lower = name.toLowerCase(); + const words = lower.split(/[^a-z0-9]+/).filter(Boolean); + const dotted = lower.split(/[^a-z0-9.]+/).filter(Boolean); + const hit = VENDORS.find( + ([, m]) => + (m.text || []).some((t) => lower.includes(t)) || + (m.words || []).some((w) => words.includes(w)) || + (m.suffix || []).some((x) => dotted.some((d) => d.endsWith(x))), + ); + return hit ? hit[0] : null; +}; + +// Scopes that only identify the user. Anything else is access beyond sign-in, to Microsoft Graph +// or whichever API the grant is on (the resource column says which). +const SIGN_IN_ONLY = ["openid", "profile", "email", "offline_access", "user.read"]; +const describe = (err) => (err && err.message ? err.message : String(err)); +const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)); + +// A throttled request (429) is retried after the Retry-After Graph gives. A wait longer than the +// script can afford isn't shortened (that would only be throttled again): the request is given up +// and the result reported as incomplete. +const MAX_WAIT_MS = 10000; +const get = async (path) => { + const link = path.startsWith("https://") ? path : `https://${url.host}${path}`; + for (let attempt = 1; ; attempt++) { + let resp; + try { + resp = await fetch(link, { + headers: { Authorization: headers.Authorization, Accept: "application/json" }, + }); + } catch (err) { + return { ok: false, status: 0, body: { error: { message: describe(err) } } }; + } + const waitMs = Number(resp.headers.get("Retry-After") || 1) * 1000; + if (resp.status === 429 && attempt < 3 && waitMs <= MAX_WAIT_MS) { + await sleep(waitMs); + continue; + } + return { ok: resp.ok, status: resp.status, body: await resp.json().catch(() => ({})) }; + } +}; +// Follows @odata.nextLink to the end. Pages read before a failure are kept, and the failure +// is returned so the result can be reported as incomplete. +const getAll = async (path) => { + const items = []; + let next = path; + while (next) { + const r = await get(next); + if (!r.ok) { + return { items, failure: r }; + } + items.push(...(r.body.value || [])); + next = r.body["@odata.nextLink"]; + } + return { items, failure: null }; +}; +const problems = new Set(); +const note = (what, r) => + problems.add(`${what}: ${(r.body.error && r.body.error.message) || "HTTP " + r.status}`); + +const aiApps = (data.value || []) + .map((a) => ({ appId: a.id, name: String(a.appDisplayName || "") })) + .filter((a) => a.appId && vendorOf(a.name)); + +const rows = []; +const userIds = new Set(); +// The APIs that permissions are granted on (Microsoft Graph, or an MCP server), by ID +const resources = new Map(); +const resourceOf = async (resourceId) => { + if (!resources.has(resourceId)) { + const r = await get(`/v1.0/servicePrincipals/${resourceId}?$select=displayName,appRoles`); + if (!r.ok) { + // The grant is still listed; only its API name and role names are missing + note("Couldn't read some APIs that permissions are granted on", r); + } + resources.set(resourceId, { + name: (r.ok && r.body.displayName) || null, + roles: new Map(((r.ok && r.body.appRoles) || []).map((x) => [x.id, x.value])), + }); + } + return resources.get(resourceId); +}; + +for (const app of aiApps) { + const spResp = await get( + `/v1.0/servicePrincipals?$filter=appId eq '${app.appId}'&$select=id,displayName,publisherName,verifiedPublisher,appOwnerOrganizationId`, + ); + if (!spResp.ok) { + note("Couldn't read AI app details", spResp); + continue; + } + const sp = (spResp.body.value || [])[0]; + if (!sp) { + continue; + } + const base = { + appDisplayName: sp.displayName || app.name, + aiVendor: vendorOf(sp.displayName || app.name), + publisher: (sp.verifiedPublisher && sp.verifiedPublisher.displayName) || sp.publisherName || null, + verifiedPublisher: !!(sp.verifiedPublisher && sp.verifiedPublisher.displayName), + appId: app.appId, + }; + + const grants = await getAll(`/v1.0/oauth2PermissionGrants?$filter=clientId eq '${sp.id}'`); + if (grants.failure) { + note("Couldn't read all delegated permission grants", grants.failure); + } + for (const g of grants.items) { + const scopes = String(g.scope || "").split(" ").filter(Boolean); + if (g.principalId) { + userIds.add(g.principalId); + } + rows.push({ + ...base, + resource: (await resourceOf(g.resourceId)).name, + permissionType: "Delegated", + grantedTo: g.consentType === "AllPrincipals" ? "All users" : "One user", + principalId: g.principalId || null, + permissions: scopes, + beyondSignIn: scopes.some((s) => !SIGN_IN_ONLY.includes(s.toLowerCase())), + }); + } + + const roles = await getAll(`/v1.0/servicePrincipals/${sp.id}/appRoleAssignments`); + if (roles.failure) { + note("Couldn't read all application permissions", roles.failure); + } + const byResource = new Map(); + for (const a of roles.items) { + const list = byResource.get(a.resourceId) || { resource: a.resourceDisplayName, roles: [] }; + list.roles.push((await resourceOf(a.resourceId)).roles.get(a.appRoleId) || a.appRoleId); + byResource.set(a.resourceId, list); + } + for (const { resource, roles: names } of byResource.values()) { + rows.push({ + ...base, + resource, + permissionType: "Application", + grantedTo: "The app itself", + principalId: null, + permissions: names, + beyondSignIn: names.length > 0, + }); + } +} + +// Users who consented for themselves, by name +const users = new Map(); +const ids = [...userIds]; +for (let i = 0; i < ids.length; i += 15) { + const chunk = ids.slice(i, i + 15).map((id) => `'${id}'`).join(","); + const r = await get( + `/v1.0/users?$filter=${encodeURIComponent(`id in (${chunk})`)}&$select=id,displayName,userPrincipalName&$top=15`, + ); + if (!r.ok) { + note("Couldn't look up users", r); + continue; + } + for (const u of r.body.value || []) { + users.set(u.id, u); + } +} +for (const msg of problems) { + api.report.warning(msg); +} + +result = rows.map((r) => { + const u = r.principalId ? users.get(r.principalId) : null; + return { + ...r, + userDisplayName: u ? u.displayName : null, + userPrincipalName: u ? u.userPrincipalName : null, + }; +}); diff --git a/plugins/MicrosoftCopilot/v1/dataStreams/scripts/appSignIns.js b/plugins/MicrosoftCopilot/v1/dataStreams/scripts/appSignIns.js new file mode 100644 index 00000000..1a0cc7df --- /dev/null +++ b/plugins/MicrosoftCopilot/v1/dataStreams/scripts/appSignIns.js @@ -0,0 +1,51 @@ +// One row per Microsoft Entra application with sign-ins in the period. AI apps are picked out +// by name, since Entra has no category for them: the vendor column says which AI product an +// app belongs to, and is empty for everything else. Name matching misses AI apps with +// unrelated names, so the "All apps" option shows the full list to check against. +// The script is templated (for the Apps option), and templating strips backslashes, so the +// matching avoids regex escapes: names are split into lowercase words instead. +const VENDORS = [ + ["GitHub Copilot", { text: ["github copilot"] }], + ["Microsoft Copilot", { text: ["copilot"] }], + ["Anthropic", { text: ["claude", "anthropic"] }], + ["OpenAI", { text: ["openai", "chatgpt", "codex"], words: ["gpt"] }], + ["Google", { text: ["gemini", "notebooklm"], words: ["bard"] }], + ["Perplexity", { text: ["perplexity"] }], + ["Mistral", { text: ["mistral"] }], + ["xAI", { words: ["grok", "xai"] }], + ["DeepSeek", { text: ["deepseek"] }], + ["Cursor", { words: ["cursor"] }], + ["Glean", { words: ["glean"] }], + ["Other AI", { words: ["ai", "llm", "agent", "agents"], suffix: [".ai"] }], +]; +const vendorOf = (name) => { + const lower = name.toLowerCase(); + const words = lower.split(/[^a-z0-9]+/).filter(Boolean); + const dotted = lower.split(/[^a-z0-9.]+/).filter(Boolean); + const hit = VENDORS.find( + ([, m]) => + (m.text || []).some((t) => lower.includes(t)) || + (m.words || []).some((w) => words.includes(w)) || + (m.suffix || []).some((x) => dotted.some((d) => d.endsWith(x))), + ); + return hit ? hit[0] : null; +}; + +const onlyAi = "{{apps || 'ai'}}" !== "all"; + +result = (data.value || []) + .map((a) => { + const name = String(a.appDisplayName || ""); + const ok = Number(a.successfulSignInCount) || 0; + const failed = Number(a.failedSignInCount) || 0; + return { + appId: a.id || null, + appDisplayName: name, + aiVendor: vendorOf(name), + successfulSignInCount: ok, + failedSignInCount: failed, + totalSignInCount: ok + failed, + successPercentage: typeof a.successPercentage === "number" ? a.successPercentage : null, + }; + }) + .filter((a) => !onlyAi || a.aiVendor); diff --git a/plugins/MicrosoftCopilot/v1/dataStreams/scripts/budgets.js b/plugins/MicrosoftCopilot/v1/dataStreams/scripts/budgets.js new file mode 100644 index 00000000..125ab6fe --- /dev/null +++ b/plugins/MicrosoftCopilot/v1/dataStreams/scripts/budgets.js @@ -0,0 +1,87 @@ +// One row per Cost Management budget at the configured scope. A budget can be narrowed to +// resource groups, resources, meters or tags, so its filter is summarised alongside it: the +// budget that guards Copilot spend is usually the one filtered to the Copilot Studio billing +// policy's Power Platform account resource. +const amountOf = (v) => (v && typeof v.amount === "number" ? v.amount : null); +const pct = (part, whole) => (part !== null && whole > 0 ? (part / whole) * 100 : null); + +// Azure only returns forecastSpend for some budgets. Without it, the forecast is a straight +// line from the spend so far in the current period (Monthly, Quarterly or Annually, counted +// from the budget's start date). Billing-period grains can't be placed, and budgets that haven't +// started have no current period, so they get none. +const MONTHS = { Monthly: 1, Quarterly: 3, Annually: 12 }; +const currentPeriod = (start, grain) => { + const step = MONTHS[grain]; + const from = start ? new Date(start) : null; + if (!step || !from || isNaN(from)) { + return null; + } + const now = new Date(); + if (now < from) { + return null; + } + const elapsed = + (now.getUTCFullYear() - from.getUTCFullYear()) * 12 + (now.getUTCMonth() - from.getUTCMonth()); + const at = (n) => new Date(Date.UTC(from.getUTCFullYear(), from.getUTCMonth() + n, from.getUTCDate())); + let n = Math.floor(elapsed / step) * step; + if (at(n) > now) { + n -= step; + } + return { start: at(n), end: at(n + step) }; +}; + +const describe = (f) => { + if (!f) { + return []; + } + const parts = []; + for (const clause of [].concat(f.and || [], f.dimensions || f.tags ? [f] : [])) { + if (clause.dimensions) { + parts.push(`${clause.dimensions.name}: ${(clause.dimensions.values || []).join(", ")}`); + } + if (clause.tags) { + parts.push(`Tag ${clause.tags.name}: ${(clause.tags.values || []).join(", ")}`); + } + } + return parts; +}; + +result = (data.value || []).map((b) => { + const p = b.properties || {}; + const amount = typeof p.amount === "number" ? p.amount : null; + const spent = amountOf(p.currentSpend); + const period = currentPeriod(p.timePeriod && p.timePeriod.startDate, p.timeGrain); + const share = period ? (Date.now() - period.start) / (period.end - period.start) : null; + const forecast = + amountOf(p.forecastSpend) ?? + (spent !== null && share !== null && share > 0.02 ? spent / share : null); + const used = pct(spent, amount); + const forecastUsed = pct(forecast, amount); + // Over budget = error; 80% used, or on course to exceed it, = warning. + const state = + used === null + ? "unknown" + : used >= 100 + ? "error" + : used >= 80 || (forecastUsed !== null && forecastUsed > 100) + ? "warning" + : "success"; + const filters = describe(p.filter); + return { + id: b.id, + name: b.name, + category: p.category || null, + timeGrain: p.timeGrain || null, + amount, + currentSpend: spent, + forecastSpend: forecast, + currency: (p.currentSpend && p.currentSpend.unit) || (p.forecastSpend && p.forecastSpend.unit) || null, + percentUsed: used, + percentForecast: forecastUsed, + budgetState: state, + filters, + periodStart: period ? period.start.toISOString() : null, + periodEnd: period ? period.end.toISOString() : null, + endDate: (p.timePeriod && p.timePeriod.endDate) || null, + }; +}); diff --git a/plugins/MicrosoftCopilot/v1/dataStreams/scripts/environmentCapacity.js b/plugins/MicrosoftCopilot/v1/dataStreams/scripts/environmentCapacity.js new file mode 100644 index 00000000..3e81fa74 --- /dev/null +++ b/plugins/MicrosoftCopilot/v1/dataStreams/scripts/environmentCapacity.js @@ -0,0 +1,50 @@ +// The Power Platform API has no call that lists allocations across environments: the tenant +// currency report (the request this stream makes) only carries totals. So each environment in +// scope is fetched here, with the token the pre-request script added to the request. +// Environments that can't hold allocations, such as developer and legacy environments, return +// 404 and are left out, so a tile scoped to many environments still loads in full. +const prop = (v) => (Array.isArray(v) ? v[0] : v); +const LABELS = { MCSMessages: "Copilot Credits" }; +const CONCURRENCY = 5; + +const environments = (context.objects || []) + .map((o) => ({ id: prop(o.rawId), name: prop(o.name) })) + .filter((e) => e.id); + +const fetchAllocations = async (env) => { + let resp; + try { + resp = await fetch( + `https://${url.host}/licensing/environments/${encodeURIComponent(env.id)}/allocations?api-version=2024-10-01`, + { headers: { Authorization: headers.Authorization, Accept: "application/json" } }, + ); + } catch (err) { + // A network failure for one environment shouldn't lose the others' rows + api.report.warning(`Couldn't get allocations for ${env.name}: ${err && err.message ? err.message : err}`); + return []; + } + if (resp.status === 404) { + return []; + } + const body = await resp.json().catch(() => ({})); + if (!resp.ok) { + api.report.warning( + `Couldn't get allocations for ${env.name}: ${resp.status} ${(body.error && body.error.message) || resp.statusText}`, + ); + return []; + } + return (body.currencyAllocations || []).map((a) => ({ + environmentName: env.name, + environmentId: body.environmentId || env.id, + currency: LABELS[a.currencyType] || a.currencyType, + allocated: a.allocated, + currencyType: a.currencyType, + })); +}; + +const rows = []; +for (let i = 0; i < environments.length; i += CONCURRENCY) { + const batch = await Promise.all(environments.slice(i, i + CONCURRENCY).map(fetchAllocations)); + batch.forEach((r) => rows.push(...r)); +} +result = rows; diff --git a/plugins/MicrosoftCopilot/v1/dataStreams/scripts/errorHandling/costManagement.js b/plugins/MicrosoftCopilot/v1/dataStreams/scripts/errorHandling/costManagement.js new file mode 100644 index 00000000..5ea32d68 --- /dev/null +++ b/plugins/MicrosoftCopilot/v1/dataStreams/scripts/errorHandling/costManagement.js @@ -0,0 +1,6 @@ +const scope = "{{dataSource.costScope}}"; +const apiMsg = data && data.error && data.error.message; + +result = !scope || scope.trim() === "" + ? "Set a Cost Management scope in the data source configuration to use this data stream." + : apiMsg || "Request failed with HTTP " + response.status; diff --git a/plugins/MicrosoftCopilot/v1/dataStreams/scripts/licences.js b/plugins/MicrosoftCopilot/v1/dataStreams/scripts/licences.js new file mode 100644 index 00000000..33349d4f --- /dev/null +++ b/plugins/MicrosoftCopilot/v1/dataStreams/scripts/licences.js @@ -0,0 +1,36 @@ +// Keep only SKUs that grant Microsoft 365 Copilot itself, identified by its service plan IDs, so +// suites that merely bundle free Copilot features aren't counted as Copilot seats. The plan +// list shows every Copilot-related plan in the SKU for context. +const COPILOT_PLAN_IDS = [ + "a62f8878-de10-42f3-b68f-6149a25ceb97", + "3f30311c-6b1e-48a4-ab79-725b469da960", +]; +const skus = (data && data.value) || []; +result = skus + .map((s) => { + const servicePlans = s.servicePlans || []; + const isCopilot = servicePlans.some((p) => + COPILOT_PLAN_IDS.includes(String(p.servicePlanId).toLowerCase()), + ); + const plans = servicePlans.filter((p) => + String(p.servicePlanName || "").toUpperCase().includes("COPILOT"), + ); + return { s, plans, isCopilot }; + }) + .filter((x) => x.isCopilot) + .map(({ s, plans }) => { + const purchased = (s.prepaidUnits && s.prepaidUnits.enabled) || 0; + const assigned = s.consumedUnits || 0; + return { + skuPartNumber: s.skuPartNumber, + skuId: s.skuId, + purchased, + assigned, + available: purchased - assigned, + utilisation: purchased > 0 ? (assigned / purchased) * 100 : null, + suspended: (s.prepaidUnits && s.prepaidUnits.suspended) || 0, + warning: (s.prepaidUnits && s.prepaidUnits.warning) || 0, + capabilityStatus: s.capabilityStatus, + copilotPlans: plans.map((p) => p.servicePlanName), + }; + }); diff --git a/plugins/MicrosoftCopilot/v1/dataStreams/scripts/spend.js b/plugins/MicrosoftCopilot/v1/dataStreams/scripts/spend.js new file mode 100644 index 00000000..5c4cecb1 --- /dev/null +++ b/plugins/MicrosoftCopilot/v1/dataStreams/scripts/spend.js @@ -0,0 +1,37 @@ +// Cost Management returns { columns: [{name}], rows: [[...]] }. One output row per day x group. +const props = (data && data.properties) || {}; +const names = (props.columns || []).map((c) => c.name); +const idx = (n) => names.indexOf(n); +const groupBy = "{{groupBy || 'ServiceName'}}"; +const iDate = idx("UsageDate"); +const iCost = names.findIndex((n) => n === "Cost" || n === "PreTaxCost"); +const iQty = idx("UsageQuantity"); +const iCur = idx("Currency"); +const iGroup = idx(groupBy); + +// A resource's name is only unique within its resource group, so the label keeps the group +// (rg-prod/openai) and same-named resources in different groups stay separate series. +const resourceLabel = (id) => { + const parts = id.split("/").filter(Boolean); + const rg = parts.findIndex((p) => p.toLowerCase() === "resourcegroups"); + const name = parts[parts.length - 1] || id; + return rg >= 0 && parts[rg + 1] && rg + 1 < parts.length - 1 ? `${parts[rg + 1]}/${name}` : name; +}; + +const toDate = (v) => { + const s = String(v); + return /^[0-9]{8}$/.test(s) ? `${s.slice(0, 4)}-${s.slice(4, 6)}-${s.slice(6, 8)}T00:00:00Z` : s; +}; + +result = (props.rows || []).map((r) => { + const g = iGroup >= 0 && r[iGroup] != null && r[iGroup] !== "" ? String(r[iGroup]) : "(none)"; + const isResource = groupBy === "ResourceId"; + return { + usageDate: toDate(r[iDate]), + group: isResource && g !== "(none)" ? resourceLabel(g) : g, + resourceId: isResource ? g : null, + cost: r[iCost], + quantity: r[iQty], + currency: r[iCur], + }; +}); diff --git a/plugins/MicrosoftCopilot/v1/dataStreams/scripts/userActivity.js b/plugins/MicrosoftCopilot/v1/dataStreams/scripts/userActivity.js new file mode 100644 index 00000000..e191b5dd --- /dev/null +++ b/plugins/MicrosoftCopilot/v1/dataStreams/scripts/userActivity.js @@ -0,0 +1,50 @@ +// One row per licensed user. Optional `users` object picker narrows the rows +// by userPrincipalName (index properties arrive as single-element arrays). +// Department, job title, account state and last sign-in aren't in the report: lookup columns +// read them from the imported Copilot User, so they're deliberately not set here. +const unwrap = (v) => (Array.isArray(v) ? v[0] : v); +const selected = (context.config && context.config.users) || []; +const upns = new Set( + selected + .map((o) => String(unwrap(o.userPrincipalName) ?? "").toLowerCase()) + .filter(Boolean), +); + +const DAY = 86400000; +const toDate = (s) => (s ? new Date(s + "T00:00:00Z") : null); +const orNull = (s) => s || null; + +const rows = (data.value ?? []).filter( + (r) => !upns.size || upns.has(String(r.userPrincipalName ?? "").toLowerCase()), +); + +result = rows.map((r) => { + // Days are counted from the report's own refresh date (it lags real time + // by a day or two), so the figure matches the data rather than today. + const refresh = toDate(r.reportRefreshDate); + const last = toDate(r.lastActivityDate); + const days = refresh && last ? Math.round((refresh - last) / DAY) : null; + // Rule: no activity ever = error; > 28 days idle = error; > 7 = warning. + const activity = + days === null || days > 28 ? "error" : days > 7 ? "warning" : "success"; + const p = (r.copilotActivityUserDetailsByPeriod ?? [])[0] ?? {}; + + return { + displayName: r.displayName, + userPrincipalName: r.userPrincipalName, + lastActivityDate: orNull(r.lastActivityDate), + daysSinceLastActivity: days, + activityState: activity, + promptsSubmitted: p.promptsSubmittedAllApps ?? 0, + activeDays: p.activeUsageDaysAllApps ?? 0, + copilotChatLastActivityDate: orNull(r.copilotChatLastActivityDate), + teamsLastActivityDate: orNull(r.microsoftTeamsCopilotLastActivityDate), + wordLastActivityDate: orNull(r.wordCopilotLastActivityDate), + excelLastActivityDate: orNull(r.excelCopilotLastActivityDate), + powerPointLastActivityDate: orNull(r.powerPointCopilotLastActivityDate), + outlookLastActivityDate: orNull(r.outlookCopilotLastActivityDate), + oneNoteLastActivityDate: orNull(r.oneNoteCopilotLastActivityDate), + loopLastActivityDate: orNull(r.loopCopilotLastActivityDate), + reportRefreshDate: orNull(r.reportRefreshDate), + }; +}); diff --git a/plugins/MicrosoftCopilot/v1/dataStreams/scripts/userActivityDaily.js b/plugins/MicrosoftCopilot/v1/dataStreams/scripts/userActivityDaily.js new file mode 100644 index 00000000..86c9cb86 --- /dev/null +++ b/plugins/MicrosoftCopilot/v1/dataStreams/scripts/userActivityDaily.js @@ -0,0 +1,65 @@ +// Microsoft keeps per-user daily Copilot activity for about a week, one report per day. The +// first request (the 7-day summary) only supplies the report's refresh date. Each later +// request fetches one day, starting at the refresh date and stepping back a day at a time, +// by handing the next day's report URL back as the paging context. It stops after 7 days, +// or sooner if a day comes back empty, so it never asks for a date outside the window. +const DAYS = 7; +const DAY = 86400000; +const unwrap = (v) => (Array.isArray(v) ? v[0] : v); +const selected = (context.config && context.config.users) || []; +const upns = new Set( + selected.map((o) => String(unwrap(o.userPrincipalName) ?? "").toLowerCase()).filter(Boolean), +); + +const reportUrl = (day) => + `https://${url.host}/beta/copilot/reports/getMicrosoft365CopilotUsageUserDetailByDate(date=${day})?$format=application/json`; +const shift = (day, n) => new Date(Date.parse(day + "T00:00:00Z") + n * DAY).toISOString().slice(0, 10); + +const APPS = [ + ["isActiveInM365Chat", "Copilot Chat (work)"], + ["isActiveInBusinessChatWeb", "Copilot Chat (web)"], + ["isActiveInTeams", "Teams"], + ["isActiveInOutlook", "Outlook"], + ["isActiveInWord", "Word"], + ["isActiveInExcel", "Excel"], + ["isActiveInPowerPoint", "PowerPoint"], + ["isActiveInOneNote", "OneNote"], + ["isActiveInLoop", "Loop"], + ["isActiveInM365CopilotChatCopilotApp", "Microsoft 365 Copilot app"], + ["isActiveInEdge", "Edge"], +]; + +const isSummary = !context.pagingContext; +if (isSummary) { + const refresh = ((data && data.value && data.value[0]) || {}).reportRefreshDate; + pagingContext = refresh ? reportUrl(String(refresh).slice(0, 10)) : undefined; + result = []; +} else { + const rows = (data && data.value) || []; + const first = rows[0] || {}; + const match = String(context.pagingContext).match(/date=([0-9-]{10})/); + const day = first.reportSelectedDate || (match && match[1]); + const refresh = first.reportRefreshDate; + const morePages = data && data["@odata.nextLink"]; + const earlier = day && refresh ? shift(day, -1) : null; + pagingContext = morePages + ? morePages + : rows.length && earlier && earlier > shift(refresh, -DAYS) + ? reportUrl(earlier) + : undefined; + + result = rows + .filter((r) => !upns.size || upns.has(String(r.userPrincipalName ?? "").toLowerCase())) + .map((r) => ({ + date: r.reportSelectedDate ? `${r.reportSelectedDate}T00:00:00Z` : null, + displayName: r.displayName, + userPrincipalName: r.userPrincipalName, + isActive: r.isActive === true, + activeUser: r.isActive === true ? 1 : 0, + promptsSubmitted: Number(r.allAppsCopilotActionCount) || 0, + chatWorkPrompts: Number(r.m365ChatQueriesSubmitted) || 0, + chatWebPrompts: Number(r.businessChatWebPromptsCount) || 0, + activeApps: APPS.filter(([key]) => r[key] === true).map(([, name]) => name), + reportRefreshDate: r.reportRefreshDate || null, + })); +} diff --git a/plugins/MicrosoftCopilot/v1/dataStreams/spend.json b/plugins/MicrosoftCopilot/v1/dataStreams/spend.json new file mode 100644 index 00000000..fe2c162b --- /dev/null +++ b/plugins/MicrosoftCopilot/v1/dataStreams/spend.json @@ -0,0 +1,103 @@ +{ + "name": "spend", + "displayName": "Copilot Spend", + "description": "Daily Azure Cost Management spend and usage quantity for Copilot and AI services, by service, meter or resource", + "tags": [ + "Cost" + ], + "baseDataSourceName": "httpRequestUnscoped", + "config": { + "httpMethod": "post", + "baseUrl": "https://management.azure.com", + "endpointPath": "{{dataSource.costScope}}/providers/Microsoft.CostManagement/query", + "getArgs": [ + { + "key": "api-version", + "value": "2023-11-01" + } + ], + "postBody": { + "type": "ActualCost", + "timeframe": "Custom", + "timePeriod": { + "from": "{{timeframe.start}}", + "to": "{{timeframe.end}}" + }, + "dataset": { + "granularity": "Daily", + "aggregation": { + "totalCost": { + "name": "Cost", + "function": "Sum" + }, + "totalQuantity": { + "name": "UsageQuantity", + "function": "Sum" + } + }, + "grouping": [ + { + "type": "Dimension", + "name": "{{groupBy || 'ServiceName'}}" + } + ], + "filter": "{{scopeOfCosts === 'all' ? undefined : { or: [ { dimensions: { name: 'ResourceType', operator: 'In', values: ['microsoft.powerplatform/accounts'] } }, { dimensions: { name: 'ServiceName', operator: 'In', values: ['Cognitive Services','Azure OpenAI Service','Azure AI Services','Copilot Studio','Microsoft Copilot Studio','Power Platform','Foundry Models','Foundry Tools'] } } ] } }}" + } + }, + "paging": { + "mode": "nextUrl", + "in": { + "realm": "payload", + "path": "properties.nextLink" + } + }, + "errorHandling": { + "type": "script", + "script": "errorHandling/costManagement.js" + }, + "postRequestScript": "spend.js" + }, + "matches": "none", + "timeframes": [ + "last7days", + "last30days", + "thisMonth", + "lastMonth", + "thisQuarter", + "lastQuarter" + ], + "ui": [ + { + "type": "radio", + "name": "groupBy", + "label": "Group by", + "defaultValue": "ServiceName", + "options": [ + { "value": "ServiceName", "label": "Service" }, + { "value": "MeterCategory", "label": "Meter category" }, + { "value": "Meter", "label": "Meter" }, + { "value": "ResourceGroupName", "label": "Resource group" }, + { "value": "ResourceId", "label": "Resource" }, + { "value": "ResourceType", "label": "Resource type" } + ] + }, + { + "type": "radio", + "name": "scopeOfCosts", + "label": "Scope of costs", + "defaultValue": "copilot", + "options": [ + { "value": "copilot", "label": "Copilot and AI services" }, + { "value": "all", "label": "All services" } + ] + } + ], + "metadata": [ + { "name": "usageDate", "displayName": "Date", "shape": "date", "role": "timestamp" }, + { "name": "group", "displayName": "Group", "shape": "string", "role": "label" }, + { "name": "resourceId", "displayName": "Resource ID", "shape": "string" }, + { "name": "cost", "displayName": "Cost", "shape": ["number", { "decimalPlaces": 2 }], "role": "value" }, + { "name": "quantity", "displayName": "Usage quantity", "shape": ["number", { "decimalPlaces": 2 }] }, + { "name": "currency", "displayName": "Currency", "shape": "string" } + ] +} diff --git a/plugins/MicrosoftCopilot/v1/dataStreams/userActivity.json b/plugins/MicrosoftCopilot/v1/dataStreams/userActivity.json new file mode 100644 index 00000000..0a9039a1 --- /dev/null +++ b/plugins/MicrosoftCopilot/v1/dataStreams/userActivity.json @@ -0,0 +1,250 @@ +{ + "name": "userActivity", + "displayName": "Copilot User Activity", + "description": "Microsoft 365 Copilot activity per user, including days since last use, prompts submitted, department and seat status", + "tags": [ + "Adoption", + "User" + ], + "baseDataSourceName": "httpRequestUnscoped", + "config": { + "httpMethod": "get", + "endpointPath": "beta/copilot/reports/getMicrosoft365CopilotUsageUserDetail(period='{{period || 'D28'}}')", + "postRequestScript": "userActivity.js", + "paging": { + "mode": "nextUrl", + "pageSize": { + "realm": "none" + }, + "in": { + "realm": "payload", + "path": "@odata.nextLink" + } + } + }, + "matches": "none", + "timeframes": false, + "ui": [ + { + "type": "radio", + "name": "period", + "label": "Period", + "defaultValue": "D28", + "options": [ + { + "value": "D7", + "label": "7 days" + }, + { + "value": "D28", + "label": "28 days" + }, + { + "value": "D90", + "label": "90 days" + }, + { + "value": "D180", + "label": "180 days" + } + ] + }, + { + "type": "objects", + "name": "users", + "label": "User (optional)", + "matches": { + "sourceType": { + "type": "oneOf", + "values": [ + "User" + ] + } + } + } + ], + "metadata": [ + { + "name": "displayName", + "displayName": "Name", + "shape": "string", + "role": "label" + }, + { + "name": "userPrincipalName", + "displayName": "User principal name", + "shape": "string", + "sourceType": "User" + }, + { + "name": "department", + "displayName": "Department", + "shape": "string", + "sourceId": "userPrincipalName", + "objectPropertyPath": "department" + }, + { + "name": "jobTitle", + "displayName": "Job title", + "shape": "string", + "sourceId": "userPrincipalName", + "objectPropertyPath": "jobTitle" + }, + { + "name": "accountEnabled", + "displayName": "Account enabled", + "shape": "boolean", + "sourceId": "userPrincipalName", + "objectPropertyPath": "accountEnabled" + }, + { + "name": "activityState", + "displayName": "Activity", + "shape": [ + "state", + { + "map": { + "success": [ + "success" + ], + "warning": [ + "warning" + ], + "error": [ + "error" + ] + } + } + ] + }, + { + "name": "seatStatus", + "displayName": "Seat status", + "shape": "string", + "computed": true, + "valueExpression": "{{ $['accountEnabled'] === false || $['accountEnabled'] === 'false' ? 'Possible leaver' : $['daysSinceLastActivity'] === null || $['daysSinceLastActivity'] === undefined ? 'Never used' : $['daysSinceLastActivity'] > 28 ? 'Idle' : $['daysSinceLastActivity'] > 7 ? 'Low use' : 'Active' }}" + }, + { + "name": "lastActivityDate", + "displayName": "Last activity", + "shape": [ + "date", + { + "format": "dd/MM/yyyy" + } + ] + }, + { + "name": "daysSinceLastActivity", + "displayName": "Days since last activity", + "shape": "number" + }, + { + "name": "lastUsed", + "displayName": "Last used", + "shape": "string", + "computed": true, + "valueExpression": "{{ $['lastActivityDate'] ? 'Last used ' + String($['lastActivityDate']).slice(0, 10) : 'Never used' }}" + }, + { + "name": "promptsSubmitted", + "displayName": "Prompts submitted", + "shape": "number" + }, + { + "name": "activeDays", + "displayName": "Active days", + "shape": "number" + }, + { + "name": "copilotChatLastActivityDate", + "displayName": "Copilot Chat last activity", + "shape": [ + "date", + { + "format": "dd/MM/yyyy" + } + ] + }, + { + "name": "teamsLastActivityDate", + "displayName": "Teams last activity", + "shape": [ + "date", + { + "format": "dd/MM/yyyy" + } + ] + }, + { + "name": "wordLastActivityDate", + "displayName": "Word last activity", + "shape": [ + "date", + { + "format": "dd/MM/yyyy" + } + ] + }, + { + "name": "excelLastActivityDate", + "displayName": "Excel last activity", + "shape": [ + "date", + { + "format": "dd/MM/yyyy" + } + ] + }, + { + "name": "powerPointLastActivityDate", + "displayName": "PowerPoint last activity", + "shape": [ + "date", + { + "format": "dd/MM/yyyy" + } + ] + }, + { + "name": "outlookLastActivityDate", + "displayName": "Outlook last activity", + "shape": [ + "date", + { + "format": "dd/MM/yyyy" + } + ] + }, + { + "name": "oneNoteLastActivityDate", + "displayName": "OneNote last activity", + "shape": [ + "date", + { + "format": "dd/MM/yyyy" + } + ] + }, + { + "name": "loopLastActivityDate", + "displayName": "Loop last activity", + "shape": [ + "date", + { + "format": "dd/MM/yyyy" + } + ] + }, + { + "name": "reportRefreshDate", + "displayName": "Report refreshed", + "shape": [ + "date", + { + "format": "dd/MM/yyyy" + } + ] + } + ] +} diff --git a/plugins/MicrosoftCopilot/v1/dataStreams/userActivityDaily.json b/plugins/MicrosoftCopilot/v1/dataStreams/userActivityDaily.json new file mode 100644 index 00000000..6703917d --- /dev/null +++ b/plugins/MicrosoftCopilot/v1/dataStreams/userActivityDaily.json @@ -0,0 +1,101 @@ +{ + "name": "userActivityDaily", + "displayName": "Copilot Daily User Activity", + "description": "Microsoft 365 Copilot activity per user per day for the last 7 days of reporting, with prompts and the apps used", + "tags": [ + "Adoption", + "User" + ], + "baseDataSourceName": "httpRequestUnscoped", + "config": { + "httpMethod": "get", + "endpointPath": "beta/copilot/reports/getMicrosoft365CopilotUserCountSummary(period='D7')", + "postRequestScript": "userActivityDaily.js", + "paging": { + "mode": "nextUrl", + "pageSize": { + "realm": "none" + }, + "in": { + "realm": "payload", + "path": "@odata.nextLink" + } + } + }, + "matches": "none", + "timeframes": false, + "ui": [ + { + "type": "objects", + "name": "users", + "label": "User (optional)", + "matches": { + "sourceType": { + "type": "oneOf", + "values": [ + "User" + ] + } + } + } + ], + "metadata": [ + { + "name": "date", + "displayName": "Date", + "shape": "date", + "role": "timestamp" + }, + { + "name": "displayName", + "displayName": "Name", + "shape": "string", + "role": "label" + }, + { + "name": "userPrincipalName", + "displayName": "User principal name", + "shape": "string" + }, + { + "name": "isActive", + "displayName": "Active", + "shape": "boolean" + }, + { + "name": "activeUser", + "displayName": "Active (1 or 0)", + "shape": "number" + }, + { + "name": "promptsSubmitted", + "displayName": "Prompts (all apps)", + "shape": "number" + }, + { + "name": "chatWorkPrompts", + "displayName": "Copilot Chat (work) prompts", + "shape": "number" + }, + { + "name": "chatWebPrompts", + "displayName": "Copilot Chat (web) prompts", + "shape": "number" + }, + { + "name": "activeApps", + "displayName": "Apps used", + "shape": [ + "array", + { + "itemShape": "string" + } + ] + }, + { + "name": "reportRefreshDate", + "displayName": "Report refreshed", + "shape": "date" + } + ] +} diff --git a/plugins/MicrosoftCopilot/v1/dataStreams/userSignIns.json b/plugins/MicrosoftCopilot/v1/dataStreams/userSignIns.json new file mode 100644 index 00000000..625e7163 --- /dev/null +++ b/plugins/MicrosoftCopilot/v1/dataStreams/userSignIns.json @@ -0,0 +1,92 @@ +{ + "name": "userSignIns", + "displayName": "Copilot User Sign-ins", + "description": "Last Microsoft Entra sign-in for each user with a Microsoft 365 Copilot licence, read live (needs AuditLog.Read.All and Microsoft Entra ID P1 or P2)", + "tags": [ + "User" + ], + "baseDataSourceName": "httpRequestUnscoped", + "config": { + "httpMethod": "get", + "endpointPath": "v1.0/users", + "pathToData": "value", + "expandInnerObjects": true, + "headers": [ + { + "key": "ConsistencyLevel", + "value": "eventual" + } + ], + "getArgs": [ + { + "key": "$filter", + "value": "assignedPlans/any(p:p/servicePlanId eq a62f8878-de10-42f3-b68f-6149a25ceb97 and p/capabilityStatus eq 'Enabled') or assignedPlans/any(p:p/servicePlanId eq 3f30311c-6b1e-48a4-ab79-725b469da960 and p/capabilityStatus eq 'Enabled')" + }, + { + "key": "$count", + "value": "true" + }, + { + "key": "$select", + "value": "id,displayName,userPrincipalName,accountEnabled,signInActivity" + } + ], + "paging": { + "mode": "nextUrl", + "pageSize": { + "realm": "queryArg", + "path": "$top", + "value": "500" + }, + "in": { + "realm": "payload", + "path": "@odata.nextLink" + } + } + }, + "matches": "none", + "timeframes": false, + "metadata": [ + { + "name": "displayName", + "displayName": "Name", + "shape": "string", + "role": "label" + }, + { + "name": "userPrincipalName", + "displayName": "User principal name", + "shape": "string" + }, + { + "name": "accountEnabled", + "displayName": "Account enabled", + "shape": "boolean" + }, + { + "name": "lastSignInDateTime", + "displayName": "Last sign-in", + "shape": "date", + "computed": true, + "valueExpression": "{{ $['signInActivity.lastSuccessfulSignInDateTime'] || null }}" + }, + { + "name": "signInActivity.lastSuccessfulSignInDateTime", + "displayName": "Last successful sign-in", + "shape": "date", + "visible": false + }, + { + "name": "signInActivity.lastSignInDateTime", + "displayName": "Last sign-in attempt", + "shape": "date", + "visible": false + }, + { + "name": "id", + "displayName": "Object ID", + "shape": "guid", + "visible": false + } + ] +} diff --git a/plugins/MicrosoftCopilot/v1/dataStreams/users.json b/plugins/MicrosoftCopilot/v1/dataStreams/users.json new file mode 100644 index 00000000..cc230578 --- /dev/null +++ b/plugins/MicrosoftCopilot/v1/dataStreams/users.json @@ -0,0 +1,43 @@ +{ + "name": "users", + "displayName": "Copilot Users", + "description": "Users with a Microsoft 365 Copilot licence", + "tags": ["User", "Licence"], + "baseDataSourceName": "httpRequestUnscoped", + "config": { + "httpMethod": "get", + "endpointPath": "v1.0/users", + "pathToData": "value", + "headers": [{ "key": "ConsistencyLevel", "value": "eventual" }], + "getArgs": [ + { + "key": "$filter", + "value": "assignedPlans/any(p:p/servicePlanId eq a62f8878-de10-42f3-b68f-6149a25ceb97 and p/capabilityStatus eq 'Enabled') or assignedPlans/any(p:p/servicePlanId eq 3f30311c-6b1e-48a4-ab79-725b469da960 and p/capabilityStatus eq 'Enabled')" + }, + { "key": "$count", "value": "true" }, + { + "key": "$select", + "value": "id,displayName,userPrincipalName,mail,department,jobTitle,officeLocation,country,accountEnabled" + } + ], + "paging": { + "mode": "nextUrl", + "pageSize": { "realm": "queryArg", "path": "$top", "value": "999" }, + "in": { "realm": "payload", "path": "@odata.nextLink" } + } + }, + "matches": "none", + "timeframes": false, + "visibility": { "type": "hidden" }, + "metadata": [ + { "name": "id", "displayName": "Object ID", "shape": "guid", "visible": false }, + { "name": "displayName", "displayName": "Name", "shape": "string", "role": "label" }, + { "name": "userPrincipalName", "displayName": "User principal name", "shape": "string" }, + { "name": "mail", "displayName": "Email", "shape": "string" }, + { "name": "department", "displayName": "Department", "shape": "string" }, + { "name": "jobTitle", "displayName": "Job title", "shape": "string" }, + { "name": "officeLocation", "displayName": "Office", "shape": "string" }, + { "name": "country", "displayName": "Country", "shape": "string" }, + { "name": "accountEnabled", "displayName": "Account enabled", "shape": "boolean" } + ] +} diff --git a/plugins/MicrosoftCopilot/v1/dataStreams/validationLicences.json b/plugins/MicrosoftCopilot/v1/dataStreams/validationLicences.json new file mode 100644 index 00000000..48071588 --- /dev/null +++ b/plugins/MicrosoftCopilot/v1/dataStreams/validationLicences.json @@ -0,0 +1,15 @@ +{ + "name": "validationLicences", + "displayName": "Validation - Licences", + "baseDataSourceName": "httpRequestUnscoped", + "config": { + "httpMethod": "get", + "endpointPath": "v1.0/subscribedSkus", + "pathToData": "value", + "getArgs": [{ "key": "$select", "value": "skuId,skuPartNumber" }] + }, + "matches": "none", + "timeframes": false, + "providesPluginDiagnostics": true, + "visibility": { "type": "hidden" } +} diff --git a/plugins/MicrosoftCopilot/v1/dataStreams/validationPowerPlatform.json b/plugins/MicrosoftCopilot/v1/dataStreams/validationPowerPlatform.json new file mode 100644 index 00000000..1beca948 --- /dev/null +++ b/plugins/MicrosoftCopilot/v1/dataStreams/validationPowerPlatform.json @@ -0,0 +1,14 @@ +{ + "name": "validationPowerPlatform", + "displayName": "Validation - Power Platform", + "baseDataSourceName": "httpRequestUnscoped", + "config": { + "httpMethod": "get", + "baseUrl": "https://api.powerplatform.com", + "endpointPath": "licensing/entitlements/MCSMessages", + "getArgs": [{ "key": "api-version", "value": "2024-10-01" }] + }, + "matches": "none", + "timeframes": false, + "visibility": { "type": "hidden" } +} diff --git a/plugins/MicrosoftCopilot/v1/dataStreams/validationUsageReports.json b/plugins/MicrosoftCopilot/v1/dataStreams/validationUsageReports.json new file mode 100644 index 00000000..d1f5b4d3 --- /dev/null +++ b/plugins/MicrosoftCopilot/v1/dataStreams/validationUsageReports.json @@ -0,0 +1,13 @@ +{ + "name": "validationUsageReports", + "displayName": "Validation - Usage Reports", + "baseDataSourceName": "httpRequestUnscoped", + "config": { + "httpMethod": "get", + "endpointPath": "beta/copilot/reports/getMicrosoft365CopilotUserCountSummary(period='D7')", + "pathToData": "value" + }, + "matches": "none", + "timeframes": false, + "visibility": { "type": "hidden" } +} diff --git a/plugins/MicrosoftCopilot/v1/defaultContent/agent.dash.json b/plugins/MicrosoftCopilot/v1/defaultContent/agent.dash.json new file mode 100644 index 00000000..ac2f5e22 --- /dev/null +++ b/plugins/MicrosoftCopilot/v1/defaultContent/agent.dash.json @@ -0,0 +1,258 @@ +{ + "name": "Agent", + "schemaVersion": "1.5", + "timeframe": "none", + "variables": [ + "{{variables.[Copilot Agent]}}" + ], + "dashboard": { + "_type": "layout/grid", + "columns": 4, + "version": 1, + "contents": [ + { + "i": "aa5035f5-fb6d-4a48-8674-1639c6d8c478", + "x": 0, + "y": 0, + "w": 2, + "h": 4, + "moved": false, + "static": false, + "z": 0, + "config": { + "_type": "tile/data-stream", + "activePluginConfigIds": [ + "{{configId}}" + ], + "title": "Agent Details", + "description": "The agent's entry in the Microsoft Agent 365 registry", + "timeframe": "none", + "dataStream": { + "id": "datastream-properties", + "name": "properties", + "pluginConfigId": "{{configId}}" + }, + "scope": { + "scope": "{{scopes.[Copilot Agents]}}", + "variable": "{{variables.[Copilot Agent]}}", + "workspace": "{{workspaceId}}" + }, + "variables": [ + "{{variables.[Copilot Agent]}}" + ], + "vizSpec": { + "version": "1.0", + "visualization": { + "chartType": "richTable", + "encoding": { + "columns": [ + { + "field": "agentType", + "title": "Type", + "renderer": { + "type": "badge", + "defaultColor": "#3b82f6" + } + }, + { + "field": "platform", + "title": "Platform", + "renderer": { + "type": "text" + } + }, + { + "field": "publisher", + "title": "Publisher", + "renderer": { + "type": "text" + } + }, + { + "field": "ownershipStatus", + "title": "Ownership", + "renderer": { + "type": "badge", + "colors": { + "OK": "#22c55e", + "No owner": "#ef4444" + } + } + }, + { + "field": "ownerCount", + "title": "Owners", + "renderer": { + "type": "number" + } + }, + { + "field": "availableTo", + "title": "Available to", + "renderer": { + "type": "text" + } + }, + { + "field": "deployedTo", + "title": "Deployed to", + "renderer": { + "type": "text" + } + }, + { + "field": "isBlocked", + "title": "Blocked", + "renderer": { + "type": "boolean", + "trueLabel": "Yes", + "falseLabel": "No", + "trueColor": "#d97706", + "falseColor": "#64748b" + } + }, + { + "field": "createdDateTime", + "title": "Created", + "renderer": { + "type": "date" + } + } + ] + }, + "style": { + "richTableCellPadding": 6, + "richTableTranspose": true + } + } + } + } + }, + { + "i": "7932b0ad-9d85-48a2-942a-e61841f40df7", + "x": 2, + "y": 0, + "w": 2, + "h": 2, + "moved": false, + "static": false, + "z": 0, + "config": { + "_type": "tile/data-stream", + "activePluginConfigIds": [ + "{{configId}}" + ], + "title": "Usage", + "description": "Active users and sessions over the last 30 days, and days since the agent was last used, from the Agent 365 registry", + "timeframe": "none", + "dataStream": { + "id": "{{dataStreams.[agentDetails]}}", + "name": "agentDetails", + "pluginConfigId": "{{configId}}" + }, + "scope": { + "scope": "{{scopes.[Copilot Agents]}}", + "variable": "{{variables.[Copilot Agent]}}", + "workspace": "{{workspaceId}}" + }, + "variables": [ + "{{variables.[Copilot Agent]}}" + ], + "vizSpec": { + "version": "1.0", + "visualization": { + "chartType": "scalar", + "encoding": { + "values": [ + { + "field": "activeUsers", + "type": "quantitative", + "title": "Active users" + }, + { + "field": "totalSessions", + "type": "quantitative", + "title": "Sessions" + }, + { + "field": "daysSinceUsed", + "type": "quantitative", + "title": "Days since used" + } + ] + }, + "style": { + "scalarColumns": 3 + } + } + } + } + }, + { + "i": "b3d99177-b6dc-4280-a6bc-7fd430e927a1", + "x": 2, + "y": 2, + "w": 2, + "h": 2, + "moved": false, + "static": false, + "z": 0, + "config": { + "_type": "tile/data-stream", + "activePluginConfigIds": [ + "{{configId}}" + ], + "title": "Reach", + "description": "How many users and groups the agent is shared with or allowed for, and its run time and exceptions over the last 30 days", + "timeframe": "none", + "dataStream": { + "id": "{{dataStreams.[agentDetails]}}", + "name": "agentDetails", + "pluginConfigId": "{{configId}}" + }, + "scope": { + "scope": "{{scopes.[Copilot Agents]}}", + "variable": "{{variables.[Copilot Agent]}}", + "workspace": "{{workspaceId}}" + }, + "variables": [ + "{{variables.[Copilot Agent]}}" + ], + "vizSpec": { + "version": "1.0", + "visualization": { + "chartType": "scalar", + "encoding": { + "values": [ + { + "field": "sharedWithCount", + "type": "quantitative", + "title": "Shared with" + }, + { + "field": "allowedCount", + "type": "quantitative", + "title": "Allowed for" + }, + { + "field": "totalRunTimeInHours", + "type": "quantitative", + "title": "Run time (hours)" + }, + { + "field": "exceptions", + "type": "quantitative", + "title": "Exceptions" + } + ] + }, + "style": { + "scalarColumns": 4 + } + } + } + } + } + ] + } +} diff --git a/plugins/MicrosoftCopilot/v1/defaultContent/agents.dash.json b/plugins/MicrosoftCopilot/v1/defaultContent/agents.dash.json new file mode 100644 index 00000000..ec7434b9 --- /dev/null +++ b/plugins/MicrosoftCopilot/v1/defaultContent/agents.dash.json @@ -0,0 +1,615 @@ +{ + "name": "Agents", + "schemaVersion": "1.5", + "timeframe": "none", + "variables": [], + "dashboard": { + "_type": "layout/grid", + "columns": 4, + "version": 1, + "contents": [ + { + "i": "f318a84f-fb47-4dd3-90d0-ed25174e114d", + "x": 0, + "y": 0, + "w": 1, + "h": 2, + "moved": false, + "static": false, + "z": 0, + "config": { + "_type": "tile/data-stream", + "activePluginConfigIds": [], + "title": "Agents", + "description": "Agents in the Microsoft Agent 365 registry. Needs Microsoft Agent 365 in the tenant and the CopilotPackages.Read.All permission", + "timeframe": "none", + "dataStream": { + "id": "datastream-sql", + "dataSourceConfig": { + "version": "2.0", + "sql": "SELECT COUNT(*) AS \"agents\" FROM \"agents\"", + "tables": [ + { + "tableName": "agents", + "config": { + "activePluginConfigIds": [ + "{{configId}}" + ], + "dataStream": { + "id": "{{dataStreams.[agents]}}", + "name": "agents" + }, + "timeframe": "none" + } + } + ] + } + }, + "vizSpec": { + "version": "1.0", + "visualization": { + "chartType": "scalar", + "encoding": { + "values": [ + { + "field": "agents", + "type": "quantitative", + "title": "Agents" + } + ] + } + } + } + } + }, + { + "i": "3ec4dceb-956e-49c7-aa10-ef7033f624b3", + "x": 1, + "y": 0, + "w": 1, + "h": 2, + "moved": false, + "static": false, + "z": 0, + "config": { + "_type": "tile/data-stream", + "activePluginConfigIds": [], + "title": "Ownership Issues", + "description": "Agents with no owner in the registry", + "timeframe": "none", + "dataStream": { + "id": "datastream-sql", + "dataSourceConfig": { + "version": "2.0", + "sql": "SELECT COUNT(*) AS \"issues\" FROM \"agents\" WHERE \"ownershipStatus\" = 'No owner'", + "tables": [ + { + "tableName": "agents", + "config": { + "activePluginConfigIds": [ + "{{configId}}" + ], + "dataStream": { + "id": "{{dataStreams.[agents]}}", + "name": "agents" + }, + "timeframe": "none" + } + } + ] + } + }, + "vizSpec": { + "version": "1.0", + "visualization": { + "chartType": "scalar", + "encoding": { + "values": [ + { + "field": "issues", + "type": "quantitative", + "title": "Without an owner" + } + ] + } + } + } + } + }, + { + "i": "cd7b8215-cd05-4ab6-b9c8-15156faf5e77", + "x": 2, + "y": 0, + "w": 1, + "h": 2, + "moved": false, + "static": false, + "z": 0, + "config": { + "_type": "tile/data-stream", + "activePluginConfigIds": [], + "title": "Blocked Agents", + "description": "Agents an administrator has blocked", + "timeframe": "none", + "dataStream": { + "id": "datastream-sql", + "dataSourceConfig": { + "version": "2.0", + "sql": "SELECT COUNT(*) AS \"blocked\" FROM \"agents\" WHERE \"isBlocked\"", + "tables": [ + { + "tableName": "agents", + "config": { + "activePluginConfigIds": [ + "{{configId}}" + ], + "dataStream": { + "id": "{{dataStreams.[agents]}}", + "name": "agents" + }, + "timeframe": "none" + } + } + ] + } + }, + "vizSpec": { + "version": "1.0", + "visualization": { + "chartType": "scalar", + "encoding": { + "values": [ + { + "field": "blocked", + "type": "quantitative", + "title": "Blocked" + } + ] + } + } + } + } + }, + { + "i": "d7d38ab8-b6e2-485c-8d40-a97016b4d0d0", + "x": 3, + "y": 0, + "w": 1, + "h": 2, + "moved": false, + "static": false, + "z": 0, + "config": { + "_type": "tile/data-stream", + "activePluginConfigIds": [], + "title": "New This Month", + "description": "Agents created in the last 30 days", + "timeframe": "none", + "dataStream": { + "id": "datastream-sql", + "dataSourceConfig": { + "version": "2.0", + "sql": "SELECT COUNT(*) AS \"created\" FROM \"agents\" WHERE \"createdDateTime\" >= NOW() - INTERVAL 30 DAY", + "tables": [ + { + "tableName": "agents", + "config": { + "activePluginConfigIds": [ + "{{configId}}" + ], + "dataStream": { + "id": "{{dataStreams.[agents]}}", + "name": "agents" + }, + "timeframe": "none" + } + } + ] + } + }, + "vizSpec": { + "version": "1.0", + "visualization": { + "chartType": "scalar", + "encoding": { + "values": [ + { + "field": "created", + "type": "quantitative", + "title": "Created in 30 days" + } + ] + } + } + } + } + }, + { + "i": "0384aecc-3240-4ea6-bf93-b2dd014681f9", + "x": 0, + "y": 2, + "w": 2, + "h": 3, + "moved": false, + "static": false, + "z": 0, + "config": { + "_type": "tile/data-stream", + "activePluginConfigIds": [], + "title": "Agents by Platform", + "description": "Agents in the registry by the platform they were built on and their type", + "timeframe": "none", + "dataStream": { + "id": "datastream-sql", + "dataSourceConfig": { + "version": "2.0", + "sql": "SELECT COALESCE(\"platform\", '(Unknown)') AS \"platform\", COALESCE(\"agentType\", '(Unknown)') AS \"type\", COUNT(*) AS \"agents\" FROM \"agents\" GROUP BY 1, 2 ORDER BY 3 DESC", + "tables": [ + { + "tableName": "agents", + "config": { + "activePluginConfigIds": [ + "{{configId}}" + ], + "dataStream": { + "id": "{{dataStreams.[agents]}}", + "name": "agents" + }, + "timeframe": "none" + } + } + ] + } + }, + "vizSpec": { + "version": "1.0", + "visualization": { + "chartType": "bar", + "encoding": { + "x": { + "field": "platform", + "type": "nominal", + "title": "Platform" + }, + "y": { + "field": "agents", + "type": "quantitative", + "title": "Agents", + "aggregate": "sum" + }, + "series": { + "field": "type", + "type": "nominal", + "title": "Type" + } + }, + "style": { + "cartesianHorizontal": true, + "cartesianStack": "on", + "cartesianBarBorderRadius": 2 + } + } + } + } + }, + { + "i": "cf7e9640-f816-464e-9d9f-85568d146346", + "x": 2, + "y": 2, + "w": 2, + "h": 3, + "moved": false, + "static": false, + "z": 0, + "config": { + "_type": "tile/data-stream", + "activePluginConfigIds": [], + "title": "New Agents per Week", + "description": "Agents added to the registry each week", + "timeframe": "none", + "dataStream": { + "id": "datastream-sql", + "dataSourceConfig": { + "version": "2.0", + "sql": "SELECT DATE_TRUNC('week', CAST(\"createdDateTime\" AS TIMESTAMP)) AS \"week\", COUNT(*) AS \"agents\" FROM \"agents\" WHERE \"createdDateTime\" IS NOT NULL GROUP BY 1 ORDER BY 1", + "tables": [ + { + "tableName": "agents", + "config": { + "activePluginConfigIds": [ + "{{configId}}" + ], + "dataStream": { + "id": "{{dataStreams.[agents]}}", + "name": "agents" + }, + "timeframe": "none" + } + } + ] + } + }, + "vizSpec": { + "version": "1.0", + "visualization": { + "chartType": "bar", + "encoding": { + "x": { + "field": "week", + "type": "temporal", + "title": "Week" + }, + "y": { + "field": "agents", + "type": "quantitative", + "title": "New agents", + "aggregate": "sum" + } + }, + "style": { + "cartesianBarBorderRadius": 2, + "cartesianTrendLine": true + } + } + } + } + }, + { + "i": "d8dfb32a-1ace-4240-a826-980fa6d0bcdc", + "x": 0, + "y": 5, + "w": 4, + "h": 4, + "moved": false, + "static": false, + "z": 0, + "config": { + "_type": "tile/data-stream", + "activePluginConfigIds": [], + "title": "Agents Needing Attention", + "description": "Agents with no owner, or that are blocked, with who they're available to", + "timeframe": "none", + "dataStream": { + "id": "datastream-sql", + "dataSourceConfig": { + "version": "2.0", + "sql": "SELECT \"ownershipState\", \"displayName\", \"ownershipStatus\", CASE WHEN \"isBlocked\" THEN 'Blocked' ELSE '' END AS \"blocked\", \"platform\", \"publisher\", \"availableTo\", \"ownerCount\", \"lastModifiedDateTime\" FROM \"agents\" WHERE \"ownershipStatus\" <> 'OK' OR \"isBlocked\" ORDER BY \"ownershipStatus\", \"displayName\"", + "tables": [ + { + "tableName": "agents", + "config": { + "activePluginConfigIds": [ + "{{configId}}" + ], + "dataStream": { + "id": "{{dataStreams.[agents]}}", + "name": "agents" + }, + "timeframe": "none" + } + } + ] + } + }, + "vizSpec": { + "version": "1.0", + "visualization": { + "chartType": "richTable", + "encoding": { + "columns": [ + { + "field": "ownershipState", + "title": "", + "renderer": { + "type": "status", + "showLabel": false + }, + "width": 32 + }, + { + "field": "displayName", + "title": "Agent", + "renderer": { + "type": "text" + } + }, + { + "field": "ownershipStatus", + "title": "Ownership", + "renderer": { + "type": "badge", + "colors": { + "OK": "#22c55e", + "No owner": "#ef4444" + } + }, + "width": 120 + }, + { + "field": "blocked", + "title": "Blocked", + "renderer": { + "type": "badge", + "colors": { + "Blocked": "#f59e0b" + } + }, + "width": 100 + }, + { + "field": "platform", + "title": "Platform", + "renderer": { + "type": "text" + } + }, + { + "field": "publisher", + "title": "Publisher", + "renderer": { + "type": "text" + } + }, + { + "field": "availableTo", + "title": "Available to", + "renderer": { + "type": "text" + }, + "width": 110 + }, + { + "field": "ownerCount", + "title": "Owners", + "renderer": { + "type": "number" + }, + "align": "right", + "width": 80 + }, + { + "field": "lastModifiedDateTime", + "title": "Last updated", + "renderer": { + "type": "date", + "relative": true + }, + "width": 130 + } + ] + }, + "style": { + "richTableHideCount": false + } + } + } + } + }, + { + "i": "73a53de2-427a-4495-a8e8-6885e62dced4", + "x": 0, + "y": 9, + "w": 4, + "h": 4, + "moved": false, + "static": false, + "z": 0, + "config": { + "_type": "tile/data-stream", + "activePluginConfigIds": [], + "title": "All Agents", + "description": "Every agent in the registry, newest first", + "timeframe": "none", + "dataStream": { + "id": "datastream-sql", + "dataSourceConfig": { + "version": "2.0", + "sql": "SELECT \"displayName\", \"agentType\", \"platform\", \"publisher\", \"ownershipStatus\", \"availableTo\", \"deployedTo\", \"ownerCount\", \"createdDateTime\" FROM \"agents\" ORDER BY \"createdDateTime\" DESC NULLS LAST", + "tables": [ + { + "tableName": "agents", + "config": { + "activePluginConfigIds": [ + "{{configId}}" + ], + "dataStream": { + "id": "{{dataStreams.[agents]}}", + "name": "agents" + }, + "timeframe": "none" + } + } + ] + } + }, + "vizSpec": { + "version": "1.0", + "visualization": { + "chartType": "richTable", + "encoding": { + "columns": [ + { + "field": "displayName", + "title": "Agent", + "renderer": { + "type": "text" + } + }, + { + "field": "agentType", + "title": "Type", + "renderer": { + "type": "badge", + "defaultColor": "#3b82f6" + }, + "width": 100 + }, + { + "field": "platform", + "title": "Platform", + "renderer": { + "type": "text" + } + }, + { + "field": "publisher", + "title": "Publisher", + "renderer": { + "type": "text" + } + }, + { + "field": "ownershipStatus", + "title": "Ownership", + "renderer": { + "type": "badge", + "colors": { + "OK": "#22c55e", + "No owner": "#ef4444" + } + }, + "width": 120 + }, + { + "field": "availableTo", + "title": "Available to", + "renderer": { + "type": "text" + }, + "width": 110 + }, + { + "field": "deployedTo", + "title": "Deployed to", + "renderer": { + "type": "text" + }, + "width": 110 + }, + { + "field": "ownerCount", + "title": "Owners", + "renderer": { + "type": "number" + }, + "align": "right", + "width": 80 + }, + { + "field": "createdDateTime", + "title": "Created", + "renderer": { + "type": "date", + "relative": true + }, + "width": 120 + } + ] + } + } + } + } + } + ] + } +} diff --git a/plugins/MicrosoftCopilot/v1/defaultContent/environment.dash.json b/plugins/MicrosoftCopilot/v1/defaultContent/environment.dash.json new file mode 100644 index 00000000..90948164 --- /dev/null +++ b/plugins/MicrosoftCopilot/v1/defaultContent/environment.dash.json @@ -0,0 +1,180 @@ +{ + "name": "Environment", + "schemaVersion": "1.5", + "timeframe": "none", + "variables": [ + "{{variables.[Copilot Environment]}}" + ], + "dashboard": { + "_type": "layout/grid", + "columns": 4, + "version": 1, + "contents": [ + { + "i": "fa354534-6766-4c88-9b70-29735ff5596f", + "x": 0, + "y": 0, + "w": 2, + "h": 3, + "moved": false, + "static": false, + "z": 0, + "config": { + "_type": "tile/data-stream", + "activePluginConfigIds": [ + "{{configId}}" + ], + "title": "Environment Details", + "description": "The Power Platform environment: type, region, state and Dataverse URL", + "timeframe": "none", + "dataStream": { + "id": "datastream-properties", + "name": "properties", + "pluginConfigId": "{{configId}}" + }, + "scope": { + "scope": "{{scopes.[Copilot Environments]}}", + "variable": "{{variables.[Copilot Environment]}}", + "workspace": "{{workspaceId}}" + }, + "variables": [ + "{{variables.[Copilot Environment]}}" + ], + "vizSpec": { + "version": "1.0", + "visualization": { + "chartType": "richTable", + "encoding": { + "columns": [ + { + "field": "environmentType", + "title": "Type", + "renderer": { + "type": "badge", + "colors": { + "Production": "#6366f1", + "Sandbox": "#14b8a6", + "Developer": "#8b5cf6", + "Trial": "#d97706", + "Default": "#2563eb" + }, + "defaultColor": "#64748b" + } + }, + { + "field": "isDefault", + "title": "Default environment", + "renderer": { + "type": "boolean", + "trueLabel": "Yes", + "falseLabel": "No", + "trueColor": "#2563eb", + "falseColor": "#64748b" + } + }, + { + "field": "status", + "title": "State", + "renderer": { + "type": "badge", + "colors": { + "Ready": "#16a34a", + "NotSpecified": "#64748b" + }, + "defaultColor": "#d97706" + } + }, + { + "field": "geography", + "title": "Geography", + "renderer": { + "type": "text" + } + }, + { + "field": "azureRegion", + "title": "Azure region", + "renderer": { + "type": "text" + } + }, + { + "field": "createdTime", + "title": "Created", + "renderer": { + "type": "date" + } + }, + { + "field": "dataverseUrl", + "title": "Dataverse", + "renderer": { + "type": "link" + } + } + ] + }, + "style": { + "richTableCellPadding": 6, + "richTableTranspose": true + } + } + } + } + }, + { + "i": "2cef0e01-2415-4927-9967-a27b5863241f", + "x": 2, + "y": 0, + "w": 2, + "h": 3, + "moved": false, + "static": false, + "z": 0, + "config": { + "_type": "tile/data-stream", + "activePluginConfigIds": [ + "{{configId}}" + ], + "title": "Credit Allocations", + "description": "Capacity allocated to this environment from the tenant, by currency. Developer and some legacy environments can't hold Copilot Credit allocations, so this is empty for them", + "timeframe": "none", + "dataStream": { + "id": "{{dataStreams.[environmentCapacity]}}", + "name": "environmentCapacity", + "pluginConfigId": "{{configId}}" + }, + "scope": { + "scope": "{{scopes.[Copilot Environments]}}", + "variable": "{{variables.[Copilot Environment]}}", + "workspace": "{{workspaceId}}" + }, + "variables": [ + "{{variables.[Copilot Environment]}}" + ], + "vizSpec": { + "version": "1.0", + "visualization": { + "chartType": "scalar", + "encoding": { + "values": [ + { + "field": "allocated", + "type": "quantitative", + "title": "Allocated" + } + ], + "label": { + "field": "currency", + "type": "nominal", + "title": "Currency" + } + }, + "style": {} + } + } + } + } + ] + } +} diff --git a/plugins/MicrosoftCopilot/v1/defaultContent/manifest.json b/plugins/MicrosoftCopilot/v1/defaultContent/manifest.json new file mode 100644 index 00000000..4b3049d7 --- /dev/null +++ b/plugins/MicrosoftCopilot/v1/defaultContent/manifest.json @@ -0,0 +1,24 @@ +{ + "items": [ + { + "name": "overview", + "type": "dashboard" + }, + { + "name": "user", + "type": "dashboard" + }, + { + "name": "environment", + "type": "dashboard" + }, + { + "name": "agents", + "type": "dashboard" + }, + { + "name": "agent", + "type": "dashboard" + } + ] +} diff --git a/plugins/MicrosoftCopilot/v1/defaultContent/overview.dash.json b/plugins/MicrosoftCopilot/v1/defaultContent/overview.dash.json new file mode 100644 index 00000000..7b05e2ec --- /dev/null +++ b/plugins/MicrosoftCopilot/v1/defaultContent/overview.dash.json @@ -0,0 +1,1436 @@ +{ + "name": "Overview", + "schemaVersion": "1.5", + "timeframe": "last30days", + "variables": [], + "dashboard": { + "_type": "layout/grid", + "columns": 4, + "version": 1, + "contents": [ + { + "i": "5ed7b80b-9286-5563-bf30-0948c657b525", + "x": 0, + "y": 0, + "w": 1, + "h": 2, + "moved": false, + "static": false, + "z": 0, + "config": { + "_type": "tile/data-stream", + "activePluginConfigIds": [], + "title": "Seats in Use", + "description": "Microsoft 365 Copilot seats assigned out of those purchased. Amber when 40% or more of the seats are unassigned", + "timeframe": "none", + "dataStream": { + "id": "datastream-sql", + "dataSourceConfig": { + "version": "2.0", + "sql": "SELECT REPLACE(REPLACE(\"skuPartNumber\", 'Microsoft_365_', 'M365 '), '_', ' ') AS \"licence\", \"assigned\", \"purchased\" FROM \"licences\"", + "tables": [ + { + "tableName": "licences", + "config": { + "activePluginConfigIds": [ + "{{configId}}" + ], + "dataStream": { + "id": "{{dataStreams.[licences]}}", + "name": "licences" + }, + "timeframe": "none" + } + } + ] + } + }, + "vizSpec": { + "version": "1.0", + "visualization": { + "chartType": "ringGrid", + "encoding": { + "value": { + "field": "assigned", + "type": "quantitative" + }, + "max": { + "field": "purchased", + "type": "quantitative" + }, + "label": { + "field": "licence", + "type": "nominal" + } + }, + "style": { + "ringGridThresholds": [ + { + "to": 0.6, + "color": "#f59e0b" + }, + { + "to": 1, + "color": "#22c55e" + } + ], + "ringGridTrackWidth": 10, + "labelFontSize": 13 + } + } + } + } + }, + { + "i": "2b361145-82d8-518a-8f7b-5e657236ecd5", + "x": 1, + "y": 0, + "w": 1, + "h": 2, + "moved": false, + "static": false, + "z": 0, + "config": { + "_type": "tile/data-stream", + "activePluginConfigIds": [], + "title": "Active Users", + "description": "Copilot-enabled users who used Copilot in any app in the last 28 days", + "timeframe": "none", + "dataStream": { + "id": "datastream-sql", + "dataSourceConfig": { + "version": "2.0", + "sql": "SELECT 'Last 28 days' AS \"label\", \"activeUsers\", \"enabledUsers\" FROM \"adoption\" WHERE \"app\" = 'Any app'", + "tables": [ + { + "tableName": "adoption", + "config": { + "activePluginConfigIds": [ + "{{configId}}" + ], + "dataStream": { + "id": "{{dataStreams.[adoptionSummary]}}", + "name": "adoptionSummary", + "dataSourceConfig": { + "period": "D28" + } + }, + "timeframe": "none" + } + } + ] + } + }, + "vizSpec": { + "version": "1.0", + "visualization": { + "chartType": "ringGrid", + "encoding": { + "value": { + "field": "activeUsers", + "type": "quantitative" + }, + "max": { + "field": "enabledUsers", + "type": "quantitative" + }, + "label": { + "field": "label", + "type": "nominal" + } + }, + "style": { + "ringGridThresholds": [ + { + "to": 0.4, + "color": "#ef4444" + }, + { + "to": 0.7, + "color": "#f59e0b" + }, + { + "to": 1, + "color": "#22c55e" + } + ], + "ringGridTrackWidth": 10, + "labelFontSize": 13 + } + } + } + } + }, + { + "i": "0af47596-434f-5c25-877d-90c446b41ebc", + "x": 2, + "y": 0, + "w": 1, + "h": 2, + "moved": false, + "static": false, + "z": 0, + "config": { + "_type": "tile/data-stream", + "activePluginConfigIds": [], + "title": "Prompts", + "description": "Prompts submitted to Copilot across all apps in the last 28 days, and the average per active user", + "timeframe": "none", + "dataStream": { + "id": "datastream-sql", + "dataSourceConfig": { + "version": "2.0", + "sql": "SELECT \"totalPrompts\" AS \"prompts\", ROUND(\"averagePrompts\") AS \"perUser\" FROM \"adoption\" WHERE \"app\" = 'Any app'", + "tables": [ + { + "tableName": "adoption", + "config": { + "activePluginConfigIds": [ + "{{configId}}" + ], + "dataStream": { + "id": "{{dataStreams.[adoptionSummary]}}", + "name": "adoptionSummary", + "dataSourceConfig": { + "period": "D28" + } + }, + "timeframe": "none" + } + } + ] + } + }, + "vizSpec": { + "version": "1.0", + "visualization": { + "chartType": "scalar", + "encoding": { + "values": [ + { + "field": "prompts", + "type": "quantitative", + "title": "Prompts in 28 days" + }, + { + "field": "perUser", + "type": "quantitative", + "title": "Average per user" + } + ] + }, + "style": { + "scalarColumns": 1 + } + } + } + } + }, + { + "i": "d43e3456-7b1a-5b9f-a5fd-d3daf79f05ad", + "x": 3, + "y": 0, + "w": 1, + "h": 2, + "moved": false, + "static": false, + "z": 0, + "config": { + "_type": "tile/data-stream", + "activePluginConfigIds": [], + "title": "Copilot Studio Credits", + "description": "Whether the tenant is within its prepaid Copilot Credit capacity this month, and how many pay-as-you-go credits it has used", + "timeframe": "none", + "dataStream": { + "id": "datastream-sql", + "dataSourceConfig": { + "version": "2.0", + "sql": "SELECT CASE \"capacity.status\" WHEN 'WithinCapacity' THEN 'Within capacity' WHEN 'CoveredOverage' THEN 'Overage covered' WHEN 'Overage' THEN 'In overage' ELSE COALESCE(\"capacity.status\", 'Unknown') END AS \"label\", \"capacityState\" AS \"state\", CONCAT_WS(' · ', CASE WHEN \"capacity.entitled.value\" > 0 THEN FORMAT('{:,.0f} of {:,.0f} prepaid', \"capacity.consumed.value\", \"capacity.entitled.value\") END, FORMAT('{:,.0f} pay-as-you-go', COALESCE(\"payGo.consumed.value\", 0))) AS \"detail\" FROM \"credits\"", + "tables": [ + { + "tableName": "credits", + "config": { + "activePluginConfigIds": [ + "{{configId}}" + ], + "dataStream": { + "id": "{{dataStreams.[creditCapacity]}}", + "name": "creditCapacity" + }, + "timeframe": "none" + } + } + ] + } + }, + "vizSpec": { + "version": "1.0", + "visualization": { + "chartType": "statusGrid", + "encoding": { + "label": { + "field": "label", + "type": "nominal" + }, + "status": { + "field": "state", + "type": "nominal" + } + }, + "style": { + "statusGridColumnsPerRow": 1, + "statusGridLabelWrap": true, + "statusGridSecondaryTemplate": "{{{{raw}}}}{{detail}}{{{{/raw}}}}", + "labelFontSize": 16, + "secondaryFontSize": 12 + } + } + } + } + }, + { + "i": "53a77d15-61db-5626-b137-22c25eb89728", + "x": 0, + "y": 2, + "w": 2, + "h": 3, + "moved": false, + "static": false, + "z": 0, + "config": { + "_type": "tile/data-stream", + "activePluginConfigIds": [], + "title": "Adoption by App", + "description": "Percentage of Copilot-enabled users who used Copilot in each app in the last 28 days", + "timeframe": "none", + "dataStream": { + "id": "datastream-sql", + "dataSourceConfig": { + "version": "2.0", + "sql": "SELECT \"app\", \"activeRate\" AS \"rate\" FROM \"adoption\" WHERE \"app\" NOT IN ('Any app', 'Copilot Chat (all)') ORDER BY \"activeRate\" DESC, \"app\"", + "tables": [ + { + "tableName": "adoption", + "config": { + "activePluginConfigIds": [ + "{{configId}}" + ], + "dataStream": { + "id": "{{dataStreams.[adoptionSummary]}}", + "name": "adoptionSummary", + "dataSourceConfig": { + "period": "D28" + } + }, + "timeframe": "none" + } + } + ] + } + }, + "vizSpec": { + "version": "1.0", + "visualization": { + "chartType": "bullet", + "encoding": { + "value": { + "field": "rate", + "type": "quantitative", + "title": "Active rate" + }, + "label": { + "field": "app", + "type": "nominal" + } + }, + "style": { + "gaugeMin": 0, + "gaugeMax": 100, + "bulletFillColor": "#3b82f6", + "bulletLabelWidth": 140, + "bulletTrackHeight": 14 + } + } + } + } + }, + { + "i": "4a277e0a-e95b-596d-a930-5292561f329d", + "x": 2, + "y": 2, + "w": 2, + "h": 3, + "moved": false, + "static": false, + "z": 0, + "config": { + "_type": "tile/data-stream", + "activePluginConfigIds": [], + "title": "Daily Activity", + "description": "Users active in any Copilot app each day, and prompts submitted, over the last 28 days", + "timeframe": "none", + "dataStream": { + "id": "datastream-sql", + "dataSourceConfig": { + "version": "2.0", + "sql": "SELECT \"reportDate\" AS \"date\", \"activeUsers\", \"promptsSubmitted\" AS \"prompts\" FROM \"trend\" WHERE \"app\" = 'Any app' ORDER BY \"reportDate\"", + "tables": [ + { + "tableName": "trend", + "config": { + "activePluginConfigIds": [ + "{{configId}}" + ], + "dataStream": { + "id": "{{dataStreams.[adoptionTrend]}}", + "name": "adoptionTrend", + "dataSourceConfig": { + "period": "D28" + } + }, + "timeframe": "none" + } + } + ] + } + }, + "vizSpec": { + "version": "1.0", + "visualization": { + "chartType": "line", + "encoding": { + "x": { + "field": "date", + "type": "temporal" + } + }, + "style": { + "cartesianAreaGradient": true, + "cartesianY2AxisField": "prompts", + "legendPosition": "bottom", + "mappedColors": { + "activeUsers": "#22c55e", + "prompts": "#3b82f6" + } + } + } + } + } + }, + { + "i": "323139b5-1cf8-56d9-b74d-da0c78a5ecee", + "x": 0, + "y": 5, + "w": 2, + "h": 3, + "moved": false, + "static": false, + "z": 0, + "config": { + "_type": "tile/data-stream", + "activePluginConfigIds": [], + "title": "Seats by Status", + "description": "Copilot-licensed users by seat status: Active (used in the last 7 days), Low use (8–28 days), Idle (over 28 days), Never used, or Possible leaver (account disabled)", + "timeframe": "none", + "dataStream": { + "id": "datastream-sql", + "dataSourceConfig": { + "version": "2.0", + "sql": "SELECT \"seatStatus\" AS \"status\", COUNT(*) AS \"users\" FROM \"activity\" GROUP BY 1", + "tables": [ + { + "tableName": "activity", + "config": { + "activePluginConfigIds": [ + "{{configId}}" + ], + "dataStream": { + "id": "{{dataStreams.[userActivity]}}", + "name": "userActivity", + "dataSourceConfig": { + "period": "D28" + } + }, + "timeframe": "none" + } + } + ] + } + }, + "vizSpec": { + "version": "1.0", + "visualization": { + "chartType": "pie", + "encoding": { + "label": { + "field": "status", + "type": "nominal" + }, + "value": { + "field": "users", + "type": "quantitative", + "aggregate": "sum" + } + }, + "style": { + "pieInnerRadius": 60, + "pieDonutCenterValue": "total", + "labelFontSize": 14, + "pieLabels": "nameAndValue", + "mappedColors": { + "Active": "#22c55e", + "Low use": "#f59e0b", + "Idle": "#ef4444", + "Never used": "#6b7280", + "Possible leaver": "#a855f7" + } + } + } + } + } + }, + { + "i": "033c11f9-3f22-5ed7-8ed5-30fe5b94b6d6", + "x": 2, + "y": 5, + "w": 2, + "h": 3, + "moved": false, + "static": false, + "z": 0, + "config": { + "_type": "tile/data-stream", + "activePluginConfigIds": [], + "title": "Seats to Review", + "description": "Licensed users who haven't used Copilot for more than 7 days, have never used it, or whose account is disabled, with their department. Candidates for training or for reclaiming the licence", + "timeframe": "none", + "dataStream": { + "id": "datastream-sql", + "dataSourceConfig": { + "version": "2.0", + "sql": "SELECT \"displayName\", CASE WHEN CAST(\"department\" AS VARCHAR) LIKE 'Object not found%' THEN NULL ELSE \"department\" END AS \"department\", \"seatStatus\", \"lastActivityDate\", \"daysSinceLastActivity\" FROM \"activity\" WHERE \"seatStatus\" <> 'Active' ORDER BY \"daysSinceLastActivity\" DESC NULLS FIRST", + "tables": [ + { + "tableName": "activity", + "config": { + "activePluginConfigIds": [ + "{{configId}}" + ], + "dataStream": { + "id": "{{dataStreams.[userActivity]}}", + "name": "userActivity", + "dataSourceConfig": { + "period": "D28" + } + }, + "timeframe": "none" + } + } + ] + } + }, + "vizSpec": { + "version": "1.0", + "visualization": { + "chartType": "richTable", + "encoding": { + "columns": [ + { + "field": "displayName", + "title": "User", + "renderer": { + "type": "text" + } + }, + { + "field": "department", + "title": "Department", + "renderer": { + "type": "text" + } + }, + { + "field": "seatStatus", + "title": "Status", + "renderer": { + "type": "badge", + "colors": { + "Active": "#22c55e", + "Low use": "#f59e0b", + "Idle": "#ef4444", + "Never used": "#6b7280", + "Possible leaver": "#a855f7" + } + }, + "width": 130 + }, + { + "field": "lastActivityDate", + "title": "Last used", + "renderer": { + "type": "date", + "relative": true + }, + "width": 120 + }, + { + "field": "daysSinceLastActivity", + "title": "Days idle", + "renderer": { + "type": "number" + }, + "align": "right", + "width": 100 + } + ] + }, + "style": {} + } + } + } + }, + { + "i": "0ae0d24a-25fa-4c3c-9fb6-67ea729bc256", + "x": 0, + "y": 8, + "w": 2, + "h": 3, + "moved": false, + "static": false, + "z": 0, + "config": { + "_type": "tile/data-stream", + "activePluginConfigIds": [], + "title": "Adoption by Department", + "description": "Copilot seats per department, the share used in the last 28 days, and prompts per seat over 28 days. Department comes from Microsoft Entra ID through the imported Copilot Users", + "timeframe": "none", + "dataStream": { + "id": "datastream-sql", + "dataSourceConfig": { + "version": "2.0", + "sql": "SELECT COALESCE(NULLIF(TRIM(CASE WHEN CAST(\"department\" AS VARCHAR) LIKE 'Object not found%' THEN NULL ELSE \"department\" END), ''), '(No department)') AS \"department\", COUNT(*) AS \"seats\", CAST(ROUND(100.0 * SUM(CASE WHEN \"daysSinceLastActivity\" <= 28 THEN 1 ELSE 0 END) / COUNT(*), 0) AS DOUBLE) AS \"activePct\", CAST(ROUND(SUM(\"promptsSubmitted\") * 1.0 / COUNT(*), 1) AS DOUBLE) AS \"promptsPerSeat\" FROM \"activity\" WHERE CAST(\"department\" AS VARCHAR) NOT LIKE 'Object not found%' OR \"department\" IS NULL GROUP BY 1 ORDER BY 2 DESC", + "tables": [ + { + "tableName": "activity", + "config": { + "activePluginConfigIds": [ + "{{configId}}" + ], + "dataStream": { + "id": "{{dataStreams.[userActivity]}}", + "name": "userActivity", + "dataSourceConfig": { + "period": "D28" + } + }, + "timeframe": "none" + } + } + ] + } + }, + "vizSpec": { + "version": "1.0", + "visualization": { + "chartType": "richTable", + "encoding": { + "columns": [ + { + "field": "department", + "title": "Department", + "renderer": { + "type": "text" + } + }, + { + "field": "seats", + "title": "Seats", + "renderer": { + "type": "number" + }, + "align": "right", + "width": 100 + }, + { + "field": "activePct", + "title": "Active % (28d)", + "renderer": { + "type": "bar", + "max": 100, + "suffix": "%", + "thresholds": [ + { + "to": 49, + "color": "#ef4444" + }, + { + "to": 74, + "color": "#f59e0b" + }, + { + "to": 100, + "color": "#22c55e" + } + ] + } + }, + { + "field": "promptsPerSeat", + "title": "Prompts / seat", + "renderer": { + "type": "number", + "decimals": 1 + }, + "align": "right", + "width": 140 + } + ] + }, + "style": { + "richTableSort": { + "field": "seats", + "direction": "desc" + } + } + } + } + } + }, + { + "i": "f90a5d15-8cda-5354-b904-f9696a3ca96a", + "x": 2, + "y": 8, + "w": 2, + "h": 3, + "moved": false, + "static": false, + "z": 0, + "config": { + "_type": "tile/data-stream", + "activePluginConfigIds": [], + "title": "Top Users by Prompts", + "description": "The ten users who submitted the most Copilot prompts in the last 28 days", + "timeframe": "none", + "dataStream": { + "id": "datastream-sql", + "dataSourceConfig": { + "version": "2.0", + "sql": "SELECT \"user\", \"prompts\" FROM (SELECT \"displayName\" AS \"user\", \"promptsSubmitted\" AS \"prompts\" FROM \"activity\" WHERE \"promptsSubmitted\" > 0 ORDER BY \"promptsSubmitted\" DESC LIMIT 10) ORDER BY \"prompts\" ASC", + "tables": [ + { + "tableName": "activity", + "config": { + "activePluginConfigIds": [ + "{{configId}}" + ], + "dataStream": { + "id": "{{dataStreams.[userActivity]}}", + "name": "userActivity", + "dataSourceConfig": { + "period": "D28" + } + }, + "timeframe": "none" + } + } + ] + } + }, + "vizSpec": { + "version": "1.0", + "visualization": { + "chartType": "bar", + "encoding": { + "x": { + "field": "user", + "type": "nominal", + "title": "User" + }, + "y": { + "field": "prompts", + "type": "quantitative", + "title": "Prompts" + } + }, + "style": { + "cartesianHorizontal": true, + "cartesianBarBorderRadius": 4, + "showLabels": true, + "colors": [ + "#3b82f6" + ] + } + } + } + } + }, + { + "i": "9f452077-0ef4-57e4-a763-87cd074034ad", + "x": 0, + "y": 11, + "w": 2, + "h": 3, + "moved": false, + "static": false, + "z": 0, + "config": { + "_type": "tile/data-stream", + "activePluginConfigIds": [ + "{{configId}}" + ], + "title": "Credit Allocations by Environment", + "description": "Capacity allocated to each Power Platform environment, by currency. Environments that can't hold allocations aren't listed", + "timeframe": "none", + "dataStream": { + "id": "{{dataStreams.[environmentCapacity]}}", + "name": "environmentCapacity", + "pluginConfigId": "{{configId}}", + "sort": { + "by": [ + [ + "allocated", + "desc" + ] + ] + } + }, + "scope": { + "scope": "{{scopes.[Copilot Environments]}}", + "workspace": "{{workspaceId}}" + }, + "vizSpec": { + "version": "1.0", + "visualization": { + "chartType": "richTable", + "encoding": { + "columns": [ + { + "field": "environmentName", + "title": "Environment", + "renderer": { + "type": "text" + } + }, + { + "field": "currency", + "title": "Currency", + "renderer": { + "type": "badge", + "defaultColor": "#3b82f6" + } + }, + { + "field": "allocated", + "title": "Allocated", + "renderer": { + "type": "bar", + "color": "#3b82f6" + } + } + ] + }, + "style": {} + } + } + } + }, + { + "i": "e8b64d25-b9dd-4f1a-a9b2-261ceda64876", + "x": 2, + "y": 11, + "w": 2, + "h": 3, + "moved": false, + "static": false, + "z": 0, + "config": { + "_type": "tile/data-stream", + "activePluginConfigIds": [ + "{{configId}}" + ], + "title": "Cost Budgets", + "description": "Cost Management budgets at the Cost Management scope, with spend so far this period and the forecast at period end. Amber at 80% used or when the forecast exceeds the budget, red when it's exceeded", + "timeframe": "none", + "dataStream": { + "id": "{{dataStreams.[budgets]}}", + "name": "budgets", + "pluginConfigId": "{{configId}}", + "sort": { + "by": [ + [ + "percentUsed", + "desc" + ] + ] + } + }, + "vizSpec": { + "version": "1.0", + "visualization": { + "chartType": "richTable", + "encoding": { + "columns": [ + { + "field": "budgetState", + "title": "", + "renderer": { + "type": "status", + "showLabel": false + }, + "width": 32 + }, + { + "field": "name", + "title": "Budget", + "renderer": { + "type": "text" + } + }, + { + "field": "currentSpend", + "title": "Spent", + "renderer": { + "type": "number", + "decimals": 0 + }, + "align": "right", + "width": 90 + }, + { + "field": "amount", + "title": "Budget", + "renderer": { + "type": "number", + "decimals": 0 + }, + "align": "right", + "width": 90 + }, + { + "field": "percentUsed", + "title": "Used %", + "renderer": { + "type": "bar", + "max": 100, + "suffix": "%", + "thresholds": [ + { + "to": 79, + "color": "#22c55e" + }, + { + "to": 99, + "color": "#f59e0b" + }, + { + "to": 100000, + "color": "#ef4444" + } + ] + } + }, + { + "field": "percentForecast", + "title": "Forecast", + "renderer": { + "type": "number", + "decimals": 0, + "suffix": "%", + "thresholds": [ + { + "to": 100, + "color": "#9ca3af" + }, + { + "to": 100000, + "color": "#f59e0b" + } + ] + }, + "align": "right", + "width": 110 + } + ] + }, + "style": { + "richTableHideCount": true + } + } + } + } + }, + { + "i": "391d9af4-cde3-556c-98ef-68b34d639d02", + "x": 0, + "y": 14, + "w": 4, + "h": 3, + "moved": false, + "static": false, + "z": 0, + "config": { + "_type": "tile/data-stream", + "activePluginConfigIds": [], + "title": "Copilot and AI Spend", + "description": "Daily Azure cost of Copilot Studio, Copilot pay-as-you-go and Azure AI services from Cost Management, by service, with each service's total for the timeframe", + "dataStream": { + "id": "datastream-sql", + "dataSourceConfig": { + "version": "2.0", + "sql": "SELECT \"usageDate\" AS \"day\", \"group\" || ' (' || \"currency\" || ')' AS \"service\", SUM(\"cost\") AS \"cost\" FROM \"spend\" GROUP BY 1, 2 ORDER BY 1", + "tables": [ + { + "tableName": "spend", + "config": { + "activePluginConfigIds": [ + "{{configId}}" + ], + "dataStream": { + "id": "{{dataStreams.[spend]}}", + "name": "spend", + "dataSourceConfig": { + "groupBy": "ServiceName", + "scopeOfCosts": "copilot" + } + } + } + } + ] + } + }, + "vizSpec": { + "version": "1.0", + "visualization": { + "chartType": "bar", + "encoding": { + "x": { + "field": "day", + "type": "temporal", + "title": "Day" + }, + "y": { + "field": "cost", + "type": "quantitative", + "title": "Cost", + "aggregate": "sum" + }, + "series": { + "field": "service", + "type": "nominal", + "title": "Service" + } + }, + "style": { + "cartesianStack": "on", + "legendPosition": "right", + "cartesianLegendStyle": "table", + "cartesianLegendStats": [ + "sum" + ], + "cartesianBarBorderRadius": 2, + "cartesianYAxisDecimalPlaces": 2 + } + } + } + } + }, + { + "i": "ac929a02-cbef-4e8c-81ef-6ab6013be8cd", + "x": 2, + "y": 17, + "w": 2, + "h": 3, + "moved": false, + "static": false, + "z": 0, + "config": { + "_type": "tile/data-stream", + "activePluginConfigIds": [], + "title": "Copilot Emissions", + "description": "Monthly carbon emissions from Microsoft 365 Copilot use, by emissions scope (scope 2 location-based), as reported by Microsoft Graph. Microsoft's Emissions Impact Dashboard reports these figures in metric tons of CO2e", + "timeframe": "none", + "dataStream": { + "id": "datastream-sql", + "dataSourceConfig": { + "version": "2.0", + "sql": "SELECT \"monthStart\" AS \"month\", 'Scope 1' AS \"scope\", CAST(SUM(\"scope1Emissions\") AS DOUBLE) AS \"emissions\" FROM \"emissions\" GROUP BY 1 UNION ALL SELECT \"monthStart\", 'Scope 2', CAST(SUM(\"scope2LocationBasedEmissions\") AS DOUBLE) FROM \"emissions\" GROUP BY 1 UNION ALL SELECT \"monthStart\", 'Scope 3', CAST(SUM(\"scope3Emissions\") AS DOUBLE) FROM \"emissions\" GROUP BY 1 ORDER BY 1, 2", + "tables": [ + { + "tableName": "emissions", + "config": { + "activePluginConfigIds": [ + "{{configId}}" + ], + "dataStream": { + "id": "{{dataStreams.[emissions]}}", + "name": "emissions" + }, + "timeframe": "none" + } + } + ] + } + }, + "vizSpec": { + "version": "1.0", + "visualization": { + "chartType": "bar", + "encoding": { + "x": { + "field": "month", + "type": "temporal", + "title": "Month" + }, + "y": { + "field": "emissions", + "type": "quantitative", + "title": "Emissions (CO2e)", + "aggregate": "sum" + }, + "series": { + "field": "scope", + "type": "nominal", + "title": "Scope" + } + }, + "style": { + "cartesianStack": "on", + "legendPosition": "bottom", + "cartesianBarBorderRadius": 2, + "cartesianYAxisDecimalPlaces": 4, + "mappedColors": { + "Scope 1": "#f59e0b", + "Scope 2": "#3b82f6", + "Scope 3": "#a855f7" + } + } + } + } + } + }, + { + "i": "0d997771-47d4-42f5-aa62-7f4e5f32cbcc", + "x": 0, + "y": 17, + "w": 2, + "h": 3, + "moved": false, + "static": false, + "z": 0, + "config": { + "_type": "tile/data-stream", + "activePluginConfigIds": [ + "{{configId}}" + ], + "title": "AI App Sign-ins", + "description": "Sign-ins over the last 30 days to AI apps that use Microsoft Entra sign-in, such as Copilot, ChatGPT Enterprise or Claude connectors to Microsoft 365. Apps are recognised by name, and personal AI accounts aren't seen", + "timeframe": "none", + "dataStream": { + "id": "{{dataStreams.[appSignIns]}}", + "name": "appSignIns", + "pluginConfigId": "{{configId}}", + "dataSourceConfig": { + "period": "D30", + "apps": "ai" + }, + "sort": { + "by": [ + [ + "totalSignInCount", + "desc" + ] + ] + } + }, + "vizSpec": { + "version": "1.0", + "visualization": { + "chartType": "richTable", + "encoding": { + "columns": [ + { + "field": "appDisplayName", + "title": "App", + "renderer": { + "type": "text" + } + }, + { + "field": "aiVendor", + "title": "Vendor", + "renderer": { + "type": "badge", + "colors": { + "Microsoft Copilot": "#3b82f6", + "GitHub Copilot": "#6366f1", + "Anthropic": "#d97706", + "OpenAI": "#10b981", + "Google": "#ef4444", + "Other AI": "#6b7280" + }, + "defaultColor": "#6b7280" + }, + "width": 150 + }, + { + "field": "totalSignInCount", + "title": "Sign-ins", + "renderer": { + "type": "bar", + "color": "#3b82f6" + } + }, + { + "field": "failedSignInCount", + "title": "Failed", + "renderer": { + "type": "number", + "thresholds": [ + { + "to": 0, + "color": "#9ca3af" + }, + { + "to": 100000000, + "color": "#f59e0b" + } + ] + }, + "align": "right", + "width": 80 + } + ] + }, + "style": { + "richTableHideCount": true + } + } + } + } + }, + { + "i": "426c3e79-f52b-45b6-9366-0fe81d943488", + "x": 0, + "y": 20, + "w": 4, + "h": 4, + "moved": false, + "static": false, + "z": 0, + "config": { + "_type": "tile/data-stream", + "activePluginConfigIds": [], + "title": "AI App Permissions", + "description": "What AI apps people sign in to have been allowed to do: delegated permissions granted for all users or by individual users, and application permissions, with the API each is granted on. Red marks grants that go beyond basic sign-in", + "timeframe": "none", + "dataStream": { + "id": "datastream-sql", + "dataSourceConfig": { + "version": "2.0", + "sql": "SELECT \"appDisplayName\", \"publisher\", \"resource\", \"grantedTo\", COALESCE(\"userDisplayName\", '') AS \"user\", \"permissions\", CASE WHEN \"beyondSignIn\" THEN 'Beyond sign-in' ELSE 'Sign-in only' END AS \"reach\" FROM \"grants\" ORDER BY \"beyondSignIn\" DESC, \"appDisplayName\", \"grantedTo\"", + "tables": [ + { + "tableName": "grants", + "config": { + "activePluginConfigIds": [ + "{{configId}}" + ], + "dataStream": { + "id": "{{dataStreams.[aiAppPermissions]}}", + "name": "aiAppPermissions" + }, + "timeframe": "none" + } + } + ] + } + }, + "vizSpec": { + "version": "1.0", + "visualization": { + "chartType": "richTable", + "encoding": { + "columns": [ + { + "field": "appDisplayName", + "title": "App", + "renderer": { + "type": "text" + } + }, + { + "field": "publisher", + "title": "Publisher", + "renderer": { + "type": "text" + }, + "width": 140 + }, + { + "field": "resource", + "title": "Granted on", + "renderer": { + "type": "text" + } + }, + { + "field": "grantedTo", + "title": "Granted to", + "renderer": { + "type": "badge", + "colors": { + "All users": "#d97706", + "One user": "#3b82f6", + "The app itself": "#ef4444" + } + }, + "width": 120 + }, + { + "field": "user", + "title": "User", + "renderer": { + "type": "text" + }, + "width": 140 + }, + { + "field": "reach", + "title": "Access", + "renderer": { + "type": "badge", + "colors": { + "Beyond sign-in": "#ef4444", + "Sign-in only": "#64748b" + } + }, + "width": 120 + }, + { + "field": "permissions", + "title": "Permissions", + "renderer": { + "type": "tag-list" + } + } + ] + }, + "style": { + "richTableWrapText": true + } + } + } + } + }, + { + "i": "beb384bc-63e5-4410-a64a-308285195c6f", + "x": 0, + "y": 24, + "w": 4, + "h": 3, + "moved": false, + "static": false, + "z": 0, + "config": { + "_type": "tile/data-stream", + "activePluginConfigIds": [], + "title": "Possible Leavers", + "description": "Copilot seats whose user hasn't signed in to Microsoft Entra for 30 days or whose account is disabled, from live sign-in data. Needs AuditLog.Read.All and Microsoft Entra ID P1 or P2", + "timeframe": "none", + "dataStream": { + "id": "datastream-sql", + "dataSourceConfig": { + "version": "2.0", + "sql": "SELECT s.\"displayName\", s.\"userPrincipalName\", CASE WHEN s.\"accountEnabled\" = false THEN 'Account disabled' ELSE 'No recent sign-in' END AS \"reason\", s.\"lastSignInDateTime\", DATE_DIFF('day', CAST(s.\"lastSignInDateTime\" AS TIMESTAMP), CAST(NOW() AS TIMESTAMP)) AS \"daysSinceSignIn\", a.\"lastActivityDate\" FROM \"signins\" s LEFT JOIN \"activity\" a ON LOWER(a.\"userPrincipalName\") = LOWER(s.\"userPrincipalName\") WHERE s.\"accountEnabled\" = false OR s.\"lastSignInDateTime\" IS NULL OR CAST(s.\"lastSignInDateTime\" AS TIMESTAMP) < NOW() - INTERVAL 30 DAY ORDER BY \"daysSinceSignIn\" DESC NULLS FIRST", + "tables": [ + { + "tableName": "signins", + "config": { + "activePluginConfigIds": [ + "{{configId}}" + ], + "dataStream": { + "id": "{{dataStreams.[userSignIns]}}", + "name": "userSignIns" + }, + "timeframe": "none" + } + }, + { + "tableName": "activity", + "config": { + "activePluginConfigIds": [ + "{{configId}}" + ], + "dataStream": { + "id": "{{dataStreams.[userActivity]}}", + "name": "userActivity", + "dataSourceConfig": { + "period": "D28" + } + }, + "timeframe": "none" + } + } + ] + } + }, + "vizSpec": { + "version": "1.0", + "visualization": { + "chartType": "richTable", + "encoding": { + "columns": [ + { + "field": "displayName", + "title": "User", + "renderer": { + "type": "text" + } + }, + { + "field": "userPrincipalName", + "title": "User principal name", + "renderer": { + "type": "text" + } + }, + { + "field": "reason", + "title": "Reason", + "renderer": { + "type": "badge", + "colors": { + "Account disabled": "#ef4444", + "No recent sign-in": "#a855f7" + } + }, + "width": 150 + }, + { + "field": "lastSignInDateTime", + "title": "Last sign-in", + "renderer": { + "type": "date", + "relative": true + }, + "width": 130 + }, + { + "field": "lastActivityDate", + "title": "Last used Copilot", + "renderer": { + "type": "date", + "relative": true + }, + "width": 140 + } + ] + } + } + } + } + } + ] + } +} diff --git a/plugins/MicrosoftCopilot/v1/defaultContent/scopes.json b/plugins/MicrosoftCopilot/v1/defaultContent/scopes.json new file mode 100644 index 00000000..f4a55f38 --- /dev/null +++ b/plugins/MicrosoftCopilot/v1/defaultContent/scopes.json @@ -0,0 +1,53 @@ +[ + { + "name": "Copilot Users", + "matches": { + "sourceType": { + "type": "oneOf", + "values": [ + "User" + ] + } + }, + "variable": { + "name": "Copilot User", + "allowMultipleSelection": false, + "default": "none", + "type": "object" + } + }, + { + "name": "Copilot Environments", + "matches": { + "sourceType": { + "type": "oneOf", + "values": [ + "Environment" + ] + } + }, + "variable": { + "name": "Copilot Environment", + "allowMultipleSelection": false, + "default": "none", + "type": "object" + } + }, + { + "name": "Copilot Agents", + "matches": { + "sourceType": { + "type": "oneOf", + "values": [ + "Agent" + ] + } + }, + "variable": { + "name": "Copilot Agent", + "allowMultipleSelection": false, + "default": "none", + "type": "object" + } + } +] diff --git a/plugins/MicrosoftCopilot/v1/defaultContent/user.dash.json b/plugins/MicrosoftCopilot/v1/defaultContent/user.dash.json new file mode 100644 index 00000000..11f87624 --- /dev/null +++ b/plugins/MicrosoftCopilot/v1/defaultContent/user.dash.json @@ -0,0 +1,481 @@ +{ + "name": "Copilot User", + "schemaVersion": "1.5", + "timeframe": "none", + "variables": [ + "{{variables.[Copilot User]}}" + ], + "dashboard": { + "_type": "layout/grid", + "columns": 4, + "version": 1, + "contents": [ + { + "i": "d103ff83-c267-44ea-8620-895caddcbe1d", + "x": 0, + "y": 0, + "w": 1, + "h": 2, + "moved": false, + "static": false, + "z": 0, + "config": { + "_type": "tile/data-stream", + "activePluginConfigIds": [ + "{{configId}}" + ], + "title": "Copilot Activity", + "description": "Active in the last 7 days (green), idle for more than 7 days (amber), or idle for more than 28 days or never used (red)", + "timeframe": "none", + "variables": [ + "{{variables.[Copilot User]}}" + ], + "dataStream": { + "id": "{{dataStreams.[userActivity]}}", + "name": "userActivity", + "pluginConfigId": "{{configId}}", + "dataSourceConfig": { + "period": "D28", + "users": { + "variable": "{{variables.[Copilot User]}}", + "workspace": "{{workspaceId}}", + "scope": "{{scopes.[Copilot Users]}}" + } + } + }, + "vizSpec": { + "version": "1.0", + "visualization": { + "chartType": "statusGrid", + "encoding": { + "label": { + "field": "displayName", + "type": "nominal", + "title": "Name" + }, + "status": { + "field": "activityState", + "type": "nominal", + "title": "Activity" + }, + "value": { + "field": "lastUsed", + "type": "nominal", + "title": "Last used" + } + }, + "style": { + "statusGridColumnsPerRow": 1, + "statusGridLabelWrap": true, + "labelFontSize": 16, + "secondaryFontSize": 12 + } + } + } + } + }, + { + "i": "425c8683-6f66-553d-b3a3-e22076044687", + "x": 1, + "y": 0, + "w": 1, + "h": 2, + "moved": false, + "static": false, + "z": 0, + "config": { + "_type": "tile/data-stream", + "activePluginConfigIds": [ + "{{configId}}" + ], + "title": "Active Days", + "description": "Days in the last 28 on which this user used Copilot in any app", + "timeframe": "none", + "variables": [ + "{{variables.[Copilot User]}}" + ], + "dataStream": { + "id": "{{dataStreams.[userActivity]}}", + "name": "userActivity", + "pluginConfigId": "{{configId}}", + "dataSourceConfig": { + "period": "D28", + "users": { + "variable": "{{variables.[Copilot User]}}", + "workspace": "{{workspaceId}}", + "scope": "{{scopes.[Copilot Users]}}" + } + } + }, + "vizSpec": { + "version": "1.0", + "visualization": { + "chartType": "ringGrid", + "encoding": { + "value": { + "field": "activeDays", + "type": "quantitative" + } + }, + "style": { + "ringGridMax": 28, + "ringGridTrackWidth": 10, + "ringGridThresholds": [ + { + "to": 0.15, + "color": "#f59e0b" + }, + { + "to": 1, + "color": "#22c55e" + } + ] + } + } + } + } + }, + { + "i": "861a1e31-e58c-4754-94fc-535a489123ed", + "x": 2, + "y": 0, + "w": 2, + "h": 2, + "moved": false, + "static": false, + "z": 0, + "config": { + "_type": "tile/data-stream", + "activePluginConfigIds": [ + "{{configId}}" + ], + "title": "Usage (28 Days)", + "description": "Prompts this user submitted to Copilot in the last 28 days, days since they last used it, and their seat status (Possible leaver when the account is disabled)", + "timeframe": "none", + "variables": [ + "{{variables.[Copilot User]}}" + ], + "dataStream": { + "id": "{{dataStreams.[userActivity]}}", + "name": "userActivity", + "pluginConfigId": "{{configId}}", + "dataSourceConfig": { + "period": "D28", + "users": { + "variable": "{{variables.[Copilot User]}}", + "workspace": "{{workspaceId}}", + "scope": "{{scopes.[Copilot Users]}}" + } + } + }, + "vizSpec": { + "version": "1.0", + "visualization": { + "chartType": "scalar", + "encoding": { + "values": [ + { + "field": "promptsSubmitted", + "type": "quantitative", + "title": "Prompts submitted" + }, + { + "field": "daysSinceLastActivity", + "type": "quantitative", + "title": "Days since last use" + }, + { + "field": "seatStatus", + "type": "nominal", + "title": "Seat status" + } + ] + }, + "style": { + "scalarColumns": 3 + } + } + } + } + }, + { + "i": "eb1b900e-5c32-4cf9-8dc1-e6e26224b822", + "x": 0, + "y": 2, + "w": 2, + "h": 3, + "moved": false, + "static": false, + "z": 0, + "config": { + "_type": "tile/data-stream", + "activePluginConfigIds": [ + "{{configId}}" + ], + "title": "User Details", + "description": "The user's Entra ID profile", + "timeframe": "none", + "dataStream": { + "id": "datastream-properties", + "name": "properties", + "pluginConfigId": "{{configId}}" + }, + "scope": { + "scope": "{{scopes.[Copilot Users]}}", + "variable": "{{variables.[Copilot User]}}", + "workspace": "{{workspaceId}}" + }, + "variables": [ + "{{variables.[Copilot User]}}" + ], + "vizSpec": { + "version": "1.0", + "visualization": { + "chartType": "richTable", + "encoding": { + "columns": [ + { + "field": "userPrincipalName", + "title": "User principal name", + "renderer": { + "type": "text" + } + }, + { + "field": "mail", + "title": "Email", + "renderer": { + "type": "text" + } + }, + { + "field": "jobTitle", + "title": "Job title", + "renderer": { + "type": "text" + } + }, + { + "field": "department", + "title": "Department", + "renderer": { + "type": "text" + } + }, + { + "field": "officeLocation", + "title": "Office", + "renderer": { + "type": "text" + } + }, + { + "field": "country", + "title": "Country", + "renderer": { + "type": "text" + } + }, + { + "field": "accountEnabled", + "title": "Account enabled", + "renderer": { + "type": "boolean", + "trueLabel": "Yes", + "falseLabel": "No", + "trueColor": "#16a34a", + "falseColor": "#dc2626" + } + } + ] + }, + "style": { + "richTableCellPadding": 6, + "richTableTranspose": true + } + } + } + } + }, + { + "i": "4640a3f2-063d-4353-b7bb-012ee5a2c3a7", + "x": 2, + "y": 2, + "w": 2, + "h": 3, + "moved": false, + "static": false, + "z": 0, + "config": { + "_type": "tile/data-stream", + "activePluginConfigIds": [ + "{{configId}}" + ], + "title": "Last Used by App", + "description": "When this user last used Copilot in each Microsoft 365 app. Blank means never in the reporting window", + "timeframe": "none", + "variables": [ + "{{variables.[Copilot User]}}" + ], + "dataStream": { + "id": "{{dataStreams.[userActivity]}}", + "name": "userActivity", + "pluginConfigId": "{{configId}}", + "dataSourceConfig": { + "period": "D28", + "users": { + "variable": "{{variables.[Copilot User]}}", + "workspace": "{{workspaceId}}", + "scope": "{{scopes.[Copilot Users]}}" + } + } + }, + "vizSpec": { + "version": "1.0", + "visualization": { + "chartType": "richTable", + "encoding": { + "columns": [ + { + "field": "copilotChatLastActivityDate", + "title": "Copilot Chat", + "renderer": { + "type": "date", + "relative": true + } + }, + { + "field": "teamsLastActivityDate", + "title": "Teams", + "renderer": { + "type": "date", + "relative": true + } + }, + { + "field": "outlookLastActivityDate", + "title": "Outlook", + "renderer": { + "type": "date", + "relative": true + } + }, + { + "field": "wordLastActivityDate", + "title": "Word", + "renderer": { + "type": "date", + "relative": true + } + }, + { + "field": "excelLastActivityDate", + "title": "Excel", + "renderer": { + "type": "date", + "relative": true + } + }, + { + "field": "powerPointLastActivityDate", + "title": "PowerPoint", + "renderer": { + "type": "date", + "relative": true + } + }, + { + "field": "oneNoteLastActivityDate", + "title": "OneNote", + "renderer": { + "type": "date", + "relative": true + } + }, + { + "field": "loopLastActivityDate", + "title": "Loop", + "renderer": { + "type": "date", + "relative": true + } + }, + { + "field": "reportRefreshDate", + "title": "Report refreshed", + "renderer": { + "type": "date" + } + } + ] + }, + "style": { + "richTableCellPadding": 6, + "richTableTranspose": true + } + } + } + } + }, + { + "i": "4bcb6324-fef7-4b05-bd1f-19739511fd07", + "x": 0, + "y": 5, + "w": 4, + "h": 3, + "moved": false, + "static": false, + "z": 0, + "config": { + "_type": "tile/data-stream", + "activePluginConfigIds": [ + "{{configId}}" + ], + "title": "Last 7 Days", + "description": "Prompts this user submitted to Copilot each day over the last 7 days of reporting (Microsoft keeps daily detail for about a week)", + "timeframe": "none", + "variables": [ + "{{variables.[Copilot User]}}" + ], + "dataStream": { + "id": "{{dataStreams.[userActivityDaily]}}", + "name": "userActivityDaily", + "pluginConfigId": "{{configId}}", + "dataSourceConfig": { + "users": { + "variable": "{{variables.[Copilot User]}}", + "workspace": "{{workspaceId}}", + "scope": "{{scopes.[Copilot Users]}}" + } + } + }, + "vizSpec": { + "version": "1.0", + "visualization": { + "chartType": "bar", + "encoding": { + "x": { + "field": "date", + "type": "temporal", + "title": "Day" + }, + "y": { + "field": "promptsSubmitted", + "type": "quantitative", + "title": "Prompts", + "aggregate": "sum" + } + }, + "style": { + "cartesianBarBorderRadius": 2, + "colors": [ + "#3b82f6" + ] + } + } + } + } + } + ] + } +} diff --git a/plugins/MicrosoftCopilot/v1/docs/README.md b/plugins/MicrosoftCopilot/v1/docs/README.md new file mode 100644 index 00000000..4f88df34 --- /dev/null +++ b/plugins/MicrosoftCopilot/v1/docs/README.md @@ -0,0 +1,151 @@ +Monitor your Microsoft Copilot estate in SquaredUp: [Microsoft 365 Copilot](https://learn.microsoft.com/en-us/copilot/microsoft-365/) adoption and licence use, [Copilot Studio](https://learn.microsoft.com/en-us/microsoft-copilot-studio/) credit capacity, Copilot spend and budgets from [Azure Cost Management](https://learn.microsoft.com/en-us/azure/cost-management-billing/), the agents in the [Microsoft Agent 365](https://learn.microsoft.com/en-us/microsoft-agent-365/overview) registry, the AI apps people sign in to with their work account and what they're allowed to do, and the carbon emissions of Copilot use. Data comes from [Microsoft Graph](https://learn.microsoft.com/en-us/graph/overview), the [Power Platform API](https://learn.microsoft.com/en-us/power-platform/admin/programmability-overview) and the [Cost Management API](https://learn.microsoft.com/en-us/rest/api/cost-management/), all through one Microsoft Entra app registration. + +> ⚠️ Copilot Studio credit consumption **per agent or per environment** isn't available to an app registration, only to a signed-in administrator, so this plugin reports Copilot Studio credits for the whole tenant. Per-agent breakdowns remain in the [Power Platform admin center](https://admin.powerplatform.microsoft.com). + +## Setup + +You need a Microsoft Entra **app registration** with a client secret, Microsoft Graph application permissions, registration as a Power Platform management app, and optionally Cost Management access. The plugin only ever reads data, and every Graph permission and Azure role below is read-only, but the Power Platform registration is not: see step 4. + +### 1. Register the app + +1. In the [Microsoft Entra admin center](https://entra.microsoft.com), go to **Identity → Applications → App registrations** and click **New registration**. Give it a name such as `SquaredUp Copilot` and click **Register**. +2. From the **Overview** page, copy the **Directory (tenant) ID** and **Application (client) ID** into the matching fields. +3. Go to **Certificates & secrets → Client secrets → New client secret**. Copy the secret **Value** into the **Client secret** field. + +### 2. Grant Microsoft Graph permissions + +In the app registration, go to **API permissions → Add a permission → Microsoft Graph → Application permissions**, add the permissions below, then click **Grant admin consent** for your organization. The first three are required; add the others for the data streams that need them. + +| Permission | Required | What it's used for | +| ---------- | -------- | ------------------ | +| **Reports.Read.All** | Yes | Copilot usage reports (Copilot Adoption, Copilot Adoption Trend, Copilot User Activity, Copilot Daily User Activity), Copilot Emissions, and the application sign-in summary behind AI App Sign-ins and AI App Permissions. | +| **User.Read.All** | Yes | Importing Copilot Users (with department, job title and account state, which Copilot User Activity reads from them), and naming users who granted AI apps access. | +| **LicenseAssignment.Read.All** | Yes | Copilot Licences, and the licence check on save. | +| **AuditLog.Read.All** | No | Copilot User Sign-ins, each user's last sign-in, read live, which the Possible Leavers tile uses. | +| **Directory.Read.All** | No | Add with AuditLog.Read.All for Copilot User Sign-ins: Microsoft uses it to check the tenant's Entra ID licence, and without it sign-in queries can fail intermittently ([Microsoft guide](https://learn.microsoft.com/en-us/troubleshoot/entra/entra-id/users-groups-entra-apis/b2c-or-tenant-premium-license-sign-in-activities)). | +| **Application.Read.All** | No | AI App Permissions: each AI app's publisher and the application permissions it holds. | +| **DelegatedPermissionGrant.Read.All** | No | AI App Permissions: the delegated permissions granted to each AI app, for all users or by individual users. | +| **CopilotPackages.Read.All** | No | Agents and Agent Usage, from the Microsoft Agent 365 registry, and importing Agents. | + +Some data also depends on tenant licences rather than permissions: + +- **Last sign-in, AI App Sign-ins and AI App Permissions** need a Microsoft Entra ID P1 or P2 licence in the tenant. +- **Agents and Agent Usage** need [Microsoft Agent 365](https://learn.microsoft.com/en-us/microsoft-agent-365/overview), licensed for at least one user, which turns on the agent registry for the tenant. Without it, Agents shows no data and a warning, and nothing else is affected. + +### 3. Show user names in usage reports (optional) + +Microsoft 365 hides user names in usage reports by default. The plugin works with names hidden, but the **Copilot User Activity** data stream then shows anonymous IDs instead of names, and its rows can't be matched to imported Copilot Users, so the per-user filter and the **Copilot User** dashboard show no activity, and department and sign-in details can't be shown. + +This is a tenant-wide setting: showing names applies to **all** Microsoft 365 usage reports, not only Copilot's. Check your organization's privacy policy before you change it. To show names: + +1. In the [Microsoft 365 admin center](https://admin.microsoft.com), go to **Settings → Org settings → Services → Reports**. +2. Clear **Display concealed user, group, and site names in all reports** and click **Save**. + +### 4. Register the app with Power Platform + +Copilot Studio credit and environment data comes from Power Platform, which only accepts apps a Power Platform administrator has registered ([Microsoft guide](https://learn.microsoft.com/en-us/power-platform/admin/powerplatform-api-create-service-principal)). Signed in as a **Power Platform administrator** or **Global administrator**, run one of these once, replacing `TENANT_ID` with the **Directory (tenant) ID** and `CLIENT_ID` with the **Application (client) ID**. + +> ⚠️ A registered management app is treated by Power Platform like a user with the **Power Platform Administrator** role, and Microsoft doesn't allow its access to be narrowed. The plugin only calls read-only Power Platform APIs, but anyone holding the app's client secret has administrator-level access to Power Platform, so protect the secret accordingly. Skip this step if you don't need Copilot Studio credits or environments; the rest of the plugin works without it. + +With the [Azure CLI](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli) on any operating system: + +```bash +az login --tenant "TENANT_ID" --allow-no-subscriptions +az rest --method put --resource https://service.powerapps.com/ --url "https://api.bap.microsoft.com/providers/Microsoft.BusinessAppPlatform/adminApplications/CLIENT_ID?api-version=2020-10-01" +``` + +Or with Windows PowerShell. If you've never signed in to the [Power Platform admin center](https://admin.powerplatform.microsoft.com), sign in once first, or the cmdlets fail with an authorization error ([Microsoft guide](https://learn.microsoft.com/en-us/power-platform/admin/powershell-getting-started)): + +```powershell +Install-Module -Name Microsoft.PowerApps.Administration.PowerShell +Add-PowerAppsAccount +New-PowerAppManagementApp -ApplicationId CLIENT_ID +``` + +### 5. Give the app access to Cost Management (optional) + +To see Copilot spend and budgets, choose the scope your Copilot Studio billing policy and Azure AI resources are billed to, give the app read access there, and enter the scope in the **Cost Management scope** field. The role depends on the kind of scope ([Microsoft guide](https://learn.microsoft.com/en-us/azure/cost-management-billing/costs/assign-access-acm-data)): + +- **Subscription or resource group**: assign the **Cost Management Reader** role. Open the scope in the [Azure portal](https://portal.azure.com), go to **Access control (IAM) → Add role assignment**, and pick the app. +- **Microsoft Customer Agreement billing account**: assign the **Billing account reader** role, in **Cost Management + Billing → Billing scopes →** the billing account **→ Access control (IAM)**. +- **Microsoft Customer Agreement billing profile**: assign the **Billing profile reader** role, in the billing profile's **Access control (IAM)**. +- **Enterprise Agreement billing account**: assign the app the **EnrollmentReader** role ([Microsoft guide](https://learn.microsoft.com/en-us/azure/cost-management-billing/manage/assign-roles-azure-service-principals)). + +Copilot Studio pay-as-you-go charges land on the subscription that holds the billing policy's **Power Platform account** resource (`Microsoft.PowerPlatform/accounts`). Azure OpenAI and Azure AI Foundry charges land on the subscriptions that hold those resources. To cover several subscriptions at once, use a billing account or billing profile scope. + +The **Cost Budgets** data stream lists the [budgets](https://learn.microsoft.com/en-us/azure/cost-management-billing/costs/tutorial-acm-create-budgets) set at the same scope. To track Copilot Studio pay-as-you-go spend against a limit, create a monthly budget filtered to the Power Platform account resource rather than its resource group, so charges for other resources in the group aren't counted. If the billing policy also covers other Power Platform products, add a meter filter for the Copilot Studio meters too. + +## Configuration fields + +| Field | What it is | Where to find it | Required | +| ----- | ---------- | ---------------- | -------- | +| **Directory (tenant) ID** | The Microsoft Entra tenant the app is registered in. | App registration → **Overview**. | Yes | +| **Application (client) ID** | Identifies the app registration. | App registration → **Overview**. | Yes | +| **Client secret** | Authenticates the app. | App registration → **Certificates & secrets**. | Yes | +| **Cost Management scope** | The Azure scope to read Copilot spend and budgets from, such as `/subscriptions/` or `/providers/Microsoft.Billing/billingAccounts/`. Leave blank to skip spend and budget data. | Azure portal → the subscription or billing account → **Properties**. | No | + +On save, the plugin checks that it can read licences, Microsoft 365 Copilot usage reports and Copilot Studio credit capacity. A failed licence check means the credentials or Graph permissions are wrong and blocks setup. The other two checks only warn, and name the step to revisit. + +## What this plugin monitors + +- **Licence use**: Copilot seats purchased, assigned and available, so unused seats stand out. +- **Adoption**: enabled and active users per Microsoft 365 app (Teams, Outlook, Word, Excel, PowerPoint, Copilot Chat and more), daily trends, and prompts submitted. +- **Per-user activity**: when each licensed user last used Copilot and in which apps, with users who haven't used it for over 7 or 28 days flagged. +- **Seats to reclaim**: each licensed user's department and account state, with a seat status (Active, Low use, Idle, Never used or Possible leaver), adoption by department, and users who haven't signed in for 30 days. +- **Copilot Studio credits**: prepaid capacity, consumption and pay-as-you-go usage this month, and whether the tenant is within capacity or in overage. +- **Spend**: daily Azure costs for Copilot Studio, Copilot Chat pay-as-you-go and Azure AI services, by service, meter or resource, and spend against Cost Management budgets with a forecast for the period. +- **AI app sign-ins**: which AI apps people sign in to with their work account, such as Copilot, ChatGPT Enterprise or Claude's Microsoft 365 connectors. +- **AI app permissions**: what those AI apps have been allowed to access, granted for everyone or by individual users, such as an MCP connector consented to read mail and files. +- **Agents**: the Microsoft Agent 365 registry: agents by platform, type and publisher, new agents each week, agents that are blocked or have no active owner, and per-agent active users and sessions. +- **Daily activity**: each user's Copilot use and prompts per day over the last week. +- **Emissions**: monthly carbon emissions from Copilot use, by datacenter region and emissions scope. + +The out-of-the-box dashboards include an estate-wide **Overview** and an **Agents** dashboard, plus a perspective for each **Copilot User**, **Environment** and **Agent**. + +## Data streams + +- **Copilot Licences**: purchased, assigned and available seats for each licence that includes Microsoft 365 Copilot (account-wide). +- **Copilot Adoption**: enabled users, active users and active rate per app over a 7, 28, 90 or 180-day period, with prompt totals (account-wide). +- **Copilot Adoption Trend**: daily enabled and active users per app over the chosen period (account-wide). +- **Copilot User Activity**: last activity per app, days since last use, prompts and active days for each licensed user, with department, job title, account state and seat status (account-wide, or filtered to selected users). +- **Copilot User Sign-ins**: each Copilot-licensed user's account state and last successful Microsoft Entra sign-in, read live (account-wide). Failed sign-in attempts don't count, so a leaver's account can't look active because someone tried to sign in to it. +- **Copilot Daily User Activity**: whether each licensed user was active, their prompts and the apps they used, per day over the last 7 days of reporting (account-wide, or filtered to selected users). +- **Copilot Credit Capacity**: prepaid and pay-as-you-go Copilot Credit usage this month, with capacity status (account-wide). +- **Environment Credit Allocations**: capacity allocated to each environment, by currency (per environment). +- **Copilot Spend**: daily cost and usage quantity from Azure Cost Management, grouped by service, meter category, meter, resource group, resource or resource type, for Copilot and AI services or all services (account-wide). +- **Cost Budgets**: each Cost Management budget at the configured scope, with its amount, spend so far this period, forecast at period end and filters (account-wide). +- **AI App Sign-ins**: successful and failed Microsoft Entra sign-ins per application over 7 or 30 days, with each AI app's vendor, for AI apps only or all apps (account-wide). +- **AI App Permissions**: one row per permission grant held by an AI app used in the last 30 days: delegated grants for all users or one user (named), and application permissions, with the API they're granted on and whether they go beyond basic sign-in (account-wide). +- **Agents**: each agent in the Microsoft Agent 365 registry with its type, platform, publisher, availability, whether it's blocked, created and updated dates, and its owners (Microsoft Entra object IDs, linked to Copilot Users where the owner has a Copilot licence), with agents that have no owner flagged (account-wide, or filtered to selected agents). +- **Agent Usage**: active users, sessions, run time and exceptions over the last 30 days, last use, and sharing for an agent (per agent). +- **Copilot Emissions**: monthly scope 1, scope 2 and scope 3 emissions from Microsoft 365 Copilot use, by datacenter region (account-wide). + +## What gets indexed + +| Object type | API source | Represents | +| ----------- | ---------- | ---------- | +| **Copilot User** | Microsoft Graph `GET /v1.0/users`, filtered to users with an enabled Microsoft 365 Copilot service plan | A user licensed for Microsoft 365 Copilot, identified by user principal name, with their Microsoft Entra object ID, mail, department, job title and account state. | +| **Environment** | Power Platform admin API `GET /providers/Microsoft.BusinessAppPlatform/scopes/admin/environments` | A Power Platform environment, where Copilot Studio agents are built and credits are allocated. | +| **Agent** | Microsoft Graph `GET /v1.0/copilot/admin/catalog/packages` (needs Microsoft Agent 365) | An agent in the Agent 365 registry, such as a Copilot Studio or Agent Builder agent, or one from Microsoft or a publisher. | + +Each **Agent** is related to the **Copilot Users** who own it (*is owned by*), matched on Microsoft Entra object ID. Owners without a Copilot licence aren't imported, so they have no relationship. + +## Known limitations + +- **Usage reports lag by about two days**, and use Microsoft's fixed 7, 28, 90 and 180-day periods, chosen with each data stream's **Period** setting rather than the dashboard timeframe. +- **Users who recently lost their licence still appear** in Copilot User Activity: Microsoft's report covers anyone licensed in the last 180 days. They're no longer imported as Copilot Users, so their department, job title and account state show **Object not found**; the out-of-the-box tiles leave these blank. +- **Last sign-in needs AuditLog.Read.All and Microsoft Entra ID P1 or P2**: without them, Copilot User Sign-ins and the Possible Leavers tile show an error, and nothing else is affected. +- **Department, job title and account state are as recent as the last import**: Copilot User Activity reads them from the imported Copilot Users, so its seat status flags a disabled account once the next import has run. +- **Copilot Chat use by unlicensed users isn't reported**: Microsoft Graph only covers users with a Microsoft 365 Copilot licence. +- **Copilot Studio credits are tenant-wide and month to date**: consumption by agent, environment or user, per-agent limits, and session analytics (resolution, escalation, satisfaction) are only in the Power Platform admin center and Copilot Studio. +- **Some environments have no credit allocations**: developer and legacy environments can't hold allocations, so they don't appear in Environment Credit Allocations. +- **Cost Management throttles requests across the whole tenant**, and its data refreshes about every four hours. Several spend tiles refreshing at once may briefly show "Too many requests". +- **Cost Management doesn't support every scope**: management groups return no data for Microsoft Customer Agreement subscriptions, and Azure Sponsorship subscriptions report no costs. Use a subscription, billing account or billing profile scope. +- **Large spend queries can exceed the response size limit**: grouping all services by resource over a whole quarter may fail. Narrow the timeframe or keep the default Copilot and AI services filter. +- **AI App Sign-ins only sees apps that sign in with Microsoft Entra**: AI tools used with personal accounts never appear. AI apps are recognised by name, so one with an unrelated name is missed; set **Apps** to **All apps** to check the full list. +- **Daily user activity only goes back about a week**: Microsoft keeps per-user daily detail for roughly 7 days, so the stream always covers the last 7 days of reporting rather than the dashboard timeframe. +- **AI App Permissions only covers AI apps used in the last 30 days**: it starts from the apps people signed in to, so an AI app that's been granted access but not used recently isn't listed. "Access beyond sign-in" means any permission other than basic sign-in (`openid`, `profile`, `email`, `offline_access`, `User.Read`), on Microsoft Graph or whichever API the grant is on. +- **Agents are untested against a live Agent 365 registry**: the data streams follow Microsoft's documented API, but haven't yet been run in a tenant with Agent 365. Microsoft doesn't say whether the registry lists every agent or only those owned by licensed users. The registry lists agents only, not plugins, MCP servers or Power Platform connectors, and doesn't report credit consumption. +- **Budget forecasts are estimates**: Azure returns a forecast for some budgets only. Otherwise the forecast is a straight line from the spend so far in the current period, and budgets that reset on a billing period have no forecast. +- **Copilot Emissions uses an undocumented Microsoft Graph beta report**: it may change without notice. Microsoft's Emissions Impact Dashboard reports the same scopes in metric tons of CO2e. +- **Read-only**: the plugin never changes anything in Microsoft 365, Power Platform or Azure. diff --git a/plugins/MicrosoftCopilot/v1/icon.svg b/plugins/MicrosoftCopilot/v1/icon.svg new file mode 100644 index 00000000..1bdd89ff --- /dev/null +++ b/plugins/MicrosoftCopilot/v1/icon.svg @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/MicrosoftCopilot/v1/indexDefinitions/default.json b/plugins/MicrosoftCopilot/v1/indexDefinitions/default.json new file mode 100644 index 00000000..a5e4d9c1 --- /dev/null +++ b/plugins/MicrosoftCopilot/v1/indexDefinitions/default.json @@ -0,0 +1,68 @@ +{ + "steps": [ + { + "name": "users", + "dataStream": { "name": "users" }, + "timeframe": "none", + "objectMapping": { + "id": "userPrincipalName", + "name": "displayName", + "type": { "value": "User" }, + "properties": [ + "userPrincipalName", + { "entraObjectId": "id" }, + "mail", + "department", + "jobTitle", + "officeLocation", + "country", + "accountEnabled" + ] + } + }, + { + "name": "environments", + "dataStream": { "name": "environments" }, + "optional": true, + "timeframe": "none", + "objectMapping": { + "id": "name", + "name": "properties.displayName", + "type": { "value": "Environment" }, + "properties": [ + { "environmentType": "properties.environmentSku" }, + { "geography": "location" }, + { "azureRegion": "properties.azureRegion" }, + { "isDefault": "properties.isDefault" }, + { "status": "properties.states.management.id" }, + { "dataverseUrl": "properties.linkedEnvironmentMetadata.instanceUrl" }, + { "createdTime": "properties.createdTime" } + ] + } + }, + { + "name": "agents", + "dataStream": { "name": "agents" }, + "optional": true, + "timeframe": "none", + "objectMapping": { + "id": "id", + "name": "displayName", + "type": { "value": "Agent" }, + "properties": [ + "agentType", + "platform", + "publisher", + "availableTo", + "deployedTo", + "isBlocked", + "ownershipStatus", + "ownerIds", + "ownerCount", + "createdDateTime", + "appId" + ] + } + } + ] +} diff --git a/plugins/MicrosoftCopilot/v1/metadata.json b/plugins/MicrosoftCopilot/v1/metadata.json new file mode 100644 index 00000000..a2e5cf9a --- /dev/null +++ b/plugins/MicrosoftCopilot/v1/metadata.json @@ -0,0 +1,60 @@ +{ + "name": "microsoft-copilot", + "displayName": "Microsoft Copilot", + "version": "1.0.0", + "author": { + "name": "SquaredUp Labs", + "type": "labs" + }, + "description": "Track Microsoft 365 Copilot adoption, licence use and seats to reclaim, Copilot Studio credit capacity, and Copilot spend against budget.", + "category": "Monitoring", + "type": "hybrid", + "schemaVersion": "2.1", + "importNotSupported": false, + "restrictedToPlatforms": [], + "keywords": [ + "copilot", + "copilot studio", + "microsoft 365", + "microsoft", + "ai", + "agents", + "adoption", + "licences", + "credits", + "cost", + "budgets", + "emissions" + ], + "objectTypes": ["User", "Environment", "Agent"], + "links": [ + { + "category": "documentation", + "url": "https://github.com/squaredup/plugins/blob/main/plugins/MicrosoftCopilot/v1/docs/README.md", + "label": "Help adding this plugin" + }, + { + "category": "source", + "url": "https://github.com/squaredup/plugins/tree/main/plugins/MicrosoftCopilot/v1", + "label": "Repository" + } + ], + "base": { + "plugin": "WebAPI", + "majorVersion": "1", + "config": { + "baseUrl": "https://graph.microsoft.com/", + "allowedScriptHosts": ["login.microsoftonline.com"], + "authMode": "none", + "headers": [], + "queryArgs": [], + "showScripting": true, + "scriptingVariables": [ + { "key": "tenantId", "value": "{{tenantId}}" }, + { "key": "clientId", "value": "{{clientId}}" }, + { "key": "clientSecret", "value": "{{clientSecret}}" } + ], + "preRequestScript": "preRequest.js" + } + } +} diff --git a/plugins/MicrosoftCopilot/v1/preRequest.js b/plugins/MicrosoftCopilot/v1/preRequest.js new file mode 100644 index 00000000..a413ae4d --- /dev/null +++ b/plugins/MicrosoftCopilot/v1/preRequest.js @@ -0,0 +1,51 @@ +// Copilot data spans several Microsoft APIs, and Entra issues a separate client-credentials +// token for each one's audience. Each stream targets its API's own host, so the host picks +// the audience. Tokens are cached per host in state until a minute before they expire. +const audiences = { + "graph.microsoft.com": "https://graph.microsoft.com/.default", + "management.azure.com": "https://management.azure.com/.default", + "api.powerplatform.com": "https://api.powerplatform.com/.default", + "api.bap.microsoft.com": "https://service.powerapps.com/.default", +}; + +const scope = audiences[url.host]; +if (!scope) { + api.report.error(`No token audience is configured for ${url.host}`); +} + +const now = Date.now(); +const tokens = { ...(state?.tokens ?? {}) }; +const cached = tokens[url.host]; + +if (typeof cached?.token !== "string" || (cached.expiryTime ?? 0) <= now) { + const form = { + grant_type: "client_credentials", + client_id: String(secrets.clientId ?? "").trim(), + client_secret: String(secrets.clientSecret ?? "").trim(), + scope, + }; + const resp = await fetch( + `https://login.microsoftonline.com/${encodeURIComponent(String(secrets.tenantId ?? "").trim())}/oauth2/v2.0/token`, + { + method: "post", + headers: { "Content-Type": "application/x-www-form-urlencoded" }, + body: Object.entries(form) + .map(([k, v]) => `${k}=${encodeURIComponent(v)}`) + .join("&"), + }, + ); + const payload = await resp.json().catch(() => ({})); + if (!resp.ok || typeof payload.access_token !== "string") { + api.report.error( + `Failed to get a token for ${scope}: ${resp.status} ${payload.error_description ?? resp.statusText}`, + ); + } + tokens[url.host] = { + token: payload.access_token, + // Refresh a minute early so a token never expires mid-request + expiryTime: now + (payload.expires_in ?? 3600) * 1000 - 60000, + }; + state = { ...(state ?? {}), tokens }; +} + +headers["Authorization"] = `Bearer ${tokens[url.host].token}`; diff --git a/plugins/MicrosoftCopilot/v1/ui.json b/plugins/MicrosoftCopilot/v1/ui.json new file mode 100644 index 00000000..6cd08c89 --- /dev/null +++ b/plugins/MicrosoftCopilot/v1/ui.json @@ -0,0 +1,36 @@ +[ + { + "type": "text", + "name": "tenantId", + "label": "Directory (tenant) ID", + "placeholder": "00000000-0000-0000-0000-000000000000", + "validation": { + "required": true + } + }, + { + "type": "text", + "name": "clientId", + "label": "Application (client) ID", + "placeholder": "00000000-0000-0000-0000-000000000000", + "validation": { + "required": true + } + }, + { + "type": "password", + "name": "clientSecret", + "label": "Client secret", + "placeholder": "Enter a client secret", + "validation": { + "required": true + } + }, + { + "type": "text", + "name": "costScope", + "label": "Cost Management scope", + "placeholder": "/subscriptions/00000000-0000-0000-0000-000000000000", + "help": "Enables the Copilot spend data stream. Accepts a subscription, resource group, management group or billing account scope. See [Cost Management scopes](https://learn.microsoft.com/en-us/azure/cost-management-billing/costs/understand-work-scopes)." + } +]