arcus-azure / arcus.scripting

Scripting with Microsoft Azure in a breeze.
https://scripting.arcus-azure.net/
MIT License
9 stars 11 forks source link

Provide script to retrieve quota metrics from IoT Hub #137

Open mbraekman opened 3 years ago

mbraekman commented 3 years ago

Is your feature request related to a problem? Please describe. As part of the setup for alert-creations for IoT Hub, a script has been included which allows you to determine the current quota of messages. As this could be useful outside of that specific use-case, would form a nice addition for a new module Arcus.Scripting.IoT.Hub

Describe the solution you'd like The current version of the script can be found in the CoditEU/platform-operations-specialization-area repo at the following location: /platform-operations-specialization-area/alerting/catalog/templates/iothub/determine-messagequota-used-threshold.ps1

This is to be updated to ensure it aligns with the current naming conventions as used across all Arcus.Scripting-modules, as well as implement the suggested changes (parameterization) from the source-repo.

For more context, see the mentioned repo. Credits: @fgheysels

stijnmoreels commented 1 year ago

Q: in what way is this different from: Get-AzIoTHubQuotaMetric?

fgheysels commented 1 year ago

The script in the Codit repo retrieves one specific quota metric of an IoT Hub (Total Messages), and applies a (specified) percentage to it. The result of that script can then be used when creating an alert on IoT Hub that is triggered when the daily amount of messages that you have received, is reaching the quota / limit of that iothub.

(The alert that I'm talking about, is also available in the repo that @mbraekman mentionned: https://github.com/Codit/platform-operations-practice/tree/main/alerting/catalog/templates/iothub)

stijnmoreels commented 1 year ago

Ok, but we can still use the Get-AzIoTHubQuotaMetric here, and use the percentage parameter from the Codit repo.

stijnmoreels commented 1 year ago

So, this would be enough, right?

$quotaMetric = Get-AzIotHubQuotaMetric -Name $IoTHubName -ResourceGroupName $ResourceGroupName
$result = [Math]::Round($quotaMetric.MaxValue * $QuotaPercentage)