Skip to content

Commit

Permalink
[MetricsAdvisor] Added DimensionsToSplitAlert property (#22434)
Browse files Browse the repository at this point in the history
  • Loading branch information
kinelski authored Jul 5, 2021
1 parent 4b0c7dd commit bc928f8
Show file tree
Hide file tree
Showing 15 changed files with 794 additions and 813 deletions.
1 change: 1 addition & 0 deletions sdk/metricsadvisor/Azure.AI.MetricsAdvisor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- `DimensionKey` now implements the `IEnumerable<KeyValuePair<string, string>>` interface. Dimension columns can now be enumerated.
- Added method `Contains` to `DimensionKey` to check whether or not a dimension column is present.
- Added a property setter to `MetricSeriesGroupDetectionCondition.SeriesGroupKey` and to `MetricSingleSeriesDetectionCondition.SeriesKey`.
- Added property `DimensionsToSplitAlert` to `AnomalyAlertConfiguration` to allow splitting an alert into multiple ones.
- Added property `MeasureType` to `MetricBoundaryCondition` to control which measure should be used when checking boundaries for alert triggering. Current supported types are `Value` and `Mean`.
- `NotificationHook.Administrators` is now a `IList` (not read-only anymore), and can be used to update the list of administrators or set it during creation.
- Added property `HookKind` to `NotificationHook`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,7 @@ public partial class AnomalyAlertConfiguration
public AnomalyAlertConfiguration() { }
public Azure.AI.MetricsAdvisor.Models.DetectionConditionOperator? ConditionOperator { get { throw null; } set { } }
public string Description { get { throw null; } set { } }
public System.Collections.Generic.IList<string> DimensionsToSplitAlert { get { throw null; } }
public string Id { get { throw null; } }
public System.Collections.Generic.IList<string> IdsOfHooksToAlert { get { throw null; } }
public System.Collections.Generic.IList<Azure.AI.MetricsAdvisor.Models.MetricAlertConfiguration> MetricAlertConfigurations { get { throw null; } }
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public AnomalyAlertConfiguration()
{
IdsOfHooksToAlert = new ChangeTrackingList<string>();
MetricAlertConfigurations = new ChangeTrackingList<MetricAlertConfiguration>();
SplitAlertByDimensions = new ChangeTrackingList<string>();
DimensionsToSplitAlert = new ChangeTrackingList<string>();
}

/// <summary>
Expand Down Expand Up @@ -63,8 +63,14 @@ public AnomalyAlertConfiguration()
/// </summary>
public string Description { get; set; }

// TODO: expose it as part of 1.0.0-beta.4
internal IList<string> SplitAlertByDimensions { get; }
/// <summary>
/// By default, an incident only triggers a single alert, regardless of how many anomalies
/// it contains. This property allows this alert to be split into multiple ones. Each element
/// in this list must hold a dimension name, and it creates a new alert from the original one
/// if the corresponding dimension is part of current incident.
/// </summary>
[CodeGenMember("SplitAlertByDimensions")]
public IList<string> DimensionsToSplitAlert { get; }

/// <summary>
/// Create a patch model from the current <see cref="AnomalyAlertConfiguration"/>
Expand All @@ -78,7 +84,8 @@ internal AnomalyAlertingConfigurationPatch GetPatchModel()
Description = Description,
Name = Name,
HookIds = IdsOfHooksToAlert.Select(h => new Guid(h)).ToList(),
MetricAlertingConfigurations = MetricAlertConfigurations
MetricAlertingConfigurations = MetricAlertConfigurations,
SplitAlertByDimensions = DimensionsToSplitAlert
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,8 @@ internal partial class AnomalyAlertingConfigurationPatch

/// <summary> Anomaly alerting configurations. </summary>
public IList<MetricAlertConfiguration> MetricAlertingConfigurations { get; internal set; }

/// <summary> dimensions used to split alert. </summary>
public IList<string> SplitAlertByDimensions { get; internal set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public async Task CreateAndGetAlertConfigurationWithWholeSeriesScope(bool useTok
var configToCreate = new AnomalyAlertConfiguration()
{
Name = configName,
DimensionsToSplitAlert = { TempDataFeedDimensionNameA },
MetricAlertConfigurations = { metricAlertConfig }
};

Expand All @@ -49,6 +50,8 @@ public async Task CreateAndGetAlertConfigurationWithWholeSeriesScope(bool useTok
Assert.That(createdConfig.Description, Is.Empty);
Assert.That(createdConfig.ConditionOperator, Is.Null);
Assert.That(createdConfig.IdsOfHooksToAlert, Is.Not.Null.And.Empty);
// https://github.com/Azure/azure-sdk-for-net/issues/22433
//Assert.That(createdConfig.DimensionsToSplitAlert.Single(), Is.EqualTo(TempDataFeedDimensionNameA));
Assert.That(createdConfig.MetricAlertConfigurations, Is.Not.Null);

MetricAlertConfiguration createdMetricAlertConfig = createdConfig.MetricAlertConfigurations.Single();
Expand Down Expand Up @@ -100,6 +103,7 @@ public async Task CreateAndGetAlertConfigurationWithSeriesGroupScope()
Assert.That(createdConfig.Description, Is.Empty);
Assert.That(createdConfig.ConditionOperator, Is.Null);
Assert.That(createdConfig.IdsOfHooksToAlert, Is.Not.Null.And.Empty);
Assert.That(createdConfig.DimensionsToSplitAlert, Is.Not.Null.And.Empty);
Assert.That(createdConfig.MetricAlertConfigurations, Is.Not.Null);

MetricAlertConfiguration createdMetricAlertConfig = createdConfig.MetricAlertConfigurations.Single();
Expand Down Expand Up @@ -149,6 +153,7 @@ public async Task CreateAndGetAlertConfigurationWithTopNScope()
Assert.That(createdConfig.Description, Is.Empty);
Assert.That(createdConfig.ConditionOperator, Is.Null);
Assert.That(createdConfig.IdsOfHooksToAlert, Is.Not.Null.And.Empty);
Assert.That(createdConfig.DimensionsToSplitAlert, Is.Not.Null.And.Empty);
Assert.That(createdConfig.MetricAlertConfigurations, Is.Not.Null);

MetricAlertConfiguration createdMetricAlertConfig = createdConfig.MetricAlertConfigurations.Single();
Expand Down Expand Up @@ -233,6 +238,7 @@ public async Task CreateAndGetAlertConfigurationWithOptionalSingleMetricConfigur
Assert.That(createdConfig.IdsOfHooksToAlert.Count, Is.EqualTo(2));
Assert.That(createdConfig.IdsOfHooksToAlert.Contains(disposableHook0.Hook.Id));
Assert.That(createdConfig.IdsOfHooksToAlert.Contains(disposableHook1.Hook.Id));
Assert.That(createdConfig.DimensionsToSplitAlert, Is.Not.Null.And.Empty);
Assert.That(createdConfig.MetricAlertConfigurations, Is.Not.Null);

MetricAlertConfiguration createdMetricAlertConfig = createdConfig.MetricAlertConfigurations.Single();
Expand Down Expand Up @@ -314,6 +320,7 @@ public async Task CreateAndGetAlertConfigurationWithMultipleMetricConfigurations
Assert.That(createdConfig.Description, Is.Empty);
Assert.That(createdConfig.ConditionOperator, Is.EqualTo(DetectionConditionOperator.Xor));
Assert.That(createdConfig.IdsOfHooksToAlert, Is.Not.Null.And.Empty);
Assert.That(createdConfig.DimensionsToSplitAlert, Is.Not.Null.And.Empty);
Assert.That(createdConfig.MetricAlertConfigurations, Is.Not.Null);
Assert.That(createdConfig.MetricAlertConfigurations.Count, Is.EqualTo(2));

Expand Down Expand Up @@ -435,6 +442,7 @@ public async Task UpdateAlertConfigurationWithMinimumSetup(bool useTokenCrendent
Assert.That(updatedConfig.Description, Is.Empty);
Assert.That(updatedConfig.ConditionOperator, Is.EqualTo(DetectionConditionOperator.Or));
Assert.That(updatedConfig.IdsOfHooksToAlert, Is.EqualTo(hookIds));
Assert.That(updatedConfig.DimensionsToSplitAlert, Is.Not.Null.And.Empty);
Assert.That(updatedConfig.MetricAlertConfigurations, Is.Not.Null);
Assert.That(updatedConfig.MetricAlertConfigurations.Count, Is.EqualTo(2));

Expand Down Expand Up @@ -546,6 +554,7 @@ public async Task UpdateAlertConfigurationWithEveryMember()

configToUpdate.Description = description;
configToUpdate.IdsOfHooksToAlert.Clear();
configToUpdate.DimensionsToSplitAlert.Add(TempDataFeedDimensionNameA);
configToUpdate.ConditionOperator = DetectionConditionOperator.And;
configToUpdate.MetricAlertConfigurations.RemoveAt(1);

Expand Down Expand Up @@ -578,6 +587,7 @@ public async Task UpdateAlertConfigurationWithEveryMember()
Assert.That(updatedConfig.Description, Is.EqualTo(description));
Assert.That(updatedConfig.ConditionOperator, Is.EqualTo(DetectionConditionOperator.And));
Assert.That(updatedConfig.IdsOfHooksToAlert, Is.Not.Null.And.Empty);
Assert.That(updatedConfig.DimensionsToSplitAlert.Single(), Is.EqualTo(TempDataFeedDimensionNameA));
Assert.That(updatedConfig.MetricAlertConfigurations, Is.Not.Null);

// Validate the first Metric Alert Configuration.
Expand Down Expand Up @@ -647,6 +657,7 @@ public async Task GetAlertConfigurations(bool useTokenCredential)
Assert.That(config.Name, Is.Not.Null.And.Not.Empty);
Assert.That(config.Description, Is.Not.Null);
Assert.That(config.IdsOfHooksToAlert, Is.Not.Null);
Assert.That(config.DimensionsToSplitAlert, Is.Not.Null);
Assert.That(config.MetricAlertConfigurations, Is.Not.Null.And.Not.Empty);

if (config.MetricAlertConfigurations.Count == 1)
Expand Down
Loading

0 comments on commit bc928f8

Please sign in to comment.