Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
f2c56e5
wip
nisha-bhatia Sep 1, 2023
75afbb1
wip
nisha-bhatia Sep 7, 2023
8dc5099
wip
nisha-bhatia Sep 12, 2023
790ef12
wip
nisha-bhatia Sep 19, 2023
bec4141
merge
nisha-bhatia Sep 19, 2023
145a072
Merge remote-tracking branch 'upstream/main' into nibhati-updateQuery
nisha-bhatia Sep 19, 2023
e22a188
wip
nisha-bhatia Sep 20, 2023
a4d9e01
Merge remote-tracking branch 'upstream/main' into nibhati-updateQuery
nisha-bhatia Sep 25, 2023
acd1596
fix ci
nisha-bhatia Sep 25, 2023
85d3917
wip
nisha-bhatia Sep 29, 2023
7b94d42
wip
nisha-bhatia Oct 4, 2023
ea13e03
wip
nisha-bhatia Oct 4, 2023
e785dae
Merge remote-tracking branch 'upstream/main' into nibhati-updateQuery
nisha-bhatia Oct 10, 2023
1d95e85
revert audience
nisha-bhatia Oct 10, 2023
9bbaf5f
Update CHANGELOG.md
nisha-bhatia Oct 10, 2023
8cbae99
Merge remote-tracking branch 'upstream/main' into nibhati-updateQuery
nisha-bhatia Oct 12, 2023
db25117
wip
nisha-bhatia Oct 12, 2023
d538ee7
Update MonitorIngestionLiveTest.cs
nisha-bhatia Oct 12, 2023
b150a9e
Update MonitorIngestionLiveTest.cs
nisha-bhatia Oct 12, 2023
49e698c
Update MonitorIngestionLiveTest.cs
nisha-bhatia Oct 12, 2023
81d2411
Update MonitorIngestionLiveTest.cs
nisha-bhatia Oct 12, 2023
3cdd388
Update MetricsBatchQueryClient.cs
nisha-bhatia Oct 12, 2023
6a3f143
Merge branch 'nibhati-updateQuery' of https://github.com/nisha-bhatia…
nisha-bhatia Oct 12, 2023
f941367
Update Azure.Core.net472.cs
nisha-bhatia Oct 12, 2023
57af1bb
Update MetricsQueryClientLiveTests.cs
nisha-bhatia Oct 12, 2023
8cdd9e4
revert
nisha-bhatia Oct 13, 2023
30c59c1
Update ResourceIdList.cs
nisha-bhatia Oct 13, 2023
f8d73f1
wip
nisha-bhatia Oct 13, 2023
1f8ba97
add docs
nisha-bhatia Oct 13, 2023
21927cc
Update MetricsQueryClientLiveTests.cs
nisha-bhatia Oct 13, 2023
0889bfb
Update MetricsQueryClientLiveTests.cs
nisha-bhatia Oct 13, 2023
25db226
Update MetricsQueryClientLiveTests.cs
nisha-bhatia Oct 16, 2023
6737d51
wip
nisha-bhatia Oct 16, 2023
5cf2fc1
wip
nisha-bhatia Oct 16, 2023
ab6c527
Update cspell.json
nisha-bhatia Oct 17, 2023
eebfb74
wip
nisha-bhatia Oct 17, 2023
964b9bf
wip
nisha-bhatia Oct 17, 2023
50c0f87
wip
nisha-bhatia Oct 17, 2023
a87a324
wip
nisha-bhatia Oct 17, 2023
e2ba5fb
wip
nisha-bhatia Oct 17, 2023
c056b9e
Delete Azure.Monitor.OpenTelemetry.Exporter.net6.0.cs
nisha-bhatia Oct 17, 2023
be60123
Update README.md
nisha-bhatia Oct 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .vscode/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -1228,6 +1228,12 @@
"runpath",
"Cves"
]
},
{
"filename": "**/sdk/monitor/**/*.cs",
"words": [
"resourceid"
Comment thread
nisha-bhatia marked this conversation as resolved.
]
}
],
"allowCompoundWords": true
Expand Down
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 @@ -3,6 +3,8 @@
## 1.3.0-beta.1 (Unreleased)

### Features Added
- Added the `MetricsBatchQueryClient` client to support batch querying of metrics.
- Added `QueryBatch` and `QueryBatchAsync` methods to `MetricsBatchQueryClient`

### Breaking Changes

Expand Down
23 changes: 23 additions & 0 deletions sdk/monitor/Azure.Monitor.Query/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,28 @@ foreach (MetricResult metric in result.Value.Metrics)
}
```

#### Metrics batch query

A user can also query metrics from multiple resources at once using the `QueryBatch` method of `MetricsBatchQueryClient`. This uses a different API than the `MetricsQueryClient` and requires that a user pass in a regional endpoint when instantiating the client (for example, "https://westus3.metrics.monitor.azure.com").

Note, each resource must be in the same region as the endpoint passed in when instantiating the client, and each resource must be in the same Azure subscription. Furthermore, the metric namespace that contains the metrics to be queried must also be passed. A list of metric namespaces can be found [here][metric_namespaces].

```C# Snippet:QueryBatchMetrics
string resourceId =
"/subscriptions/<id>/resourceGroups/<rg-name>/providers/<source>/storageAccounts/<resource-name-1>";
MetricsBatchQueryClient client = new MetricsBatchQueryClient(new Uri("https://metrics.monitor.azure.com/.default"), new DefaultAzureCredential());
Response<MetricResultsResponse> metricsResultsResponse = await client.QueryBatchAsync(
resourceIds: new List<string> { resourceId },
metricNames: new List<string> { "Ingress" },
metricNamespace: "Microsoft.Storage/storageAccounts").ConfigureAwait(false);

MetricResultsResponse metricsQueryResults = metricsResultsResponse.Value;
foreach (var value in metricsQueryResults.Values)
{
Console.WriteLine(value.Interval);
}
```

For an inventory of metrics and dimensions available for each Azure resource type, see [Supported metrics with Azure Monitor](https://learn.microsoft.com/azure/azure-monitor/essentials/metrics-supported).

#### Register the client with dependency injection
Expand Down Expand Up @@ -618,6 +640,7 @@ This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For m
[msdocs_apiref]: https://learn.microsoft.com/dotnet/api/overview/azure/monitor.query-readme?view=azure-dotnet
[package]: https://www.nuget.org/packages/Azure.Monitor.Query
[source]: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/monitor/Azure.Monitor.Query/src
[metric_namespaces]: https://learn.microsoft.com/azure/azure-monitor/reference/supported-metrics/metrics-index#metrics-by-resource-provider

[cla]: https://cla.microsoft.com
[coc]: https://opensource.microsoft.com/codeofconduct/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,22 @@ public LogsQueryOptions() { }
public bool IncludeVisualization { get { throw null; } set { } }
public System.TimeSpan? ServerTimeout { get { throw null; } set { } }
}
public partial class MetricsBatchQueryClient
{
protected MetricsBatchQueryClient() { }
public MetricsBatchQueryClient(System.Uri endpoint, Azure.Core.TokenCredential credential, Azure.Monitor.Query.MetricsBatchQueryClientOptions options = null) { }
public System.Uri Endpoint { get { throw null; } }
public virtual Azure.Response<Azure.Monitor.Query.Models.MetricResultsResponse> QueryBatch(System.Collections.Generic.List<string> resourceIds, System.Collections.Generic.List<string> metricNames, string metricNamespace, Azure.Monitor.Query.MetricsQueryOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Monitor.Query.Models.MetricResultsResponse>> QueryBatchAsync(System.Collections.Generic.List<string> resourceIds, System.Collections.Generic.List<string> metricNames, string metricNamespace, Azure.Monitor.Query.MetricsQueryOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
}
public partial class MetricsBatchQueryClientOptions : Azure.Core.ClientOptions
{
public MetricsBatchQueryClientOptions(Azure.Monitor.Query.MetricsBatchQueryClientOptions.ServiceVersion version = Azure.Monitor.Query.MetricsBatchQueryClientOptions.ServiceVersion.V2023_05_01_PREVIEW) { }
public enum ServiceVersion
{
V2023_05_01_PREVIEW = 1,
}
}
public partial class MetricsQueryClient
{
protected MetricsQueryClient() { }
Expand Down Expand Up @@ -287,6 +303,22 @@ internal MetricResult() { }
public System.Collections.Generic.IReadOnlyList<Azure.Monitor.Query.Models.MetricTimeSeriesElement> TimeSeries { get { throw null; } }
public Azure.Monitor.Query.Models.MetricUnit Unit { get { throw null; } }
}
public partial class MetricResultsResponse
{
internal MetricResultsResponse() { }
public System.Collections.Generic.IReadOnlyList<Azure.Monitor.Query.Models.MetricResultsResponseValuesItem> Values { get { throw null; } }
}
public partial class MetricResultsResponseValuesItem
{
internal MetricResultsResponseValuesItem() { }
public System.DateTimeOffset EndTime { get { throw null; } }
public System.TimeSpan? Interval { get { throw null; } }
public string Namespace { get { throw null; } }
public Azure.Core.ResourceIdentifier ResourceId { get { throw null; } }
public string ResourceRegion { get { throw null; } }
public System.DateTimeOffset StartTime { get { throw null; } }
public System.Collections.Generic.IReadOnlyList<Azure.Monitor.Query.Models.QueryBatchMetric> Value { get { throw null; } }
}
public partial class MetricsQueryResult
{
internal MetricsQueryResult() { }
Expand Down Expand Up @@ -352,9 +384,72 @@ public static partial class MonitorQueryModelFactory
public static Azure.Monitor.Query.Models.LogsTableRow LogsTableRow(System.Collections.Generic.IEnumerable<Azure.Monitor.Query.Models.LogsTableColumn> columns, System.Collections.Generic.IEnumerable<object> values) { throw null; }
public static Azure.Monitor.Query.Models.MetricAvailability MetricAvailability(System.TimeSpan? granularity = default(System.TimeSpan?), System.TimeSpan? retention = default(System.TimeSpan?)) { throw null; }
public static Azure.Monitor.Query.Models.MetricResult MetricResult(string id, string resourceType, string name, Azure.Monitor.Query.Models.MetricUnit unit, System.Collections.Generic.IEnumerable<Azure.Monitor.Query.Models.MetricTimeSeriesElement> timeSeries) { throw null; }
public static Azure.Monitor.Query.Models.MetricResultsResponse MetricResultsResponse(System.Collections.Generic.IEnumerable<Azure.Monitor.Query.Models.MetricResultsResponseValuesItem> values = null) { throw null; }
public static Azure.Monitor.Query.Models.MetricResultsResponseValuesItem MetricResultsResponseValuesItem(System.DateTimeOffset startTime = default(System.DateTimeOffset), System.DateTimeOffset endTime = default(System.DateTimeOffset), System.TimeSpan? interval = default(System.TimeSpan?), string @namespace = null, string resourceRegion = null, Azure.Core.ResourceIdentifier resourceId = null, System.Collections.Generic.IEnumerable<Azure.Monitor.Query.Models.QueryBatchMetric> value = null) { throw null; }
public static Azure.Monitor.Query.Models.MetricsQueryResult MetricsQueryResult(int? cost, string timespan, System.TimeSpan? granularity, string @namespace, string resourceRegion, System.Collections.Generic.IReadOnlyList<Azure.Monitor.Query.Models.MetricResult> metrics) { throw null; }
public static Azure.Monitor.Query.Models.MetricTimeSeriesElement MetricTimeSeriesElement(System.Collections.Generic.IReadOnlyDictionary<string, string> metadataValues, System.Collections.Generic.IEnumerable<Azure.Monitor.Query.Models.MetricValue> values) { throw null; }
public static Azure.Monitor.Query.Models.MetricValue MetricValue(System.DateTimeOffset timeStamp = default(System.DateTimeOffset), double? average = default(double?), double? minimum = default(double?), double? maximum = default(double?), double? total = default(double?), double? count = default(double?)) { throw null; }
public static Azure.Monitor.Query.Models.QueryBatchLocalizableString QueryBatchLocalizableString(string value = null, string localizedValue = null) { throw null; }
public static Azure.Monitor.Query.Models.QueryBatchMetadataValue QueryBatchMetadataValue(Azure.Monitor.Query.Models.QueryBatchLocalizableString name = null, string value = null) { throw null; }
public static Azure.Monitor.Query.Models.QueryBatchMetric QueryBatchMetric(string id = null, Azure.Monitor.Query.Models.QueryBatchLocalizableString name = null, string displayDescription = null, string type = null, Azure.Monitor.Query.Models.QueryBatchMetricUnit unit = Azure.Monitor.Query.Models.QueryBatchMetricUnit.Count, System.Collections.Generic.IEnumerable<Azure.Monitor.Query.Models.QueryBatchTimeSeriesElement> timeseries = null, string errorCode = null, string errorMessage = null) { throw null; }
public static Azure.Monitor.Query.Models.QueryBatchMetricValue QueryBatchMetricValue(System.DateTimeOffset timeStamp = default(System.DateTimeOffset), double? average = default(double?), double? minimum = default(double?), double? maximum = default(double?), double? total = default(double?), double? count = default(double?)) { throw null; }
public static Azure.Monitor.Query.Models.QueryBatchTimeSeriesElement QueryBatchTimeSeriesElement(System.Collections.Generic.IEnumerable<Azure.Monitor.Query.Models.QueryBatchMetadataValue> metadatavalues = null, System.Collections.Generic.IEnumerable<Azure.Monitor.Query.Models.QueryBatchMetricValue> data = null) { throw null; }
}
public partial class QueryBatchLocalizableString
{
internal QueryBatchLocalizableString() { }
public string LocalizedValue { get { throw null; } }
public string Value { get { throw null; } }
}
public partial class QueryBatchMetadataValue
{
internal QueryBatchMetadataValue() { }
public Azure.Monitor.Query.Models.QueryBatchLocalizableString Name { get { throw null; } }
public string Value { get { throw null; } }
}
public partial class QueryBatchMetric
{
internal QueryBatchMetric() { }
public string DisplayDescription { get { throw null; } }
public string ErrorCode { get { throw null; } }
public string ErrorMessage { get { throw null; } }
public string Id { get { throw null; } }
public Azure.Monitor.Query.Models.QueryBatchLocalizableString Name { get { throw null; } }
public System.Collections.Generic.IReadOnlyList<Azure.Monitor.Query.Models.QueryBatchTimeSeriesElement> Timeseries { get { throw null; } }
public string Type { get { throw null; } }
public Azure.Monitor.Query.Models.QueryBatchMetricUnit Unit { get { throw null; } }
}
public enum QueryBatchMetricUnit
{
Count = 0,
Bytes = 1,
Seconds = 2,
CountPerSecond = 3,
BytesPerSecond = 4,
Percent = 5,
MilliSeconds = 6,
ByteSeconds = 7,
Unspecified = 8,
Cores = 9,
MilliCores = 10,
NanoCores = 11,
BitsPerSecond = 12,
}
public partial class QueryBatchMetricValue
{
internal QueryBatchMetricValue() { }
public double? Average { get { throw null; } }
public double? Count { get { throw null; } }
public double? Maximum { get { throw null; } }
public double? Minimum { get { throw null; } }
public System.DateTimeOffset TimeStamp { get { throw null; } }
public double? Total { get { throw null; } }
}
public partial class QueryBatchTimeSeriesElement
{
internal QueryBatchTimeSeriesElement() { }
public System.Collections.Generic.IReadOnlyList<Azure.Monitor.Query.Models.QueryBatchMetricValue> Data { get { throw null; } }
public System.Collections.Generic.IReadOnlyList<Azure.Monitor.Query.Models.QueryBatchMetadataValue> Metadatavalues { get { throw null; } }
}
}
namespace Microsoft.Extensions.Azure
Expand Down
2 changes: 1 addition & 1 deletion sdk/monitor/Azure.Monitor.Query/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "net",
"TagPrefix": "net/monitor/Azure.Monitor.Query",
"Tag": "net/monitor/Azure.Monitor.Query_3b8122268a"
"Tag": "net/monitor/Azure.Monitor.Query_cdc38c2347"
}
Loading