Skip to content

Commit b29a0b9

Browse files
authored
[MetricsAdvisor] Added Event Hubs and Log Analytics data feed sources (Azure#21624)
1 parent 2d57a44 commit b29a0b9

19 files changed

+2777
-10
lines changed

sdk/metricsadvisor/Azure.AI.MetricsAdvisor/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- `GetDetectionConfigurations` and `GetAlertConfigurations` in the `MetricsAdvisorAdministrationClient` can now take a set of options with `Skip` and `MaxPageSize` properties to configure paging behavior.
1111
- Added setters to models that use the Update APIs to make updating easier.
1212
- Added property `DataFeedId` to `DataPointAnomaly` and `AnomalyIncident`.
13+
- Added two new data feed sources: `AzureEventHubsDataFeedSource` and `LogAnalyticsDataFeedSource`.
1314

1415
### Breaking Changes
1516
- Update methods will now return the updated entity instead of an empty response. For example, `UpdateDataFeed` now returns a `Response<DataFeed>`.

sdk/metricsadvisor/Azure.AI.MetricsAdvisor/api/Azure.AI.MetricsAdvisor.netstandard2.0.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,12 @@ public AzureDataLakeStorageGen2DataFeedSource(string accountName, string account
482482
public string FileTemplate { get { throw null; } set { } }
483483
public void UpdateAccountKey(string accountKey) { }
484484
}
485+
public partial class AzureEventHubsDataFeedSource : Azure.AI.MetricsAdvisor.Models.DataFeedSource
486+
{
487+
public AzureEventHubsDataFeedSource(string connectionString, string consumerGroup) { }
488+
public string ConsumerGroup { get { throw null; } set { } }
489+
public void UpdateConnectionString(string connectionString) { }
490+
}
485491
public partial class AzureTableDataFeedSource : Azure.AI.MetricsAdvisor.Models.DataFeedSource
486492
{
487493
public AzureTableDataFeedSource(string connectionString, string table, string query) { }
@@ -740,9 +746,9 @@ internal DataFeedSource() { }
740746
public static Azure.AI.MetricsAdvisor.Models.DataFeedSourceType AzureDataExplorer { get { throw null; } }
741747
public static Azure.AI.MetricsAdvisor.Models.DataFeedSourceType AzureDataLakeStorageGen2 { get { throw null; } }
742748
public static Azure.AI.MetricsAdvisor.Models.DataFeedSourceType AzureEventHubs { get { throw null; } }
743-
public static Azure.AI.MetricsAdvisor.Models.DataFeedSourceType AzureLogAnalytics { get { throw null; } }
744749
public static Azure.AI.MetricsAdvisor.Models.DataFeedSourceType AzureTable { get { throw null; } }
745750
public static Azure.AI.MetricsAdvisor.Models.DataFeedSourceType InfluxDb { get { throw null; } }
751+
public static Azure.AI.MetricsAdvisor.Models.DataFeedSourceType LogAnalytics { get { throw null; } }
746752
public static Azure.AI.MetricsAdvisor.Models.DataFeedSourceType MongoDb { get { throw null; } }
747753
public static Azure.AI.MetricsAdvisor.Models.DataFeedSourceType MySql { get { throw null; } }
748754
public static Azure.AI.MetricsAdvisor.Models.DataFeedSourceType PostgreSql { get { throw null; } }
@@ -920,6 +926,16 @@ public void UpdatePassword(string password) { }
920926
public static bool operator !=(Azure.AI.MetricsAdvisor.Models.IngestionStatusType left, Azure.AI.MetricsAdvisor.Models.IngestionStatusType right) { throw null; }
921927
public override string ToString() { throw null; }
922928
}
929+
public partial class LogAnalyticsDataFeedSource : Azure.AI.MetricsAdvisor.Models.DataFeedSource
930+
{
931+
public LogAnalyticsDataFeedSource(string workspaceId, string query) { }
932+
public LogAnalyticsDataFeedSource(string workspaceId, string query, string clientId, string clientSecret, string tenantId) { }
933+
public string ClientId { get { throw null; } set { } }
934+
public string Query { get { throw null; } set { } }
935+
public string TenantId { get { throw null; } set { } }
936+
public string WorkspaceId { get { throw null; } set { } }
937+
public void UpdateClientSecret(string clientSecret) { }
938+
}
923939
public partial class MetricAnomalyAlertConditions
924940
{
925941
public MetricAnomalyAlertConditions() { }

sdk/metricsadvisor/Azure.AI.MetricsAdvisor/src/Generated/Models/AzureLogAnalyticsDataFeed.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/metricsadvisor/Azure.AI.MetricsAdvisor/src/Generated/Models/AzureLogAnalyticsDataFeedPatch.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/metricsadvisor/Azure.AI.MetricsAdvisor/src/Generated/Models/DataFeedSourceType.cs

Lines changed: 1 addition & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/metricsadvisor/Azure.AI.MetricsAdvisor/src/Models/DataFeed/DataFeedSource.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,16 @@ internal static DataFeedSource GetDataFeedSource(DataFeedDetail dataFeedDetail)
2424
AzureApplicationInsightsDataFeed d => new AzureApplicationInsightsDataFeedSource(d.DataSourceParameter),
2525
AzureBlobDataFeed d => new AzureBlobDataFeedSource(d.DataSourceParameter),
2626
AzureCosmosDBDataFeed d => new AzureCosmosDbDataFeedSource(d.DataSourceParameter),
27+
AzureDataExplorerDataFeed d => new AzureDataExplorerDataFeedSource(d.DataSourceParameter),
2728
AzureDataLakeStorageGen2DataFeed d => new AzureDataLakeStorageGen2DataFeedSource(d.DataSourceParameter),
29+
AzureEventHubsDataFeed d => new AzureEventHubsDataFeedSource(d.DataSourceParameter),
30+
AzureLogAnalyticsDataFeed d => new LogAnalyticsDataFeedSource(d.DataSourceParameter),
2831
AzureTableDataFeed d => new AzureTableDataFeedSource(d.DataSourceParameter),
2932
InfluxDBDataFeed d => new InfluxDbDataFeedSource(d.DataSourceParameter),
30-
AzureDataExplorerDataFeed d => new AzureDataExplorerDataFeedSource(d.DataSourceParameter),
33+
MongoDBDataFeed d => new MongoDbDataFeedSource(d.DataSourceParameter),
3134
MySqlDataFeed d => new MySqlDataFeedSource(d.DataSourceParameter),
3235
PostgreSqlDataFeed d => new PostgreSqlDataFeedSource(d.DataSourceParameter),
3336
SQLServerDataFeed d => new SqlServerDataFeedSource(d.DataSourceParameter),
34-
MongoDBDataFeed d => new MongoDbDataFeedSource(d.DataSourceParameter),
3537
_ => throw new InvalidOperationException("Invalid DataFeedDetail type")
3638
};
3739

@@ -54,10 +56,14 @@ internal DataFeedDetail InstantiateDataFeedDetail(string name, DataFeedGranulari
5456
new SqlSourceParameter(d.Query) { ConnectionString = d.ConnectionString }),
5557
AzureDataLakeStorageGen2DataFeedSource d => new AzureDataLakeStorageGen2DataFeed(name, granularityType, metricColumns, ingestionStartTime,
5658
new AzureDataLakeStorageGen2Parameter(d.FileSystemName, d.DirectoryTemplate, d.FileTemplate) { AccountKey = d.AccountKey, AccountName = d.AccountName }),
59+
AzureEventHubsDataFeedSource d => new AzureEventHubsDataFeed(name, granularityType, metricColumns, ingestionStartTime,
60+
new AzureEventHubsParameter(d.ConsumerGroup) { ConnectionString = d.ConnectionString }),
5761
AzureTableDataFeedSource d => new AzureTableDataFeed(name, granularityType, metricColumns, ingestionStartTime,
5862
new AzureTableParameter(d.Table, d.Query) { ConnectionString = d.ConnectionString }),
5963
InfluxDbDataFeedSource d => new InfluxDBDataFeed(name, granularityType, metricColumns, ingestionStartTime,
6064
new InfluxDBParameter(d.Query) { UserName = d.Username, Password = d.Password, Database = d.Database, ConnectionString = d.ConnectionString }),
65+
LogAnalyticsDataFeedSource d => new AzureLogAnalyticsDataFeed(name, granularityType, metricColumns, ingestionStartTime,
66+
new AzureLogAnalyticsParameter(d.WorkspaceId, d.Query) { ClientId = d.ClientId, ClientSecret = d.ClientSecret, TenantId = d.TenantId }),
6167
MongoDbDataFeedSource d => new MongoDBDataFeed(name, granularityType, metricColumns, ingestionStartTime,
6268
new MongoDBParameter(d.Command) { Database = d.Database, ConnectionString = d.ConnectionString }),
6369
MySqlDataFeedSource d => new MySqlDataFeed(name, granularityType, metricColumns, ingestionStartTime,
@@ -85,10 +91,14 @@ internal DataFeedDetail InstantiateDataFeedDetail(string name, DataFeedGranulari
8591
{ DataSourceParameter = new() { Query = d.Query, ConnectionString = d.ConnectionString } },
8692
AzureDataLakeStorageGen2DataFeedSource d => new AzureDataLakeStorageGen2DataFeedPatch()
8793
{ DataSourceParameter = new() { FileSystemName = d.FileSystemName, DirectoryTemplate = d.DirectoryTemplate, FileTemplate = d.FileTemplate, AccountKey = d.AccountKey, AccountName = d.AccountName } },
94+
AzureEventHubsDataFeedSource d => new AzureEventHubsDataFeedPatch()
95+
{ DataSourceParameter = new() { ConnectionString = d.ConnectionString, ConsumerGroup = d.ConsumerGroup } },
8896
AzureTableDataFeedSource d => new AzureTableDataFeedPatch()
8997
{ DataSourceParameter = new() { Table = d.Table, Query = d.Query, ConnectionString = d.ConnectionString } },
9098
InfluxDbDataFeedSource d => new InfluxDBDataFeedPatch()
9199
{ DataSourceParameter = new() { Query = d.Query, UserName = d.Username, Password = d.Password, Database = d.Database, ConnectionString = d.ConnectionString } },
100+
LogAnalyticsDataFeedSource d => new AzureLogAnalyticsDataFeedPatch()
101+
{ DataSourceParameter = new() { WorkspaceId = d.WorkspaceId, Query = d.Query, ClientId = d.ClientId, ClientSecret = d.ClientSecret, TenantId = d.TenantId } },
92102
MongoDbDataFeedSource d => new MongoDBDataFeedPatch()
93103
{ DataSourceParameter = new() { Command = d.Command, Database = d.Database, ConnectionString = d.ConnectionString } },
94104
MySqlDataFeedSource d => new MySqlDataFeedPatch()

sdk/metricsadvisor/Azure.AI.MetricsAdvisor/src/Models/DataFeed/DataFeedSourceType.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ public readonly partial struct DataFeedSourceType
3737
/// </summary>
3838
public static DataFeedSourceType AzureDataLakeStorageGen2 { get; } = new DataFeedSourceType(AzureDataLakeStorageGen2Value);
3939

40+
/// <summary>
41+
/// Azure Event Hubs.
42+
/// </summary>
43+
public static DataFeedSourceType AzureEventHubs { get; } = new DataFeedSourceType(AzureEventHubsValue);
44+
4045
/// <summary>
4146
/// Azure Table.
4247
/// </summary>
@@ -48,6 +53,12 @@ public readonly partial struct DataFeedSourceType
4853
[CodeGenMember("InfluxDB")]
4954
public static DataFeedSourceType InfluxDb { get; } = new DataFeedSourceType(InfluxDbValue);
5055

56+
/// <summary>
57+
/// Log Analytics.
58+
/// </summary>
59+
[CodeGenMember("AzureLogAnalytics")]
60+
public static DataFeedSourceType LogAnalytics { get; } = new DataFeedSourceType(LogAnalyticsValue);
61+
5162
/// <summary>
5263
/// MongoDB.
5364
/// </summary>
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
using System;
5+
using System.Threading;
6+
using Azure.Core;
7+
8+
namespace Azure.AI.MetricsAdvisor.Models
9+
{
10+
/// <summary>
11+
/// Describes an Azure Event Hubs data source which ingests data into a <see cref="DataFeed"/> for anomaly detection.
12+
/// </summary>
13+
public class AzureEventHubsDataFeedSource : DataFeedSource
14+
{
15+
private string _connectionString;
16+
17+
/// <summary>
18+
/// Initializes a new instance of the <see cref="AzureEventHubsDataFeedSource"/> class.
19+
/// </summary>
20+
/// <param name="connectionString">The connection string for authenticating to the Azure Event Hubs resource.</param>
21+
/// <param name="consumerGroup">The Azure Event Hubs consumer group to use.</param>
22+
/// <exception cref="ArgumentNullException"><paramref name="connectionString"/> or <paramref name="consumerGroup"/> is null.</exception>
23+
/// <exception cref="ArgumentException"><paramref name="connectionString"/> or <paramref name="consumerGroup"/> is empty.</exception>
24+
public AzureEventHubsDataFeedSource(string connectionString, string consumerGroup)
25+
: base(DataFeedSourceType.AzureEventHubs)
26+
{
27+
Argument.AssertNotNullOrEmpty(connectionString, nameof(connectionString));
28+
Argument.AssertNotNullOrEmpty(consumerGroup, nameof(consumerGroup));
29+
30+
ConnectionString = connectionString;
31+
ConsumerGroup = consumerGroup;
32+
}
33+
34+
internal AzureEventHubsDataFeedSource(AzureEventHubsParameter parameter)
35+
: base(DataFeedSourceType.AzureEventHubs)
36+
{
37+
Argument.AssertNotNull(parameter, nameof(parameter));
38+
39+
ConnectionString = parameter.ConnectionString;
40+
ConsumerGroup = parameter.ConsumerGroup;
41+
}
42+
43+
/// <summary>
44+
/// The Azure Event Hubs consumer group to use.
45+
/// </summary>
46+
public string ConsumerGroup { get; set; }
47+
48+
/// <summary>
49+
/// The connection string for authenticating to the Azure Event Hubs resource.
50+
/// </summary>
51+
internal string ConnectionString
52+
{
53+
get => Volatile.Read(ref _connectionString);
54+
private set => Volatile.Write(ref _connectionString, value);
55+
}
56+
57+
/// <summary>
58+
/// Updates the connection string.
59+
/// </summary>
60+
/// <param name="connectionString">The new connection string to be used for authentication.</param>
61+
/// <exception cref="ArgumentNullException"><paramref name="connectionString"/> is null.</exception>
62+
/// <exception cref="ArgumentException"><paramref name="connectionString"/> is empty.</exception>
63+
public void UpdateConnectionString(string connectionString)
64+
{
65+
Argument.AssertNotNullOrEmpty(connectionString, nameof(connectionString));
66+
ConnectionString = connectionString;
67+
}
68+
}
69+
}

0 commit comments

Comments
 (0)