Skip to content

[BUG] Using filters with aggregation in MetricsQueryClient returns null on some aggregations #37333

Open
@shevah

Description

@shevah

Describe the bug
On the EventHub resource (and might be on others as well) when we query using metricsQueryClient.queryResourceWithResponse and using filters with aggregations the result on some aggregations (all but the first one) is null. If you remove the filter then we get valid results.

Exception or Stack Trace
No exception.

To Reproduce
Create an EventHub with a test entity. populate it with some records.
then execute the following code.

Code Snippet

val tenantId = "XXXX"
val clientId = "XXXX"
val clientSecret = "XXXXX"

val clientSecretCredential: ClientSecretCredential = ClientSecretCredentialBuilder()
    .clientId(clientId)
    .clientSecret(clientSecret)
    .tenantId(tenantId)
    .build()

val metricsQueryClient = MetricsQueryClientBuilder()
    .credential(clientSecretCredential)
    .buildClient()

val id = "/subscriptions/XXXXX/resourceGroups/XXXX/providers/Microsoft.EventHub/namespaces/eventhubplayground"
val metricName = "Size"

val res11 = metricsQueryClient.queryResourceWithResponse(
    id,
    listOf(metricName),
    MetricsQueryOptions()
        .setAggregations(AggregationType.COUNT, AggregationType.AVERAGE, AggregationType.MAXIMUM,
            AggregationType.MINIMUM, AggregationType.TOTAL)
        .setFilter("EntityName eq '*'"),
    Context.NONE
)
    .value
    .metrics

val res12 = metricsQueryClient.queryResourceWithResponse(
    id,
    listOf(metricName),
    MetricsQueryOptions()
        .setAggregations(AggregationType.MAXIMUM, AggregationType.AVERAGE, AggregationType.COUNT,
            AggregationType.MINIMUM, AggregationType.TOTAL),
    Context.NONE
)
    .value
    .metrics

Expected behavior
res11 timeseries contain nulls:
image
while res12 timeseries contain the correct values:
image
and if you take recent value you will also other timestamp you see the values.

Screenshots
attached.

Setup (please complete the following information):

  • OS: macOS 14.0
  • IDE: 2023.2.3
  • Library/Libraries:
implementation("com.azure.resourcemanager:azure-resourcemanager:2.31.0")
implementation("com.azure:azure-identity:1.10.3")
implementation("com.azure:azure-monitor-query:1.3.0-beta.2")
  • Java version: 11

Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

  • Bug Description Added
  • Repro Steps Added
  • Setup information Added

Metadata

Metadata

Assignees

Labels

ClientThis issue points to a problem in the data-plane of the library.MonitorMonitor, Monitor Ingestion, Monitor Querycustomer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-triageWorkflow: This issue needs the team to triage.questionThe 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