Skip to content

Commit

Permalink
[MetricsAdvisor] Added Event Hubs and Log Analytics data feed sources (
Browse files Browse the repository at this point in the history
  • Loading branch information
kinelski authored Jun 7, 2021
1 parent 2d57a44 commit b29a0b9
Show file tree
Hide file tree
Showing 19 changed files with 2,777 additions and 10 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 @@ -10,6 +10,7 @@
- `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.
- Added property `DataFeedId` to `DataPointAnomaly` and `AnomalyIncident`.
- Added two new data feed sources: `AzureEventHubsDataFeedSource` and `LogAnalyticsDataFeedSource`.

### Breaking Changes
- Update methods will now return the updated entity instead of an empty response. For example, `UpdateDataFeed` now returns a `Response<DataFeed>`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,12 @@ public AzureDataLakeStorageGen2DataFeedSource(string accountName, string account
public string FileTemplate { get { throw null; } set { } }
public void UpdateAccountKey(string accountKey) { }
}
public partial class AzureEventHubsDataFeedSource : Azure.AI.MetricsAdvisor.Models.DataFeedSource
{
public AzureEventHubsDataFeedSource(string connectionString, string consumerGroup) { }
public string ConsumerGroup { get { throw null; } set { } }
public void UpdateConnectionString(string connectionString) { }
}
public partial class AzureTableDataFeedSource : Azure.AI.MetricsAdvisor.Models.DataFeedSource
{
public AzureTableDataFeedSource(string connectionString, string table, string query) { }
Expand Down Expand Up @@ -740,9 +746,9 @@ internal DataFeedSource() { }
public static Azure.AI.MetricsAdvisor.Models.DataFeedSourceType AzureDataExplorer { get { throw null; } }
public static Azure.AI.MetricsAdvisor.Models.DataFeedSourceType AzureDataLakeStorageGen2 { get { throw null; } }
public static Azure.AI.MetricsAdvisor.Models.DataFeedSourceType AzureEventHubs { get { throw null; } }
public static Azure.AI.MetricsAdvisor.Models.DataFeedSourceType AzureLogAnalytics { get { throw null; } }
public static Azure.AI.MetricsAdvisor.Models.DataFeedSourceType AzureTable { get { throw null; } }
public static Azure.AI.MetricsAdvisor.Models.DataFeedSourceType InfluxDb { get { throw null; } }
public static Azure.AI.MetricsAdvisor.Models.DataFeedSourceType LogAnalytics { get { throw null; } }
public static Azure.AI.MetricsAdvisor.Models.DataFeedSourceType MongoDb { get { throw null; } }
public static Azure.AI.MetricsAdvisor.Models.DataFeedSourceType MySql { get { throw null; } }
public static Azure.AI.MetricsAdvisor.Models.DataFeedSourceType PostgreSql { get { throw null; } }
Expand Down Expand Up @@ -920,6 +926,16 @@ public void UpdatePassword(string password) { }
public static bool operator !=(Azure.AI.MetricsAdvisor.Models.IngestionStatusType left, Azure.AI.MetricsAdvisor.Models.IngestionStatusType right) { throw null; }
public override string ToString() { throw null; }
}
public partial class LogAnalyticsDataFeedSource : Azure.AI.MetricsAdvisor.Models.DataFeedSource
{
public LogAnalyticsDataFeedSource(string workspaceId, string query) { }
public LogAnalyticsDataFeedSource(string workspaceId, string query, string clientId, string clientSecret, string tenantId) { }
public string ClientId { get { throw null; } set { } }
public string Query { get { throw null; } set { } }
public string TenantId { get { throw null; } set { } }
public string WorkspaceId { get { throw null; } set { } }
public void UpdateClientSecret(string clientSecret) { }
}
public partial class MetricAnomalyAlertConditions
{
public MetricAnomalyAlertConditions() { }
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.

Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@ internal static DataFeedSource GetDataFeedSource(DataFeedDetail dataFeedDetail)
AzureApplicationInsightsDataFeed d => new AzureApplicationInsightsDataFeedSource(d.DataSourceParameter),
AzureBlobDataFeed d => new AzureBlobDataFeedSource(d.DataSourceParameter),
AzureCosmosDBDataFeed d => new AzureCosmosDbDataFeedSource(d.DataSourceParameter),
AzureDataExplorerDataFeed d => new AzureDataExplorerDataFeedSource(d.DataSourceParameter),
AzureDataLakeStorageGen2DataFeed d => new AzureDataLakeStorageGen2DataFeedSource(d.DataSourceParameter),
AzureEventHubsDataFeed d => new AzureEventHubsDataFeedSource(d.DataSourceParameter),
AzureLogAnalyticsDataFeed d => new LogAnalyticsDataFeedSource(d.DataSourceParameter),
AzureTableDataFeed d => new AzureTableDataFeedSource(d.DataSourceParameter),
InfluxDBDataFeed d => new InfluxDbDataFeedSource(d.DataSourceParameter),
AzureDataExplorerDataFeed d => new AzureDataExplorerDataFeedSource(d.DataSourceParameter),
MongoDBDataFeed d => new MongoDbDataFeedSource(d.DataSourceParameter),
MySqlDataFeed d => new MySqlDataFeedSource(d.DataSourceParameter),
PostgreSqlDataFeed d => new PostgreSqlDataFeedSource(d.DataSourceParameter),
SQLServerDataFeed d => new SqlServerDataFeedSource(d.DataSourceParameter),
MongoDBDataFeed d => new MongoDbDataFeedSource(d.DataSourceParameter),
_ => throw new InvalidOperationException("Invalid DataFeedDetail type")
};

Expand All @@ -54,10 +56,14 @@ internal DataFeedDetail InstantiateDataFeedDetail(string name, DataFeedGranulari
new SqlSourceParameter(d.Query) { ConnectionString = d.ConnectionString }),
AzureDataLakeStorageGen2DataFeedSource d => new AzureDataLakeStorageGen2DataFeed(name, granularityType, metricColumns, ingestionStartTime,
new AzureDataLakeStorageGen2Parameter(d.FileSystemName, d.DirectoryTemplate, d.FileTemplate) { AccountKey = d.AccountKey, AccountName = d.AccountName }),
AzureEventHubsDataFeedSource d => new AzureEventHubsDataFeed(name, granularityType, metricColumns, ingestionStartTime,
new AzureEventHubsParameter(d.ConsumerGroup) { ConnectionString = d.ConnectionString }),
AzureTableDataFeedSource d => new AzureTableDataFeed(name, granularityType, metricColumns, ingestionStartTime,
new AzureTableParameter(d.Table, d.Query) { ConnectionString = d.ConnectionString }),
InfluxDbDataFeedSource d => new InfluxDBDataFeed(name, granularityType, metricColumns, ingestionStartTime,
new InfluxDBParameter(d.Query) { UserName = d.Username, Password = d.Password, Database = d.Database, ConnectionString = d.ConnectionString }),
LogAnalyticsDataFeedSource d => new AzureLogAnalyticsDataFeed(name, granularityType, metricColumns, ingestionStartTime,
new AzureLogAnalyticsParameter(d.WorkspaceId, d.Query) { ClientId = d.ClientId, ClientSecret = d.ClientSecret, TenantId = d.TenantId }),
MongoDbDataFeedSource d => new MongoDBDataFeed(name, granularityType, metricColumns, ingestionStartTime,
new MongoDBParameter(d.Command) { Database = d.Database, ConnectionString = d.ConnectionString }),
MySqlDataFeedSource d => new MySqlDataFeed(name, granularityType, metricColumns, ingestionStartTime,
Expand Down Expand Up @@ -85,10 +91,14 @@ internal DataFeedDetail InstantiateDataFeedDetail(string name, DataFeedGranulari
{ DataSourceParameter = new() { Query = d.Query, ConnectionString = d.ConnectionString } },
AzureDataLakeStorageGen2DataFeedSource d => new AzureDataLakeStorageGen2DataFeedPatch()
{ DataSourceParameter = new() { FileSystemName = d.FileSystemName, DirectoryTemplate = d.DirectoryTemplate, FileTemplate = d.FileTemplate, AccountKey = d.AccountKey, AccountName = d.AccountName } },
AzureEventHubsDataFeedSource d => new AzureEventHubsDataFeedPatch()
{ DataSourceParameter = new() { ConnectionString = d.ConnectionString, ConsumerGroup = d.ConsumerGroup } },
AzureTableDataFeedSource d => new AzureTableDataFeedPatch()
{ DataSourceParameter = new() { Table = d.Table, Query = d.Query, ConnectionString = d.ConnectionString } },
InfluxDbDataFeedSource d => new InfluxDBDataFeedPatch()
{ DataSourceParameter = new() { Query = d.Query, UserName = d.Username, Password = d.Password, Database = d.Database, ConnectionString = d.ConnectionString } },
LogAnalyticsDataFeedSource d => new AzureLogAnalyticsDataFeedPatch()
{ DataSourceParameter = new() { WorkspaceId = d.WorkspaceId, Query = d.Query, ClientId = d.ClientId, ClientSecret = d.ClientSecret, TenantId = d.TenantId } },
MongoDbDataFeedSource d => new MongoDBDataFeedPatch()
{ DataSourceParameter = new() { Command = d.Command, Database = d.Database, ConnectionString = d.ConnectionString } },
MySqlDataFeedSource d => new MySqlDataFeedPatch()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ public readonly partial struct DataFeedSourceType
/// </summary>
public static DataFeedSourceType AzureDataLakeStorageGen2 { get; } = new DataFeedSourceType(AzureDataLakeStorageGen2Value);

/// <summary>
/// Azure Event Hubs.
/// </summary>
public static DataFeedSourceType AzureEventHubs { get; } = new DataFeedSourceType(AzureEventHubsValue);

/// <summary>
/// Azure Table.
/// </summary>
Expand All @@ -48,6 +53,12 @@ public readonly partial struct DataFeedSourceType
[CodeGenMember("InfluxDB")]
public static DataFeedSourceType InfluxDb { get; } = new DataFeedSourceType(InfluxDbValue);

/// <summary>
/// Log Analytics.
/// </summary>
[CodeGenMember("AzureLogAnalytics")]
public static DataFeedSourceType LogAnalytics { get; } = new DataFeedSourceType(LogAnalyticsValue);

/// <summary>
/// MongoDB.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using System.Threading;
using Azure.Core;

namespace Azure.AI.MetricsAdvisor.Models
{
/// <summary>
/// Describes an Azure Event Hubs data source which ingests data into a <see cref="DataFeed"/> for anomaly detection.
/// </summary>
public class AzureEventHubsDataFeedSource : DataFeedSource
{
private string _connectionString;

/// <summary>
/// Initializes a new instance of the <see cref="AzureEventHubsDataFeedSource"/> class.
/// </summary>
/// <param name="connectionString">The connection string for authenticating to the Azure Event Hubs resource.</param>
/// <param name="consumerGroup">The Azure Event Hubs consumer group to use.</param>
/// <exception cref="ArgumentNullException"><paramref name="connectionString"/> or <paramref name="consumerGroup"/> is null.</exception>
/// <exception cref="ArgumentException"><paramref name="connectionString"/> or <paramref name="consumerGroup"/> is empty.</exception>
public AzureEventHubsDataFeedSource(string connectionString, string consumerGroup)
: base(DataFeedSourceType.AzureEventHubs)
{
Argument.AssertNotNullOrEmpty(connectionString, nameof(connectionString));
Argument.AssertNotNullOrEmpty(consumerGroup, nameof(consumerGroup));

ConnectionString = connectionString;
ConsumerGroup = consumerGroup;
}

internal AzureEventHubsDataFeedSource(AzureEventHubsParameter parameter)
: base(DataFeedSourceType.AzureEventHubs)
{
Argument.AssertNotNull(parameter, nameof(parameter));

ConnectionString = parameter.ConnectionString;
ConsumerGroup = parameter.ConsumerGroup;
}

/// <summary>
/// The Azure Event Hubs consumer group to use.
/// </summary>
public string ConsumerGroup { get; set; }

/// <summary>
/// The connection string for authenticating to the Azure Event Hubs resource.
/// </summary>
internal string ConnectionString
{
get => Volatile.Read(ref _connectionString);
private set => Volatile.Write(ref _connectionString, value);
}

/// <summary>
/// Updates the connection string.
/// </summary>
/// <param name="connectionString">The new connection string to be used for authentication.</param>
/// <exception cref="ArgumentNullException"><paramref name="connectionString"/> is null.</exception>
/// <exception cref="ArgumentException"><paramref name="connectionString"/> is empty.</exception>
public void UpdateConnectionString(string connectionString)
{
Argument.AssertNotNullOrEmpty(connectionString, nameof(connectionString));
ConnectionString = connectionString;
}
}
}
Loading

0 comments on commit b29a0b9

Please sign in to comment.