diff --git a/sdk/monitor/azure-monitor-query/CHANGELOG.md b/sdk/monitor/azure-monitor-query/CHANGELOG.md index f1043932106b..eb45cefa2f2c 100644 --- a/sdk/monitor/azure-monitor-query/CHANGELOG.md +++ b/sdk/monitor/azure-monitor-query/CHANGELOG.md @@ -8,6 +8,8 @@ ### Bugs Fixed +- Fixed a bug where Metadata values in timestamp don't show up sometimes. + ### Other Changes ## 1.0.0 (2021-10-06) diff --git a/sdk/monitor/azure-monitor-query/azure/monitor/query/_models.py b/sdk/monitor/azure-monitor-query/azure/monitor/query/_models.py index 1b7b30da04de..fc0462f9b1be 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/_models.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/_models.py @@ -509,7 +509,7 @@ class TimeSeriesElement(object): """ def __init__(self, **kwargs): # type: (Any) -> None - self.metadata_values = kwargs.get("metadatavalues", None) + self.metadata_values = kwargs.get("metadata_values", None) self.data = kwargs.get("data", None) @classmethod diff --git a/sdk/monitor/azure-monitor-query/tests/async/test_metrics_client_async.py b/sdk/monitor/azure-monitor-query/tests/async/test_metrics_client_async.py index 89757e75e37d..cd8360596064 100644 --- a/sdk/monitor/azure-monitor-query/tests/async/test_metrics_client_async.py +++ b/sdk/monitor/azure-monitor-query/tests/async/test_metrics_client_async.py @@ -42,6 +42,23 @@ async def test_metrics_granularity(): assert response assert response.granularity == timedelta(minutes=5) +@pytest.mark.live_test_only +@pytest.mark.asyncio +async def test_metrics_filter(): + credential = _credential() + client = MetricsQueryClient(credential) + response = await client.query_resource( + os.environ['METRICS_RESOURCE_URI'], + metric_names=["MatchedEventCount"], + timespan=timedelta(days=1), + granularity=timedelta(minutes=5), + filter="EventSubscriptionName eq '*'", + aggregations=[MetricAggregationType.COUNT] + ) + assert response + metric = response.metrics['MatchedEventCount'] + for t in metric.timeseries: + assert t.metadata_values is not None @pytest.mark.live_test_only @pytest.mark.asyncio diff --git a/sdk/monitor/azure-monitor-query/tests/test_metrics_client.py b/sdk/monitor/azure-monitor-query/tests/test_metrics_client.py index f9f5da4db012..54656b1cb3cf 100644 --- a/sdk/monitor/azure-monitor-query/tests/test_metrics_client.py +++ b/sdk/monitor/azure-monitor-query/tests/test_metrics_client.py @@ -39,6 +39,23 @@ def test_metrics_granularity(): assert response assert response.granularity == timedelta(minutes=5) +@pytest.mark.live_test_only +def test_metrics_filter(): + credential = _credential() + client = MetricsQueryClient(credential) + response = client.query_resource( + os.environ['METRICS_RESOURCE_URI'], + metric_names=["MatchedEventCount"], + timespan=timedelta(days=1), + granularity=timedelta(minutes=5), + filter="EventSubscriptionName eq '*'", + aggregations=[MetricAggregationType.COUNT] + ) + assert response + metric = response.metrics['MatchedEventCount'] + for t in metric.timeseries: + assert t.metadata_values is not None + @pytest.mark.live_test_only def test_metrics_list(): credential = _credential()