Skip to content

Commit

Permalink
DataPointConfiguration.GlobalAlertTransitionInterval
Browse files Browse the repository at this point in the history
DataPointConfiguration.GlobalAlertClearTransitionInterval
DataPointConfiguration.GlobalAlertForNoData
Added missing HttpIntegration fields
Added Missing Audit log processing
GetExternalApi fixes
Updated nuget packages
  • Loading branch information
davidnmbond committed Jan 2, 2024
1 parent e6a6377 commit 708406f
Show file tree
Hide file tree
Showing 10 changed files with 274 additions and 141 deletions.
10 changes: 5 additions & 5 deletions LogicMonitor.Api.Test/LogicMonitor.Api.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<ItemGroup>
<PackageReference Include="Divergic.Logging.Xunit" Version="4.3.0" />
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="FluentAssertions.Analyzers" Version="0.26.0">
<PackageReference Include="FluentAssertions.Analyzers" Version="0.28.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand All @@ -25,10 +25,10 @@
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.0" />
<PackageReference Include="xunit" Version="2.6.2" />
<PackageReference Include="xunit.analyzers" Version="1.6.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.4">
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.2" />
<PackageReference Include="xunit" Version="2.6.4" />
<PackageReference Include="xunit.analyzers" Version="1.8.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
4 changes: 2 additions & 2 deletions LogicMonitor.Api.Test/Settings/ExternalAlertsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ namespace LogicMonitor.Api.Test.Settings;
public class ExternalAlertsTests(ITestOutputHelper iTestOutputHelper) : TestWithOutput(iTestOutputHelper)
{
[Fact]
public async Task GetAll()
public async Task GetAllAsync()
{
var items = await LogicMonitorClient
.GetAllAsync<ExternalAlert>(default)
Expand All @@ -12,7 +12,7 @@ public async Task GetAll()
}

[Fact]
public async Task GetExternalApi()
public async Task GetExternalApiAsync()
{
var api = await LogicMonitorClient
.GetExternalApiAsync(default)
Expand Down
25 changes: 19 additions & 6 deletions LogicMonitor.Api/Extensions/LogItemExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ internal static void ValidateRegexes()
new(@"^Import DataSource from repository. Change details : Change datasource : (?<logicModuleName>.+?), dsId=(?<logicModuleId>.+?){(?<datasourceContent>.+)}$", RegexOptions.Singleline)),
new(28,
AuditEventEntityType.DataSourceGraph,
new(@"""Action=(?<action>Add)""; ""Type=DataSourceGraph""; ""DataSourceName=(?<logicModuleName>.+?)""; ""Device=NA""; ""Description=Add datasource graph, graph=(?<graphName>.+)\((?<graphId>.+?)\), ""$", RegexOptions.Singleline)),
new(@"""Action=(?<action>Add|Update)""; ""Type=DataSourceGraph""; ""(LogicModuleName|DataSourceName)=(?<logicModuleName>.+?)""; ""Device=NA""; ""Description=Add datasource graph, graph=(?<graphName>.+)\((?<graphId>.+?)\), ""$", RegexOptions.Singleline)),
new(29,
AuditEventEntityType.None,
new(@"^(?<discardedEventAlert>An event alert was discarded for EventSource (?<logicModuleName>.+?) because it exceeded the rate limit of \d+ events per \d+ seconds. Adding filters to your EventSource may help reduce the number of alerts triggered\.)$", RegexOptions.Singleline)),
Expand All @@ -121,7 +121,7 @@ internal static void ValidateRegexes()
new(@"^(?<action>.+?)ed device group (?<resourceGroupName>.+?) \((?<resourceGroupId>.+?)\) ,.+$", RegexOptions.Singleline)),
new(33,
AuditEventEntityType.DataSource,
new(@"^""Action=(?<action>Add)""; ""Type=DataSource""; ""DataSourceName=(?<logicModuleName>.+?)""; ""DeviceName=(?<resourceDisplayName>.+?)""; ""DeviceId=(?<resourceId>\d+?)""; ""Description=(?<dataSourceDescription>.+?)""; ""DataSourceId=(?<logicModuleId>\d+?)""; ""DeviceDataSourceId=(?<deviceDataSourceId>\d+?)""$", RegexOptions.Singleline)),
new(@"^""Action=(?<action>Add)""; ""Type=DataSource""; ""(LogicModuleName|DataSourceName)=(?<logicModuleName>.+?)""; ""DeviceName=(?<resourceDisplayName>.+?)""; ""DeviceId=(?<resourceId>\d+?)""; ""Description=(?<dataSourceDescription>.+?)""; ""DataSourceId=(?<logicModuleId>\d+?)""; ""DeviceDataSourceId=(?<deviceDataSourceId>\d+?)""$", RegexOptions.Singleline)),
new(34,
AuditEventEntityType.AlertNote,
new(@"^Note \((?<alertNote>.+?)\) added to \((?<alertId>.+?)\) by \((?<username>.+?)\).$", RegexOptions.Singleline)),
Expand All @@ -130,7 +130,7 @@ internal static void ValidateRegexes()
new(@"^(?<action>.+?)ed device (?<resourceName>.+) \((?<resourceId>.+?)\) via API token (?<apiTokenId>.+)$", RegexOptions.Singleline)),
new(36,
AuditEventEntityType.None,
new(@"^regular device total monthly metrics -> (?<monthlyMetrics>.+?)$")),
new(@"^(?<action>regular device total monthly metrics) -> (?<monthlyMetrics>.+?)$")),
new(37,
AuditEventEntityType.None,
new(@"^Throttled API request: API token (?<apiTokenId>.+?) attempted to access path '(?<apiPath>.+?)' with Method: (?<apiMethod>.+?)$", RegexOptions.Singleline)),
Expand Down Expand Up @@ -244,7 +244,7 @@ internal static void ValidateRegexes()
new(@"^(?<action>.+) (?<logicModuleType>.+)<(?<instanceName>.+)>\. ""ConfigSourceInstanceId=(?<instanceId>\d+)""; ""ConfigSourceName=(?<logicModuleName>.+)""; ""ConfigVersion=(?<logicModuleVersion>\d+)""; ""DeviceName=(?<resourceName>.+)""; ""DeviceId=(?<resourceId>\d+)"";$", RegexOptions.Singleline)),
new(74,
AuditEventEntityType.DataSource,
new(@"^(?<action>.+) (?<logicModuleType>.+)<(?<instanceName>.+)>\. ""DataSourceInstanceId=(?<instanceId>\d+)""; ""DataSourceName=(?<logicModuleName>.+)""; ""DataSourceVersion=(?<logicModuleVersion>\d+)""; ""DeviceName=(?<resourceName>.+)""; ""DeviceId=(?<resourceId>\d+)"";$", RegexOptions.Singleline)),
new(@"^(?<action>.+) (?<logicModuleType>.+)<(?<instanceName>.+)>\. ""DataSourceInstanceId=(?<instanceId>\d+)""; ""(LogicModuleName|DataSourceName)=(?<logicModuleName>.+)""; ""DataSourceVersion=(?<logicModuleVersion>\d+)""; ""DeviceName=(?<resourceName>.+)""; ""DeviceId=(?<resourceId>\d+)"";$", RegexOptions.Singleline)),
new(75,
AuditEventEntityType.Account,
new(@"^User\(name=(?<userName>.+), email=(?<userEmail>.+)\) (?<action>forgot password)$", RegexOptions.Singleline)),
Expand All @@ -271,8 +271,17 @@ internal static void ValidateRegexes()
new(@"^Schedule (?<action>collect now) for (?<logicModuleType>ConfigSource) instance<(?<instanceId>\d+)>\. ""ConfigSourceInstanceName=(?<instanceName>.+)""; ""ConfigSourceName=(?<logicModuleName>.+)""; ""DeviceName=(?<resourceName>.+)""; ""DeviceId=(?<resourceId>\d+)"";$", RegexOptions.Singleline)),
new(83,
AuditEventEntityType.Collector,
new(@"^(?<action>Add|Update|Delete) the collector (?<collectorId>\d+) \(hostname=(?<collectorName>.+), desc=(?<collectorDescription>.+)\)$", RegexOptions.Singleline))
];
new(@"^(?<action>Add|Update|Delete) the collector (?<collectorId>\d+) \(hostname=(?<collectorName>.+), desc=(?<collectorDescription>.+)\)$", RegexOptions.Singleline)),
new(84,
AuditEventEntityType.Device,
new(@"^Schedule (?<action>auto-discover poll request), deviceId=(?<resourceId>.+), collectorId=(?<collectorId>\d+), requestId=(?<requestId>\d+)$", RegexOptions.Singleline)),
new(85,
AuditEventEntityType.DataSource,
new(@"^""Action=(?<action>Add|Update)""; ""Type=DataSource""; ""LogicModuleName=(?<logicModuleName>.+)""; ""Device=NA""; (""LogicModuleId=(?<logicModuleId>\d+?)""; )?""Description=(?<description>.*)"";?$", RegexOptions.Singleline)),
new(86,
AuditEventEntityType.Device,
new(@"^""Action=(?<action>Schedule)""; ""Type=Device""; ""DeviceName=(?<resourceName>.+)""; ""DeviceId=(?<resourceId>\d+)""; ""Description=(?<description>.+)""$", RegexOptions.Singleline)),
];

/// <summary>
/// Converts a logItem to an AuditItem
Expand Down Expand Up @@ -371,6 +380,7 @@ public static AuditEvent ToAuditEvent(this LogItem logItem)
auditEvent.ResourceHostname = GetGroupValueAsTypeOrNull<string>(match, "resourceHostname");
auditEvent.RemoteSessionType = GetGroupValueAsTypeOrNull<string>(match, "remoteSessionType");
auditEvent.RemoteSessionId = GetGroupValueAsStructOrNull<long>(match, "remoteSessionId");
auditEvent.RequestId = GetGroupValueAsStructOrNull<long>(match, "requestId");
auditEvent.RestrictSso = GetGroupValueAsStructOrNull<bool>(match, "restrictSso");
auditEvent.StartDownTime = GetGroupValueAsTypeOrNull<string>(match, "startDownTime");
auditEvent.UserRole = GetGroupValueAsTypeOrNull<string>(match, "userRole");
Expand Down Expand Up @@ -534,6 +544,9 @@ private static AuditEventActionType GetAction(Match value)
"RE-BALANCED" => AuditEventActionType.Rebalance,
"FORGOT PASSWORD" => AuditEventActionType.RequestPasswordReset,
"RUN" => AuditEventActionType.Run,
"AUTO-DISCOVER POLL REQUEST" => AuditEventActionType.AutoDiscoveryPollRequest,
"REGULAR DEVICE TOTAL MONTHLY METRICS" => AuditEventActionType.RegularDeviceTotalMonthlyMetrics,
"SCHEDULE" => AuditEventActionType.ScheduleActiveDiscovery,
_ => AuditEventActionType.None
};
}
Expand Down
18 changes: 18 additions & 0 deletions LogicMonitor.Api/LogicModules/DataPointConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,24 @@ public class DataPointConfiguration : IdentifiedItem
[DataMember(Name = "globalAlertExpr")]
public string GlobalAlertExpr { get; set; } = string.Empty;

/// <summary>
/// The Global alert transition interval
/// </summary>
[DataMember(Name = "globalAlertTransitionInterval")]
public int GlobalAlertTransitionInterval { get; set; }

/// <summary>
/// The Global alert clear transition interval
/// </summary>
[DataMember(Name = "globalAlertClearTransitionInterval")]
public int GlobalAlertClearTransitionInterval { get; set; }

/// <summary>
/// The Global alert for no data
/// </summary>
[DataMember(Name = "globalAlertForNoData")]
public int GlobalAlertForNoData { get; set; }

/// <summary>
/// Whether to enable anomaly alert generation globally
/// </summary>
Expand Down
9 changes: 8 additions & 1 deletion LogicMonitor.Api/LogicMonitor.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,14 @@
<SymbolPackageFormat>snupkg</SymbolPackageFormat>

<!-- Update the following before releasing to nuget -->
<PackageReleaseNotes>Improved models. Breaking change: fixed naming of SDT to Sdt in properties throughout.</PackageReleaseNotes>
<PackageReleaseNotes>
DataPointConfiguration.GlobalAlertTransitionInterval
DataPointConfiguration.GlobalAlertClearTransitionInterval
DataPointConfiguration.GlobalAlertForNoData
Added missing HttpIntegration fields
Added Missing Audit log processing
GetExternalApi fixes
</PackageReleaseNotes>
<UserSecretsId>57aaa0e7-815d-4065-9339-f3f070bed01e</UserSecretsId>

</PropertyGroup>
Expand Down
5 changes: 5 additions & 0 deletions LogicMonitor.Api/Logs/AuditEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,4 +267,9 @@ public class AuditEvent
/// Collector Group Id
/// </summary>
public int? CollectorGroupId { get; internal set; }

/// <summary>
/// RequestId
/// </summary>
public long? RequestId { get; internal set; }
}
17 changes: 16 additions & 1 deletion LogicMonitor.Api/Logs/AuditEventActionType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,20 @@ public enum AuditEventActionType
/// <summary>
/// Collect Now
/// </summary>
CollectNow
CollectNow,

/// <summary>
/// Auto-discovery Poll Request
/// </summary>
AutoDiscoveryPollRequest,

/// <summary>
/// Regular Device Total Monthly Metrics
/// </summary>
RegularDeviceTotalMonthlyMetrics,

/// <summary>
/// Schedule Active Discovery
/// </summary>
ScheduleActiveDiscovery
}
18 changes: 10 additions & 8 deletions LogicMonitor.Api/Settings/ExternalApiStats.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace LogicMonitor.Api.Settings;
namespace LogicMonitor.Api.Settings;

/// <summary>
/// External API statistic information
/// </summary>
[DataContract]
public class ExternalApiStats
{
public class ExternalApiStats
{
/// <summary>
/// Summary
/// </summary>
Expand Down Expand Up @@ -40,6 +36,12 @@ public class ExternalApiStats
[DataMember(Name = "totalProcessedRequests")]
public int TotalProcessedRequests { get; set; }

/// <summary>
/// Total rejected requests
/// </summary>
[DataMember(Name = "totalRejectedGetAPICount")]
public int TotalRejectedGetApiCount { get; set; }

/// <summary>
/// API
/// </summary>
Expand All @@ -57,4 +59,4 @@ public class ExternalApiStats
/// </summary>
[DataMember(Name = "tags")]
public List<string> Tags { get; set; } = [];
}
}
Loading

0 comments on commit 708406f

Please sign in to comment.