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] Fixed UpdateDetectionConfiguration methods #21505

Merged
merged 3 commits into from
Jun 4, 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 @@ -7,6 +7,7 @@
- Added properties `ValueOfRootNode` and `ExpectedValueOfRootNode` to `AnomalyIncident` to provide more information about the anomalous data point at the root node of the indicent.
- Response headers that were marked as `REDACTED` in error messages and logs are now exposed by default.
- `GetDetectionConfigurations` and `GetAlertConfigurations` in the `MetricsAdvisorAdministrationClient` can now take a set of options with `Skip` and `MaxPageSize` properties to configure paging behavior.
- Added setters to models that use the Update APIs to make updating easier.

### Breaking Changes
- `NotificationHook.ExternalLink` and `WebNotificationHook.Endpoint` are now of type `Uri`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,8 @@ public MetricsAdvisorAdministrationClient(System.Uri endpoint, Azure.Core.TokenC
public virtual System.Threading.Tasks.Task<Azure.Response> UpdateDataFeedAsync(string dataFeedId, Azure.AI.MetricsAdvisor.Models.DataFeed dataFeed, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Response<Azure.AI.MetricsAdvisor.Models.DatasourceCredential> UpdateDatasourceCredential(Azure.AI.MetricsAdvisor.Models.DatasourceCredential datasourceCredential, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.AI.MetricsAdvisor.Models.DatasourceCredential>> UpdateDatasourceCredentialAsync(Azure.AI.MetricsAdvisor.Models.DatasourceCredential datasourceCredential, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Response UpdateDetectionConfiguration(string detectionConfigurationId, Azure.AI.MetricsAdvisor.Models.AnomalyDetectionConfiguration detectionConfiguration, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response> UpdateDetectionConfigurationAsync(string detectionConfigurationId, Azure.AI.MetricsAdvisor.Models.AnomalyDetectionConfiguration detectionConfiguration, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Response<Azure.AI.MetricsAdvisor.Models.AnomalyDetectionConfiguration> UpdateDetectionConfiguration(string detectionConfigurationId, Azure.AI.MetricsAdvisor.Models.AnomalyDetectionConfiguration detectionConfiguration, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.AI.MetricsAdvisor.Models.AnomalyDetectionConfiguration>> UpdateDetectionConfigurationAsync(string detectionConfigurationId, Azure.AI.MetricsAdvisor.Models.AnomalyDetectionConfiguration detectionConfiguration, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Response UpdateHook(string hookId, Azure.AI.MetricsAdvisor.Models.NotificationHook hook, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Response> UpdateHookAsync(string hookId, Azure.AI.MetricsAdvisor.Models.NotificationHook hook, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
}
Expand Down Expand Up @@ -523,11 +523,11 @@ public AzureTableDataFeedSource(string connectionString, string table, string qu
public partial class ChangeThresholdCondition
{
public ChangeThresholdCondition(double changePercentage, int shiftPoint, bool isWithinRange, Azure.AI.MetricsAdvisor.Models.AnomalyDetectorDirection anomalyDetectorDirection, Azure.AI.MetricsAdvisor.Models.SuppressCondition suppressCondition) { }
public Azure.AI.MetricsAdvisor.Models.AnomalyDetectorDirection AnomalyDetectorDirection { get { throw null; } }
public double ChangePercentage { get { throw null; } }
public bool IsWithinRange { get { throw null; } }
public int ShiftPoint { get { throw null; } }
public Azure.AI.MetricsAdvisor.Models.SuppressCondition SuppressCondition { get { throw null; } }
public Azure.AI.MetricsAdvisor.Models.AnomalyDetectorDirection AnomalyDetectorDirection { get { throw null; } set { } }
public double ChangePercentage { get { throw null; } set { } }
public bool IsWithinRange { get { throw null; } set { } }
public int ShiftPoint { get { throw null; } set { } }
public Azure.AI.MetricsAdvisor.Models.SuppressCondition SuppressCondition { get { throw null; } set { } }
kinelski marked this conversation as resolved.
Show resolved Hide resolved
}
public partial class DataFeed
{
Expand Down Expand Up @@ -861,9 +861,9 @@ public FeedbackDimensionFilter() { }
public partial class HardThresholdCondition
{
public HardThresholdCondition(Azure.AI.MetricsAdvisor.Models.AnomalyDetectorDirection anomalyDetectorDirection, Azure.AI.MetricsAdvisor.Models.SuppressCondition suppressCondition) { }
public Azure.AI.MetricsAdvisor.Models.AnomalyDetectorDirection AnomalyDetectorDirection { get { throw null; } }
public Azure.AI.MetricsAdvisor.Models.AnomalyDetectorDirection AnomalyDetectorDirection { get { throw null; } set { } }
public double? LowerBound { get { throw null; } set { } }
public Azure.AI.MetricsAdvisor.Models.SuppressCondition SuppressCondition { get { throw null; } }
public Azure.AI.MetricsAdvisor.Models.SuppressCondition SuppressCondition { get { throw null; } set { } }
public double? UpperBound { get { throw null; } set { } }
}
public partial class IncidentRootCause
Expand Down Expand Up @@ -1125,9 +1125,9 @@ public SeverityCondition(Azure.AI.MetricsAdvisor.Models.AnomalySeverity minimumA
public partial class SmartDetectionCondition
{
public SmartDetectionCondition(double sensitivity, Azure.AI.MetricsAdvisor.Models.AnomalyDetectorDirection anomalyDetectorDirection, Azure.AI.MetricsAdvisor.Models.SuppressCondition suppressCondition) { }
public Azure.AI.MetricsAdvisor.Models.AnomalyDetectorDirection AnomalyDetectorDirection { get { throw null; } }
public double Sensitivity { get { throw null; } }
public Azure.AI.MetricsAdvisor.Models.SuppressCondition SuppressCondition { get { throw null; } }
public Azure.AI.MetricsAdvisor.Models.AnomalyDetectorDirection AnomalyDetectorDirection { get { throw null; } set { } }
public double Sensitivity { get { throw null; } set { } }
public Azure.AI.MetricsAdvisor.Models.SuppressCondition SuppressCondition { get { throw null; } set { } }
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public readonly partial struct SnoozeScope : System.IEquatable<Azure.AI.MetricsAdvisor.Models.SnoozeScope>
Expand Down Expand Up @@ -1155,8 +1155,8 @@ public SqlServerDataFeedSource(string connectionString, string query) { }
public partial class SuppressCondition
{
public SuppressCondition(int minimumNumber, double minimumRatio) { }
public int MinimumNumber { get { throw null; } }
public double MinimumRatio { get { throw null; } }
public int MinimumNumber { get { throw null; } set { } }
public double MinimumRatio { get { throw null; } set { } }
}
public partial class TopNGroupScope
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -869,13 +869,13 @@ public virtual Response<AnomalyDetectionConfiguration> GetDetectionConfiguration
/// <param name="detectionConfiguration">The <see cref="AnomalyDetectionConfiguration"/> instance containing the desired updates.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
/// <returns>
/// A <see cref="Response"/> containing the result of the operation.
/// A <see cref="Response{T}"/> containing the result of the operation. The result is an <see cref="AnomalyDetectionConfiguration"/>
/// instance containing information about the updated configuration.
/// </returns>
/// <exception cref="ArgumentNullException"><paramref name="detectionConfigurationId"/> or <paramref name="detectionConfiguration"/> is null.</exception>
/// <exception cref="ArgumentException"><paramref name="detectionConfigurationId"/> is empty or not a valid GUID.</exception>
public virtual async Task<Response> UpdateDetectionConfigurationAsync(string detectionConfigurationId, AnomalyDetectionConfiguration detectionConfiguration, CancellationToken cancellationToken = default)
public virtual async Task<Response<AnomalyDetectionConfiguration>> UpdateDetectionConfigurationAsync(string detectionConfigurationId, AnomalyDetectionConfiguration detectionConfiguration, CancellationToken cancellationToken = default)
{
/*
Guid detectionConfigurationGuid = ClientCommon.ValidateGuid(detectionConfigurationId, nameof(detectionConfigurationId));
Argument.AssertNotNull(detectionConfiguration, nameof(detectionConfiguration));
if (!string.IsNullOrEmpty(detectionConfiguration.Id) && !detectionConfigurationId.Equals(detectionConfiguration.Id, StringComparison.OrdinalIgnoreCase))
Expand All @@ -896,10 +896,6 @@ public virtual async Task<Response> UpdateDetectionConfigurationAsync(string det
scope.Failed(e);
throw;
}
*/

await Task.CompletedTask.ConfigureAwait(false);
return default;
}

/// <summary>
Expand All @@ -909,13 +905,13 @@ public virtual async Task<Response> UpdateDetectionConfigurationAsync(string det
/// <param name="detectionConfiguration">The <see cref="AnomalyDetectionConfiguration"/> instance containing the desired updates.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
/// <returns>
/// A <see cref="Response"/> containing the result of the operation.
/// A <see cref="Response{T}"/> containing the result of the operation. The result is an <see cref="AnomalyDetectionConfiguration"/>
/// instance containing information about the updated configuration.
/// </returns>
/// <exception cref="ArgumentNullException"><paramref name="detectionConfigurationId"/> or <paramref name="detectionConfiguration"/> is null.</exception>
/// <exception cref="ArgumentException"><paramref name="detectionConfigurationId"/> is empty or not a valid GUID.</exception>
public virtual Response UpdateDetectionConfiguration(string detectionConfigurationId, AnomalyDetectionConfiguration detectionConfiguration, CancellationToken cancellationToken = default)
public virtual Response<AnomalyDetectionConfiguration> UpdateDetectionConfiguration(string detectionConfigurationId, AnomalyDetectionConfiguration detectionConfiguration, CancellationToken cancellationToken = default)
{
/*
Guid detectionConfigurationGuid = ClientCommon.ValidateGuid(detectionConfigurationId, nameof(detectionConfigurationId));
Argument.AssertNotNull(detectionConfiguration, nameof(detectionConfiguration));
if (!string.IsNullOrEmpty(detectionConfiguration.Id) && !detectionConfigurationId.Equals(detectionConfiguration.Id, StringComparison.OrdinalIgnoreCase))
Expand All @@ -936,8 +932,6 @@ public virtual Response UpdateDetectionConfiguration(string detectionConfigurati
scope.Failed(e);
throw;
}
*/
return default;
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ internal AnomalyDetectionConfigurationPatch GetPatchModel()
DimensionGroupOverrideConfigurations = SeriesGroupDetectionConditions,
Name = Name,
SeriesOverrideConfigurations = SeriesDetectionConditions,
//WholeMetricConfiguration = WholeSeriesDetectionConditions
WholeMetricConfiguration = WholeSeriesDetectionConditions?.GetPatchModel()
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,37 @@ public ChangeThresholdCondition(double changePercentage, int shiftPoint, bool is
/// When set to N, sets as reference the data point that's N positions before the current
/// point. Value must be at least 1.
/// </summary>
public int ShiftPoint { get; }
public int ShiftPoint { get; set; }

/// <summary>
/// Compared to the previous point, the current point is an anomaly if the percentage of change is more than this value.
/// </summary>
public double ChangePercentage { get; }
public double ChangePercentage { get; set; }

/// <summary>
/// Sets whether to detect data within the range or outside the range. If you want to detect fluctuations, select false.
/// If you want to detect flat lines in your data, select true.
/// </summary>
[CodeGenMember("WithinRange")]
public bool IsWithinRange { get; }
public bool IsWithinRange { get; set; }

/// <summary>
/// A point is considered an anomaly only when the deviation occurs in the specified direction.
/// </summary>
public AnomalyDetectorDirection AnomalyDetectorDirection { get; }
public AnomalyDetectorDirection AnomalyDetectorDirection { get; set; }

/// <summary>
/// The <see cref="Models.SuppressCondition"/> to be applied to every unexpected data point.
/// </summary>
public SuppressCondition SuppressCondition { get; }
public SuppressCondition SuppressCondition { get; set; }

internal ChangeThresholdConditionPatch GetPatchModel() => new ChangeThresholdConditionPatch()
maririos marked this conversation as resolved.
Show resolved Hide resolved
{
ShiftPoint = ShiftPoint,
ChangePercentage = ChangePercentage,
WithinRange = IsWithinRange,
AnomalyDetectorDirection = AnomalyDetectorDirection,
SuppressCondition = SuppressCondition?.GetPatchModel()
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ public HardThresholdCondition(AnomalyDetectorDirection anomalyDetectorDirection,
/// The direction of the specified boundaries. Depending on its value, <see cref="LowerBound"/>
/// and/or <see cref="UpperBound"/> may be required.
/// </summary>
public AnomalyDetectorDirection AnomalyDetectorDirection { get; }
public AnomalyDetectorDirection AnomalyDetectorDirection { get; set; }

/// <summary>
/// The <see cref="Models.SuppressCondition"/> to be applied to every unexpected data point.
/// </summary>
public SuppressCondition SuppressCondition { get; }
public SuppressCondition SuppressCondition { get; set; }

/// <summary>
/// The minimum value a data point is expected to assume. Must be set if <see cref="AnomalyDetectorDirection"/>
Expand All @@ -49,5 +49,13 @@ public HardThresholdCondition(AnomalyDetectorDirection anomalyDetectorDirection,
/// is <see cref="AnomalyDetectorDirection.Up"/> or <see cref="AnomalyDetectorDirection.Both"/>.
/// </summary>
public double? UpperBound { get; set; }

internal HardThresholdConditionPatch GetPatchModel() => new HardThresholdConditionPatch()
{
AnomalyDetectorDirection = AnomalyDetectorDirection,
SuppressCondition = SuppressCondition?.GetPatchModel(),
LowerBound = LowerBound,
UpperBound = UpperBound
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,13 @@ public MetricWholeSeriesDetectionCondition()
/// which data points are expected to be.
/// </summary>
public ChangeThresholdCondition ChangeThresholdCondition { get; set; }

internal WholeMetricConfigurationPatch GetPatchModel() => new WholeMetricConfigurationPatch()
{
ConditionOperator = CrossConditionsOperator,
SmartDetectionCondition = SmartDetectionCondition?.GetPatchModel(),
HardThresholdCondition = HardThresholdCondition?.GetPatchModel(),
ChangeThresholdCondition = ChangeThresholdCondition?.GetPatchModel()
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,23 @@ public SmartDetectionCondition(double sensitivity, AnomalyDetectorDirection anom
/// A numerical value to adjust the tolerance of the anomaly detection with a range of (0, 100].
/// Visually, the higher the value, the narrower the upper and lower boundaries around the time series.
/// </summary>
public double Sensitivity { get; }
public double Sensitivity { get; set; }

/// <summary>
/// A point is an anomaly only when the deviation occurs in the specified direction.
/// </summary>
public AnomalyDetectorDirection AnomalyDetectorDirection { get; }
public AnomalyDetectorDirection AnomalyDetectorDirection { get; set; }

/// <summary>
/// The <see cref="Models.SuppressCondition"/> to be applied to every unexpected data point.
/// </summary>
public SuppressCondition SuppressCondition { get; }
public SuppressCondition SuppressCondition { get; set; }

internal SmartDetectionConditionPatch GetPatchModel() => new SmartDetectionConditionPatch()
{
Sensitivity = Sensitivity,
AnomalyDetectorDirection = AnomalyDetectorDirection,
SuppressCondition = SuppressCondition?.GetPatchModel()
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,19 @@ public SuppressCondition(int minimumNumber, double minimumRatio)
/// Must include the most recent point, so value must be at least 1.
/// </summary>
[CodeGenMember("MinNumber")]
public int MinimumNumber { get; }
public int MinimumNumber { get; set; }

/// <summary>
/// The minimum percentage of unexpected values that must be present in the latest ingested
/// data points to detect an anomaly. Value is between (0, 100].
/// </summary>
[CodeGenMember("MinRatio")]
public double MinimumRatio { get; }
public double MinimumRatio { get; set; }

internal SuppressConditionPatch GetPatchModel() => new SuppressConditionPatch()
maririos marked this conversation as resolved.
Show resolved Hide resolved
{
MinNumber = MinimumNumber,
MinRatio = MinimumRatio
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,6 @@ public async Task CreateAndGetDetectionConfigurationWithSeriesConditions()
[RecordedTest]
[TestCase(true)]
[TestCase(false)]
[Ignore("https://github.com/Azure/azure-sdk-for-net/issues/21177")]
public async Task UpdateDetectionConfigurationWithMinimumSetupAndGetInstance(bool useTokenCredential)
{
// Set required parameters of the configuration to be created.
Expand Down Expand Up @@ -578,7 +577,7 @@ public async Task UpdateDetectionConfigurationWithMinimumSetupAndNewInstance()
}

[RecordedTest]
[Ignore("https://github.com/Azure/azure-sdk-for-net/issues/21177")]
[Ignore("https://github.com/Azure/azure-sdk-for-net/issues/21509")]
kinelski marked this conversation as resolved.
Show resolved Hide resolved
public async Task UpdateDetectionConfigurationWithEveryMemberAndGetInstance()
{
// Set parameters of the configuration to be created.
Expand Down
Loading