Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jsarrelli opened this issue Sep 16, 2024 · 3 comments
Open

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

jsarrelli opened this issue Sep 16, 2024 · 3 comments
Assignees
Labels
customer-reported Issues that are reported by GitHub users external to the Azure organization. Mgmt This issue is related to a management-plane library. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that

Comments

@jsarrelli
Copy link

jsarrelli commented Sep 16, 2024

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"

@github-actions github-actions bot added customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Sep 16, 2024
@joshfree joshfree added the Mgmt This issue is related to a management-plane library. label Sep 18, 2024
@joshfree joshfree changed the title Metric not found after using list metric definition [ARM] Metric not found after using list metric definition Sep 18, 2024
@github-actions github-actions bot removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Sep 18, 2024
@joshfree
Copy link
Member

@weidongxu-microsoft could you please take a look?

@weidongxu-microsoft
Copy link
Member

@v-hongli1 Please see if you can reproduce. The resource for the monitor metrics should be AppServicePlan.

@jsarrelli
Copy link
Author

jsarrelli commented Sep 24, 2024

I think it happens for different services

com.azure.core.management.exception.ManagementException: Status code 400, "{"code":"BadRequest","message":"Failed to find metric configuration for provider: Microsoft.Sql, resource Type: servers/databases, metric: dtu_consumption_percent, Valid metrics: cpu_percent,physical_data_read_percent,connection_successful,connection_failed,connection_failed_user_error,blocked_by_firewall,availability,ledger_digest_upload_success,ledger_digest_upload_failed"}"

Here is the example on how dtu_consumption_percent exists on the listMetrics response but failed when try to query the values

Screenshot 2024-09-23 at 9 17 32 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer-reported Issues that are reported by GitHub users external to the Azure organization. Mgmt This issue is related to a management-plane library. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Projects
None yet
Development

No branches or pull requests

4 participants