RobustPerception / azure_metrics_exporter

Azure metrics exporter for Prometheus
Apache License 2.0
133 stars 69 forks source link

Missing API version on virtualMachineScaleSets #103

Closed brianmowens closed 3 years ago

brianmowens commented 3 years ago

I'm currently facing an issue where the azure-exporter is unable to find the API version for Virtual Machine Scalesets. Perhaps there should be a way to manually specify the API version to use?

Error message:

azure-exporter | 2021/06/03 21:22:32 Failed to get resource info: No api version found for type: RESOURCE_GROUP/providers/virtualMachineScaleSets

My config (minus credentials section) is:


targets:
  - resource: "/resourceGroups/RESOURCE_GROUP/providers/Microsoft.Compute/virtualMachineScaleSets/RESOURCE_NAME"
    metric_namespace: "Microsoft.Compute/virtualMachineScaleSets"
    metrics:
      - name: "Percentage CPU"
      - name: "Network In Total"
      - name: "Network Out Total"

I've also tried this without specifying the metric_namespace, and the same error is returned.

.\azure_metrics_exporter.exe --list.definitions successfuly returns:

Available Metrics:
2021/06/03 17:21:02 - Percentage CPU
2021/06/03 17:21:02 - Network In
2021/06/03 17:21:02 - Network Out
2021/06/03 17:21:02 - Disk Read Bytes
2021/06/03 17:21:02 - Disk Write Bytes
2021/06/03 17:21:02 - Disk Read Operations/Sec
2021/06/03 17:21:02 - Disk Write Operations/Sec
2021/06/03 17:21:02 - CPU Credits Remaining
2021/06/03 17:21:02 - CPU Credits Consumed
2021/06/03 17:21:02 - Data Disk Read Bytes/sec
2021/06/03 17:21:02 - Data Disk Write Bytes/sec
2021/06/03 17:21:02 - Data Disk Read Operations/Sec
2021/06/03 17:21:02 - Data Disk Write Operations/Sec
2021/06/03 17:21:02 - Data Disk Queue Depth
2021/06/03 17:21:02 - Data Disk Bandwidth Consumed Percentage
2021/06/03 17:21:02 - Data Disk IOPS Consumed Percentage
2021/06/03 17:21:02 - Data Disk Target Bandwidth
2021/06/03 17:21:02 - Data Disk Target IOPS
2021/06/03 17:21:02 - Data Disk Max Burst Bandwidth
2021/06/03 17:21:02 - Data Disk Max Burst IOPS
2021/06/03 17:21:02 - Data Disk Used Burst BPS Credits Percentage
2021/06/03 17:21:02 - Data Disk Used Burst IO Credits Percentage
2021/06/03 17:21:02 - OS Disk Read Bytes/sec
2021/06/03 17:21:02 - OS Disk Write Bytes/sec
2021/06/03 17:21:02 - OS Disk Read Operations/Sec
2021/06/03 17:21:02 - OS Disk Write Operations/Sec
2021/06/03 17:21:02 - OS Disk Queue Depth
2021/06/03 17:21:02 - OS Disk Bandwidth Consumed Percentage
2021/06/03 17:21:02 - OS Disk IOPS Consumed Percentage
2021/06/03 17:21:02 - OS Disk Target Bandwidth
2021/06/03 17:21:02 - OS Disk Target IOPS
2021/06/03 17:21:02 - OS Disk Max Burst Bandwidth
2021/06/03 17:21:02 - OS Disk Max Burst IOPS
2021/06/03 17:21:02 - OS Disk Used Burst BPS Credits Percentage
2021/06/03 17:21:02 - OS Disk Used Burst IO Credits Percentage
2021/06/03 17:21:02 - Inbound Flows
2021/06/03 17:21:02 - Outbound Flows
2021/06/03 17:21:02 - Inbound Flows Maximum Creation Rate
2021/06/03 17:21:02 - Outbound Flows Maximum Creation Rate
2021/06/03 17:21:02 - Premium Data Disk Cache Read Hit
2021/06/03 17:21:02 - Premium Data Disk Cache Read Miss
2021/06/03 17:21:02 - Premium OS Disk Cache Read Hit
2021/06/03 17:21:02 - Premium OS Disk Cache Read Miss
2021/06/03 17:21:02 - VM Cached Bandwidth Consumed Percentage
2021/06/03 17:21:02 - VM Cached IOPS Consumed Percentage
2021/06/03 17:21:02 - VM Uncached Bandwidth Consumed Percentage
2021/06/03 17:21:02 - VM Uncached IOPS Consumed Percentage
2021/06/03 17:21:02 - Network In Total
2021/06/03 17:21:02 - Network Out Total

.\azure-metrics-exporter.exe --list.namespaces successfully returns:

2021/06/03 17:29:24 Resource: /resourceGroups/RESOURCE_GROUP/providers/Microsoft.Compute/virtualMachineScaleSets/RESOURCE_NAME

Available namespaces:
2021/06/03 17:29:24 - Microsoft.Compute/virtualMachineScaleSets
brian-brazil commented 3 years ago

I'm afraid I don't know enough about these APIs to know what the issue might be. Have you tried bumping the api version inside the code of the exporter?

brianmowens commented 3 years ago

After running the exporter in a debugger, I found that the API versions were being returned correctly and the latest version was accurately being picked up. This lead me to a formatting error in my resource_id. I had not properly updated my config file between tests, and while I thought I was using the correct resource_id string of "/resource/GROUP_NAME/...", I was actually using the incorrect resource_id that still lead with '/subscriptions/SUBSCRIPTION_ID/'.

After correcting the resource_id, this error was resolved.

Perhaps an improvement would be to add in an error log line in the findBy that checks if the resourceType actually exists in the APIVersion map returned by the extractAPIVersions function.

Thanks for the assistance!