Skip to content

Commit

Permalink
Monitor metadata bg (#21513)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rakshith Bhyravabhotla authored Nov 3, 2021
1 parent 05c8dc8 commit 49f51c0
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
2 changes: 2 additions & 0 deletions sdk/monitor/azure-monitor-query/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions sdk/monitor/azure-monitor-query/tests/test_metrics_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 49f51c0

Please sign in to comment.