From 308e2a0f8556d6f56a88b26dd9b0270db6d2ef4e Mon Sep 17 00:00:00 2001 From: Marcos Oikawa Date: Fri, 4 Oct 2024 13:11:26 -0300 Subject: [PATCH 1/3] dev box - billing consumed compute queries --- Azure Services/Dev Box/Alerts/README | 1 + Azure Services/Dev Box/Queries/README | 1 + .../Dev Box/Queries/consumed compute per user.kql | 11 +++++++++++ Azure Services/Dev Box/Workbooks/README | 1 + 4 files changed, 14 insertions(+) create mode 100644 Azure Services/Dev Box/Alerts/README create mode 100644 Azure Services/Dev Box/Queries/README create mode 100644 Azure Services/Dev Box/Queries/consumed compute per user.kql create mode 100644 Azure Services/Dev Box/Workbooks/README diff --git a/Azure Services/Dev Box/Alerts/README b/Azure Services/Dev Box/Alerts/README new file mode 100644 index 00000000..e7cf202f --- /dev/null +++ b/Azure Services/Dev Box/Alerts/README @@ -0,0 +1 @@ +Put alerts in this folder \ No newline at end of file diff --git a/Azure Services/Dev Box/Queries/README b/Azure Services/Dev Box/Queries/README new file mode 100644 index 00000000..f121024f --- /dev/null +++ b/Azure Services/Dev Box/Queries/README @@ -0,0 +1 @@ +Put queries in this folder \ No newline at end of file diff --git a/Azure Services/Dev Box/Queries/consumed compute per user.kql b/Azure Services/Dev Box/Queries/consumed compute per user.kql new file mode 100644 index 00000000..4cf8f45a --- /dev/null +++ b/Azure Services/Dev Box/Queries/consumed compute per user.kql @@ -0,0 +1,11 @@ +// Author: Microsoft Azure +// Display name: Consumed compute per user +// Description: Display consumed compute per user in hours +// Categories: Azure Resources +// Resource types: Dev Box +// Topic: Dev Box Billing + +DevCenterBillingEventLogs +| where UsageType == "Compute" +| summarize Horas=sum(Quantity) by UserId +| render columnchart \ No newline at end of file diff --git a/Azure Services/Dev Box/Workbooks/README b/Azure Services/Dev Box/Workbooks/README new file mode 100644 index 00000000..7b19c105 --- /dev/null +++ b/Azure Services/Dev Box/Workbooks/README @@ -0,0 +1 @@ +Put workbooks in this folder \ No newline at end of file From 6997c84a840e46679866133da23bc0f6601dae8c Mon Sep 17 00:00:00 2001 From: Marcos Oikawa Date: Fri, 4 Oct 2024 18:19:15 -0300 Subject: [PATCH 2/3] dev box - billing consumed using Display Name (needs Entra ID SigninLogs exported to Log Analytics --- .../consumed compute per user Display Name.kql | 14 ++++++++++++++ .../consumed compute per user in timeline.kql | 14 ++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 Azure Services/Dev Box/Queries/consumed compute per user Display Name.kql create mode 100644 Azure Services/Dev Box/Queries/consumed compute per user in timeline.kql diff --git a/Azure Services/Dev Box/Queries/consumed compute per user Display Name.kql b/Azure Services/Dev Box/Queries/consumed compute per user Display Name.kql new file mode 100644 index 00000000..7e2d4a28 --- /dev/null +++ b/Azure Services/Dev Box/Queries/consumed compute per user Display Name.kql @@ -0,0 +1,14 @@ +// Author: Microsoft Azure +// Display name: Consumed compute per user Display Name +// Description: Display consumed compute per user in hours +// Categories: Azure Resources +// Resource types: Dev Box +// Topic: Dev Box Billing + +//required: Need to export SigninLogs of Entra ID to Log Analytics to have the Display Name (Name and Surname) +DevCenterBillingEventLogs +| where UsageType == "Compute" +| summarize QTD = sum(Quantity) by UserId +| join kind=leftouter (SigninLogs | where ConditionalAccessStatus =="success" | distinct UserId, Identity) on UserId +| project Identity, QTD +| render columnchart \ No newline at end of file diff --git a/Azure Services/Dev Box/Queries/consumed compute per user in timeline.kql b/Azure Services/Dev Box/Queries/consumed compute per user in timeline.kql new file mode 100644 index 00000000..ce68878c --- /dev/null +++ b/Azure Services/Dev Box/Queries/consumed compute per user in timeline.kql @@ -0,0 +1,14 @@ +// Author: Microsoft Azure +// Display name: Consumed compute per user Display Name +// Description: Display consumed compute per user in hours +// Categories: Azure Resources +// Resource types: Dev Box +// Topic: Dev Box Billing + +//required: Need to export SigninLogs of Entra ID to Log Analytics to have the Display Name (Name and Surname) +DevCenterBillingEventLogs +| where UsageType == "Compute" +| summarize QTD = sum(Quantity) by UserId, bin(TimeGenerated, 1h) +| join kind=leftouter (SigninLogs | where ConditionalAccessStatus =="success" | distinct UserId, Identity) on UserId +| project Identity, QTD, TimeGenerated +| render columnchart with (xcolumn=TimeGenerated, ycolumns=Identity, series=QTD) \ No newline at end of file From 3467d67680128615e259ee6d05dbdda1b6420b5c Mon Sep 17 00:00:00 2001 From: Marcos Oikawa Date: Fri, 4 Oct 2024 18:23:40 -0300 Subject: [PATCH 3/3] adjusting labels --- .../Queries/consumed compute per user Display Name.kql | 4 ++-- .../Queries/consumed compute per user in timeline.kql | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Azure Services/Dev Box/Queries/consumed compute per user Display Name.kql b/Azure Services/Dev Box/Queries/consumed compute per user Display Name.kql index 7e2d4a28..cb0f3618 100644 --- a/Azure Services/Dev Box/Queries/consumed compute per user Display Name.kql +++ b/Azure Services/Dev Box/Queries/consumed compute per user Display Name.kql @@ -8,7 +8,7 @@ //required: Need to export SigninLogs of Entra ID to Log Analytics to have the Display Name (Name and Surname) DevCenterBillingEventLogs | where UsageType == "Compute" -| summarize QTD = sum(Quantity) by UserId +| summarize HoursConsumed = sum(Quantity) by UserId | join kind=leftouter (SigninLogs | where ConditionalAccessStatus =="success" | distinct UserId, Identity) on UserId -| project Identity, QTD +| project Identity, HoursConsumed | render columnchart \ No newline at end of file diff --git a/Azure Services/Dev Box/Queries/consumed compute per user in timeline.kql b/Azure Services/Dev Box/Queries/consumed compute per user in timeline.kql index ce68878c..464ee644 100644 --- a/Azure Services/Dev Box/Queries/consumed compute per user in timeline.kql +++ b/Azure Services/Dev Box/Queries/consumed compute per user in timeline.kql @@ -8,7 +8,7 @@ //required: Need to export SigninLogs of Entra ID to Log Analytics to have the Display Name (Name and Surname) DevCenterBillingEventLogs | where UsageType == "Compute" -| summarize QTD = sum(Quantity) by UserId, bin(TimeGenerated, 1h) +| summarize HoursConsumed = sum(Quantity) by UserId, bin(TimeGenerated, 1h) | join kind=leftouter (SigninLogs | where ConditionalAccessStatus =="success" | distinct UserId, Identity) on UserId -| project Identity, QTD, TimeGenerated -| render columnchart with (xcolumn=TimeGenerated, ycolumns=Identity, series=QTD) \ No newline at end of file +| project Identity, HoursConsumed, TimeGenerated +| render columnchart with (xcolumn=TimeGenerated, ycolumns=Identity, series=HoursConsumed) \ No newline at end of file