Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ public RuleDataSource()
/// Initializes a new instance of the RuleDataSource class.
/// </summary>
/// <param name="resourceUri">the resource identifier of the resource
/// the rule monitors.</param>
/// the rule monitors. **NOTE**: this property cannot be updated for an
/// existing rule.</param>
public RuleDataSource(string resourceUri = default(string))
{
ResourceUri = resourceUri;
Expand All @@ -46,7 +47,8 @@ public RuleDataSource()

/// <summary>
/// Gets or sets the resource identifier of the resource the rule
/// monitors.
/// monitors. **NOTE**: this property cannot be updated for an existing
/// rule.
/// </summary>
[JsonProperty(PropertyName = "resourceUri")]
public string ResourceUri { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ public RuleEmailAction()
/// Initializes a new instance of the RuleEmailAction class.
/// </summary>
/// <param name="sendToServiceOwners">Whether the administrators
/// (service and co-adiminstrators) of the service should be notified
/// (service and co-administrators) of the service should be notified
/// when the alert is activated.</param>
/// <param name="customEmails">the list of administrator's custom email
/// addresses notifiy of the activation of the alert.</param>
/// addresses to notify of the activation of the alert.</param>
public RuleEmailAction(bool? sendToServiceOwners = default(bool?), IList<string> customEmails = default(IList<string>))
{
SendToServiceOwners = sendToServiceOwners;
Expand All @@ -54,15 +54,15 @@ public RuleEmailAction()

/// <summary>
/// Gets or sets whether the administrators (service and
/// co-adiminstrators) of the service should be notified when the alert
/// co-administrators) of the service should be notified when the alert
/// is activated.
/// </summary>
[JsonProperty(PropertyName = "sendToServiceOwners")]
public bool? SendToServiceOwners { get; set; }

/// <summary>
/// Gets or sets the list of administrator's custom email addresses
/// notifiy of the activation of the alert.
/// Gets or sets the list of administrator's custom email addresses to
/// notify of the activation of the alert.
/// </summary>
[JsonProperty(PropertyName = "customEmails")]
public IList<string> CustomEmails { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public RuleManagementEventDataSource()
/// class.
/// </summary>
/// <param name="resourceUri">the resource identifier of the resource
/// the rule monitors.</param>
/// the rule monitors. **NOTE**: this property cannot be updated for an
/// existing rule.</param>
/// <param name="eventName">the event name.</param>
/// <param name="eventSource">the event source.</param>
/// <param name="level">the level.</param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ public RuleMetricDataSource()
/// Initializes a new instance of the RuleMetricDataSource class.
/// </summary>
/// <param name="resourceUri">the resource identifier of the resource
/// the rule monitors.</param>
/// the rule monitors. **NOTE**: this property cannot be updated for an
/// existing rule.</param>
/// <param name="metricName">the name of the metric that defines what
/// the rule monitors.</param>
public RuleMetricDataSource(string resourceUri = default(string), string metricName = default(string))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public RuleWebhookAction()
/// <summary>
/// Initializes a new instance of the RuleWebhookAction class.
/// </summary>
/// <param name="serviceUri">the service uri to Post the notitication
/// <param name="serviceUri">the service uri to Post the notification
/// when the alert activates or resolves.</param>
/// <param name="properties">the dictionary of custom properties to
/// include with the post operation. These data are appended to the
Expand All @@ -53,7 +53,7 @@ public RuleWebhookAction()
partial void CustomInit();

/// <summary>
/// Gets or sets the service uri to Post the notitication when the
/// Gets or sets the service uri to Post the notification when the
/// alert activates or resolves.
/// </summary>
[JsonProperty(PropertyName = "serviceUri")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ internal EventCategoriesOperations(MonitorClient client)

/// <summary>
/// Get the list of available event categories supported in the Activity Logs
/// Service.&lt;br&gt;The current list includes the following: Aministrative,
/// Service.&lt;br&gt;The current list includes the following: Administrative,
/// Security, ServiceHealth, Alert, Recommendation, Policy.
/// </summary>
/// <param name='customHeaders'>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static partial class EventCategoriesOperationsExtensions
{
/// <summary>
/// Get the list of available event categories supported in the Activity Logs
/// Service.&lt;br&gt;The current list includes the following: Aministrative,
/// Service.&lt;br&gt;The current list includes the following: Administrative,
/// Security, ServiceHealth, Alert, Recommendation, Policy.
/// </summary>
/// <param name='operations'>
Expand All @@ -38,7 +38,7 @@ public static IEnumerable<LocalizableString> List(this IEventCategoriesOperation

/// <summary>
/// Get the list of available event categories supported in the Activity Logs
/// Service.&lt;br&gt;The current list includes the following: Aministrative,
/// Service.&lt;br&gt;The current list includes the following: Administrative,
/// Security, ServiceHealth, Alert, Recommendation, Policy.
/// </summary>
/// <param name='operations'>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public partial interface IEventCategoriesOperations
/// <summary>
/// Get the list of available event categories supported in the
/// Activity Logs Service.&lt;br&gt;The current list includes the
/// following: Aministrative, Security, ServiceHealth, Alert,
/// following: Administrative, Security, ServiceHealth, Alert,
/// Recommendation, Policy.
/// </summary>
/// <param name='customHeaders'>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public EventData()
/// <param name="submissionTimestamp">the timestamp of when the event
/// became available for querying via this API. It is in ISO 8601
/// format. This value should not be confused eventTimestamp. As there
/// might be a delay between the occurence time of the event, and the
/// might be a delay between the occurrence time of the event, and the
/// time that the event is submitted to the Azure logging
/// infrastructure.</param>
/// <param name="claims">key value pairs to identify ARM
Expand Down Expand Up @@ -281,7 +281,7 @@ public EventData()
/// Gets or sets the timestamp of when the event became available for
/// querying via this API. It is in ISO 8601 format. This value should
/// not be confused eventTimestamp. As there might be a delay between
/// the occurence time of the event, and the time that the event is
/// the occurrence time of the event, and the time that the event is
/// submitted to the Azure logging infrastructure.
/// </summary>
[JsonProperty(PropertyName = "submissionTimestamp")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public Metric()
/// i.e. it is localizable string.</param>
/// <param name="unit">the unit of the metric. Possible values include:
/// 'Count', 'Bytes', 'Seconds', 'CountPerSecond', 'BytesPerSecond',
/// 'Percent', 'MilliSeconds'</param>
/// 'Percent', 'MilliSeconds', 'ByteSeconds', 'Unspecified'</param>
/// <param name="timeseries">the time series returned when a data query
/// is performed.</param>
public Metric(string id, string type, LocalizableString name, Unit unit, IList<TimeSeriesElement> timeseries)
Expand Down Expand Up @@ -80,7 +80,7 @@ public Metric(string id, string type, LocalizableString name, Unit unit, IList<T
/// <summary>
/// Gets or sets the unit of the metric. Possible values include:
/// 'Count', 'Bytes', 'Seconds', 'CountPerSecond', 'BytesPerSecond',
/// 'Percent', 'MilliSeconds'
/// 'Percent', 'MilliSeconds', 'ByteSeconds', 'Unspecified'
/// </summary>
[JsonProperty(PropertyName = "unit")]
public Unit Unit { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public MetricDefinition()
/// i.e. it is a localizable string.</param>
/// <param name="unit">the unit of the metric. Possible values include:
/// 'Count', 'Bytes', 'Seconds', 'CountPerSecond', 'BytesPerSecond',
/// 'Percent', 'MilliSeconds'</param>
/// 'Percent', 'MilliSeconds', 'ByteSeconds', 'Unspecified'</param>
/// <param name="primaryAggregationType">the primary aggregation type
/// value defining how to use the values for display. Possible values
/// include: 'None', 'Average', 'Count', 'Minimum', 'Maximum',
Expand Down Expand Up @@ -92,7 +92,7 @@ public MetricDefinition()
/// <summary>
/// Gets or sets the unit of the metric. Possible values include:
/// 'Count', 'Bytes', 'Seconds', 'CountPerSecond', 'BytesPerSecond',
/// 'Percent', 'MilliSeconds'
/// 'Percent', 'MilliSeconds', 'ByteSeconds', 'Unspecified'
/// </summary>
[JsonProperty(PropertyName = "unit")]
public Unit? Unit { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ public enum Unit
[EnumMember(Value = "Percent")]
Percent,
[EnumMember(Value = "MilliSeconds")]
MilliSeconds
MilliSeconds,
[EnumMember(Value = "ByteSeconds")]
ByteSeconds,
[EnumMember(Value = "Unspecified")]
Unspecified
}
internal static class UnitEnumExtension
{
Expand All @@ -60,6 +64,10 @@ internal static string ToSerializedValue(this Unit value)
return "Percent";
case Unit.MilliSeconds:
return "MilliSeconds";
case Unit.ByteSeconds:
return "ByteSeconds";
case Unit.Unspecified:
return "Unspecified";
}
return null;
}
Expand All @@ -82,6 +90,10 @@ internal static string ToSerializedValue(this Unit value)
return Unit.Percent;
case "MilliSeconds":
return Unit.MilliSeconds;
case "ByteSeconds":
return Unit.ByteSeconds;
case "Unspecified":
return Unit.Unspecified;
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<Description>Microsoft Azure Monitor Library</Description>
<AssemblyName>Microsoft.Azure.Management.Monitor</AssemblyName>
<Version>0.18.0-preview</Version>
<Version>0.18.1-preview</Version>
<PackageId>Microsoft.Azure.Management.Monitor</PackageId>
<PackageTags>Management.Monitor;Management.Monitoring;metrics;alerts;autoscale;activityLogs;events;operations;logs</PackageTags>
<PackageReleaseNotes>See https://aka.ms/azure-sdk-for-net/monitor/changelog for release notes.</PackageReleaseNotes>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
[assembly: AssemblyTitle("Microsoft Azure Monitor Library")]
[assembly: AssemblyDescription("Provides Microsoft Azure Monitor operations.")]

[assembly: AssemblyVersion("0.18.0.0")]
[assembly: AssemblyFileVersion("0.18.0.0")]
[assembly: AssemblyVersion("0.18.1.0")]
[assembly: AssemblyFileVersion("0.18.1.0")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("Microsoft Azure .NET SDK")]
Expand Down
105 changes: 101 additions & 4 deletions src/SDKs/Monitor/Monitor.Tests/Scenarios/MetricsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,18 @@
using Xunit;
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
using System.Globalization;
using Microsoft.Rest.Azure.OData;
using System;

namespace Monitor.Tests.Scenarios
{
public class MetricsTests : TestBase
{
private const string ResourceGroupName = "Rac46PostSwapRG";
private const string ResourceUriLegacy = "/subscriptions/{0}/resourceGroups/" + ResourceGroupName + "/providers/Microsoft.Web/sites/alertruleTest";

// 56bb45c9-5c14-4914-885e-c6fd6f130f7c (Demo – Azure Monitoring) For multi-dim metrics
private const string ResourceUri = "subscriptions/56bb45c9-5c14-4914-885e-c6fd6f130f7c/resourceGroups/contoso-data/providers/Microsoft.Storage/storageAccounts/contosodatadiag1";
private RecordedDelegatingHandler handler;

public MetricsTests()
Expand Down Expand Up @@ -46,7 +51,15 @@ public void GetMetricDefinitionsTest()
Check(actualMetricDefinitions.ToList());
}

// ***** read definitions for multi-dim metrics here
// ***** read definitions for multi-dim metrics
actualMetricDefinitions = insightsClient.MetricDefinitions.ListAsync(
resourceUri: ResourceUri,
cancellationToken: new CancellationToken()).Result;

if (!this.IsRecording)
{
Check(actualMetricDefinitions.ToList());
}
}
}

Expand Down Expand Up @@ -83,23 +96,101 @@ public void GetMetricsTest()
Check(actualMetrics);
}

// TODO: read multi-dim metrics here
// Reading multi-dim metrics
// https://management.azure.com/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/azmon-rest-api-walkthrough/providers/Microsoft.Storage/accounts/contosodiag1/providers/microsoft.insights/metrics?metric=Transactions&timespan=2017-09-19T02:00:00Z/2017-09-19T02:25:00Z&$filter=APIName eq 'GetBlobProperties'&interval=PT1M&aggregation=Count&api-version=2017-05-01-preview"
string timeSpan = "2017-09-19T02:00:00Z/2017-09-19T02:25:00Z";
ODataQuery<MetadataValue> filter = new ODataQuery<MetadataValue>("APIName eq 'GetBlobProperties'");

// Read data
actualMetrics = insightsClient.Metrics.List(
resourceUri: ResourceUri,
odataQuery: filter,
timespan: timeSpan,
interval: TimeSpan.FromMinutes(1),
metric: "Transactions",
aggregation: "Count",
resultType: ResultType.Data);

if (!this.IsRecording)
{
Check(actualMetrics, true);
}

// Read metadata
// NOTICE the change in the filter. If '*' is not there the backend returns BadRequest
filter = new ODataQuery<MetadataValue>("APIName eq '*'");
actualMetrics = insightsClient.Metrics.List(
resourceUri: ResourceUri,
odataQuery: filter,
timespan: timeSpan,
interval: TimeSpan.FromMinutes(1),
metric: "Transactions",
aggregation: "Count",
resultType: ResultType.Metadata);

if (!this.IsRecording)
{
CheckMetadata(actualMetrics);
}
}
}

private void Check(Response act)
private void Check(Response act, bool multiDim = false)
{
if (act != null)
{
Assert.NotNull(act.Cost);
Assert.NotNull(act.Timespan);
Assert.NotNull(act.Interval);
Assert.NotNull(act.Value);

if (act.Value.Count > 0)
{
var metric = act.Value[0];
Assert.False(string.IsNullOrWhiteSpace(metric.Id));
Assert.NotNull(metric.Name);
Assert.False(string.IsNullOrWhiteSpace(metric.Type));
Assert.Equal(metric.Type, "Microsoft.Insights/metrics");

Assert.NotNull(metric.Timeseries);
if (metric.Timeseries.Count > 0)
{
var timeSeries = metric.Timeseries[0];
Assert.NotNull(timeSeries.Metadatavalues);
Assert.True((multiDim && timeSeries.Metadatavalues.Count > 0) || (!multiDim && timeSeries.Metadatavalues.Count == 0));
Assert.NotNull(timeSeries.Data);
}
}
}
else
{
Assert.Null(act);
}
}

private void CheckMetadata(Response act)
{
if (act != null)
{
Assert.Null(act.Cost);
Assert.NotNull(act.Timespan);
Assert.Null(act.Interval);
Assert.NotNull(act.Value);

if (act.Value.Count > 0)
{
var metric = act.Value[0];
Assert.False(string.IsNullOrWhiteSpace(metric.Id));
Assert.NotNull(metric.Name);
Assert.Equal(metric.Type, "Microsoft.Insights/metrics");

Assert.NotNull(metric.Timeseries);
if (metric.Timeseries.Count > 0)
{
var timeSeries = metric.Timeseries[0];
Assert.NotNull(timeSeries.Metadatavalues);
Assert.NotEmpty(timeSeries.Metadatavalues);
Assert.Null(timeSeries.Data);
}
}
}
else
Expand All @@ -120,6 +211,12 @@ private static void Check(IList<MetricDefinition> act)
Assert.False(string.IsNullOrWhiteSpace(metricDef.Id));
Assert.NotNull(metricDef.Name);
Assert.False(string.IsNullOrWhiteSpace(metricDef.ResourceId));

Assert.NotNull(metricDef.PrimaryAggregationType);
Assert.NotNull(metricDef.Unit);
Assert.NotNull(metricDef.MetricAvailabilities);

// NOTE: Category is returned through the cable, but not deserialized!
}
}
else
Expand Down
Loading