Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MetricsAdvisor] Added DimensionsToSplitAlert property #22434

Merged
merged 5 commits into from
Jul 5, 2021
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
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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how common is the usage for this property? just wondering if there should be a sample showing it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's not that uncommon. This is used when customers have different people to handle different types of incidents, so splitting an incident into multiple alerts makes it easier to forward them to the right people. It's a property that's very simple to use, so I think it's worth adding it to samples.

I'll go through all MA samples today, so I expect to add it when going through the Alert Config 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 value `None` to `FeedbackQueryTimeMode` to indicate that no time mode is set.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,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