Skip to content

[ARM] Metric not found after using list metric definition #41874

@jsarrelli

Description

@jsarrelli

We are consuming metrics for different resources.
The way we do it is by first listing the metrics


  def listMetricsV2(resourceId: String): Future[ResourceMetrics] =
    Source
      .fromPublisher[MetricDefinition](
        underlying
          .listByResourceAsync(resourceId)
          .timeout(Duration.ofSeconds(5))
          .retryWhen(AzureClient.retrySpec)
      )
      .runFold(List.empty[MetricDefinition])(_ :+ _)
      .map(metricDefinitions =>
        ResourceMetrics(
          resourceId,
          metricDefinitions.map { metric =>
            metric.name.value -> metric
          }.toMap,
        )
      )

and then with those metrics, we query specific ones.

....
    val datapointsF: Future[Map[Instant, Double]] = metrics
      .get(metricName)
      .map { metric =>
        val query = metric
          .defineQuery()
          .startingFrom(OffsetDateTime.ofInstant(start, ZoneId.systemDefault()))
          .endsBefore(OffsetDateTime.ofInstant(end, ZoneId.systemDefault()))
          .withAggregation(aggregation.entryName)
          .withInterval(Duration.ofSeconds(period))
      }.getOrElse {
        log.debug("Requested metric was not under Azure available ones")
        }

...

So with the metric present in the listMetric response, we are getting the following errors.

com.azure.core.management.exception.ManagementException: Status code 400, "{"code":"BadRequest","message":"Failed to find metric configuration for provider: Microsoft.Web, resource Type: serverfarms, metric: DiskQueueLength, Valid metrics: "}"

SDK Version:
"com.azure.resourcemanager" % "azure-resourcemanager" % "2.42.0"

Metadata

Metadata

Assignees

Labels

Cost Management - RIandShowBackAll issues in cost management associated with Reservation and ShowBack.MgmtThis issue is related to a management-plane library.customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions