monitoring azure-iot deployments via azure-cli - azure

Background
I'm using Azure-cli (version >2.3.1) to create IoT Edge deployments:
echo az iot edge deployment create --content $(iotDeploymentPath) --deployment-id $(deploymentId) --hub-name ${hub} --priority $(priority) --target-condition "tags.location.place='$(env)'"
and for getting the metrics:
targetedCount="$(az iot edge deployment show-metric --deployment-id $(deploymentId) --metric-id targetedCount --hub-name ${hub})"
appliedCount="$(az iot edge deployment show-metric --deployment-id $(deploymentId) --metric-id appliedCount --hub-name ${hub})"
reportedSuccessfulCount="$(az iot edge deployment show-metric --deployment-id $(deploymentId) --metric-id reportedSuccessfulCount --hub-name ${hub})"
A few days ago, we got the following error message while trying to receive the deployment's metrics:
the metric 'targetedCount' is not defined in the device configuration
$(deploymentId)
the metric 'appliedCount' is not defined in the device configuration
$(deploymentId)
the metric 'reportedSuccessfulCount' is not defined in the device
configuration $(deploymentId)
with the following depracation message:
This extension 'azure-cli-iot-ext' is deprecated and scheduled for
removal. Please remove and add 'azure-iot' instead.
So I've installed 'azure-iot' instead of 'azure-cli-iot-ext', but now it seems like
az iot edge deployment show-metric stopped working and keeps sending the error message mentioned above.
the metric 'targetedCount' is not defined in the device configuration
$(deploymentId)
the metric 'appliedCount' is not defined in the device configuration
$(deploymentId)
the metric 'reportedSuccessfulCount' is not defined in the device
configuration $(deploymentId)
Question:
How can I get those metrics back without having the CLI deprecated extanstion version?

Quoting Azure support team answer:
I just received an update from our Product Group. They have informed
me that before azure-cli-iot-ext 0.8.7, iot edge deployment
show-metric would only work against system metrics. After, an argument
was introduced for the user to be able to switch between system and
user metrics but to match iot hub configuration show-metric, the user
metrics became the default (which carried over to azure-iot).
In addition, the PG member pointed out that all the metrics causing
issues with appear to be system metrics. In that case, please try
adding the --metric-type or –mt argument with value ‘system’.
For example:
az iot edge deployment show-metric -n myiothub -d mydeployment -m targetedCount --mt system

Related

Create a device in Azure IoT Hub by Terraform

I am trying to automate setting up of IoT Hub. But I am not able to find any code related to creating a device in the IoT Hub. I found the below command:
resource “azurerm_iothub_device” “example” {
name = “device_name” iothub_name = azurerm_iothub.iothub12.name
}
But it does not seem to be valid.
I have installed the extensions azure IoT Hub and IoT Device Workbench.
How can I do it?
A workaround I use is to use a local provisioner. I use it in my iothub resource for creation. The downside is that it only works on resource creation (or deletion) - so if devices need to be updated at a later stage without recreating the IoT hub you would need to create a new resource with said provisioner.
My provisioner:
provisioner "local-exec" {
command = "${path.module}/create-iot-device.sh ${azurerm_iothub.<your-resource-name>.name}"
}
And the create-iot-device.sh
#!/bin/bash
az iot hub device-identity create --device-id dev-1 --hub-name $1
According to EliiseS, as of now, support for IoT Hub device creation using Terraform is not available.

How can i determine if AKS uses the new Azure Monitor Agent?

I have onboarded my AKS cluster to Azure Monitor. I.e. assigning a Log Analytics Workspace.
This onboarding process has created pods into my cluster having the name omsagent-xxxx. The pod uses image: mcr.microsoft.com/azuremonitor/containerinsights/ciprod:ciprod08052021
From the Log Analytics Workspace i can query for logs and metrics produced from within my cluster. I assume the logs and metrics gets sent there by the newly created omsagent pods.
According to https://azure.microsoft.com/en-us/updates/were-retiring-the-log-analytics-agent-in-azure-monitor-on-31-august-2024/, the "Log Analytics Agent" is going to be replaced by the new "Azure Monitor Agent".
According to https://learn.microsoft.com/en-us/azure/azure-monitor/containers/container-insights-manage-agent#how-to-upgrade-the-container-insights-agent, the agents are to be upgraded automatically:
"When a new version of the agent is released, the agent is automatically upgraded on your managed Kubernetes clusters hosted on Azure Kubernetes Service (AKS) ..."
How can i determine whether my cluster is using Log Analytics Agent, or the new Azure Monitor Agent?
At this point, We have not found single command line, but we may use Queries to trace the same in later point.
As a workaround you can use i.e., based on limitation, and access you will predict which monitoring tool you are using.
Example: Limitation for Azure Monitoring agent tool.
No support yet for networking scenarios involving private links.
No support yet collecting custom logs (files) or IIS log files.
No support yet for Event Hubs and Storage accounts as destinations
In the documentation there is also shown list of OS’s supported in Azure monitoring. You can try using that and predict that one.
Reference: https://learn.microsoft.com/en-us/azure/azure-monitor/agents/agents-overview
Check the latest available versión of omsagent ciprod10132021 in the AKS Release notes.
Using the next commands get the current running oms versión:
→ kubectl get deployments -n kube-system -o wide
→ kubectl get ds omsagent --namespace=kube-system -o wide
→ kubectl get pods -n kube-system --selector=component=oms-agent -o jsonpath="{.items[*].spec.containers[*].image}" |tr -s '[[:space:]]' '\n' |sort |uniq –c
→ kubectl get pods -n kube-system --selector=component=oms-agent-win -o jsonpath="{.items[*].spec.containers[*].image}" |tr -s '[[:space:]]' '\n' |sort |uniq -c

Azure IoT Hub module specified in deployment but not deploying

I have a IoT Edge Module that I want to deploy on my IoT Edge device.
In VSCode, I right-clicked on the deployment.template.jsonand then selected Build and Push IoT Edge Solution. The module has been built and pushed to my container registry. Then I right-clicked on the generated deployment.json and selected Create Deployment for Single Device and selected my IoT Edge device.
From VSCode, I have the following output:
[Edge] Start deployment to device [RaspberryPi]
[Edge] Deployment succeeded.
On the Azure Portal, I can see the module in the list of the device's modules. Its status is :
| SPECIFIED IN DEPLOYMENT | REPORTED BY DEVICE | RUNTIME STATUS |
|-------------------------|--------------------|----------------|
| Yes | No | -- |
But when I look at directly on my device, the deployment didn't start.
I checked the log with journalctl -u iotedge and I found nothing related to the deployment. Normally I should have something like starting pulling module xxx, Successfully pulled module xxx, Starting module xxx, Successfully started module xxx.
Does someone have an idea of how to solve this issue ? Thanks.

Event hub does not load in Azure portal when resource group has accent in its name

When I follow these steps:
create event hub in a namespace with a resource group named tést (or other name with é in it)
Try to open up the event hub in the portal
Then the portal never finishes loading the event hub and I get this:
rainy cloud
I can reproduce this bug on different Azure subscriptions...
#SQLWaldorf,
I checked on this issue, when using the accent in Portal, it doesn't allow me to create the namespace since the character doesn't seem to be supported, I attached both screenshots from my experiment:
Then without accent:

Azure Service Fabric ARM template Provisioning Failed

I have a script that facilitates an ARM template to provision an Azure Service Fabric cluster (official windows servers) among other dependencies like storage and such. I do not provision through the portal.
Facts:
Two days ago, I used this script to provision the cluster with complete success.
I tried the same again yesterday, and the provisioning failed (with the error below).
just to reassure you that the provisioning script works, I can successfully provision with this script on other subscription and it constantly and reliably succeeds.
The error:
Resource Microsoft.Insights/autoscaleSettings '1NodeVMSetAutoScale' failed with message 'The metric with namespace '' and name '\Processor(_Total)\% Processor Time' is not supported for this resource id '/subscriptions/----/resourceGroups/-cluster/providers/Microsoft.Compute/virtualMachineScaleSets/1'.' 8:10:01 PM - Resource Microsoft.Insights/autoscaleSettings '2NodeVMSetAutoScale' failed with message 'The metric with namespace '' and name '\Processor(_Total)\% Processor Time' is not supported for this resource id '/subscriptions/----/resourceGroups/cluster/providers/Microsoft.Compute/virtualMachineScaleSets/2'.' 8:10:01 PM - "Template output evaluation skipped: at least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for usage details." 'string' does not contain a definition for 'error'
My question is why? What could be the reason for it not to consistently succeed? Can you please help with troubleshooting steps?
Related info: https://azure.microsoft.com/en-us/documentation/articles/insights-autoscale-common-metrics/
2 questions:
1) what region are you deploying in?
2) In the new subscription, can you check what resource providers you have registered, and in what regions? In the CLI, the commands look like:
azure config mode arm
azure provider list
azure provider show Microsoft.Insights
I faced the same issue since a week in my subscriptions. The way out was to make changes to the Diagnostic configurations, by adding the counter "\Processor(_Total)\% Processor Time" under the waddiagnostic performace counters section. You can also take sneak peak here were autoscale is discussed: Service Fabric Autoscale
Please share your template/ part of it to analyse further.

Resources