Search in sources :

Example 6 with AlertingConfiguration

use of com.microsoft.applicationinsights.alerting.config.AlertingConfiguration in project ApplicationInsights-Java by microsoft.

the class AlertingSubsystemTest method manualAlertWorks.

@Test
void manualAlertWorks() {
    AtomicReference<AlertBreach> called = new AtomicReference<>();
    Consumer<AlertBreach> consumer = called::set;
    AlertingSubsystem service = AlertingSubsystem.create(consumer, Executors.newSingleThreadExecutor());
    service.updateConfiguration(new AlertingConfiguration(new AlertConfiguration(AlertMetricType.CPU, true, 80, 30, 14400), new AlertConfiguration(AlertMetricType.MEMORY, true, 20, 120, 14400), new DefaultConfiguration(true, 5, 120), new CollectionPlanConfiguration(true, EngineMode.immediate, ZonedDateTime.now().plus(100, ChronoUnit.SECONDS), 120, "a-settings-moniker")));
    assertThat(called.get().getType()).isEqualTo(AlertMetricType.MANUAL);
}
Also used : AlertBreach(com.microsoft.applicationinsights.alerting.alert.AlertBreach) AtomicReference(java.util.concurrent.atomic.AtomicReference) DefaultConfiguration(com.microsoft.applicationinsights.alerting.config.DefaultConfiguration) CollectionPlanConfiguration(com.microsoft.applicationinsights.alerting.config.CollectionPlanConfiguration) AlertConfiguration(com.microsoft.applicationinsights.alerting.config.AlertingConfiguration.AlertConfiguration) AlertingConfiguration(com.microsoft.applicationinsights.alerting.config.AlertingConfiguration) Test(org.junit.jupiter.api.Test)

Example 7 with AlertingConfiguration

use of com.microsoft.applicationinsights.alerting.config.AlertingConfiguration in project ApplicationInsights-Java by microsoft.

the class GcEventMonitorTest method getAlertingSubsystem.

private static AlertingSubsystem getAlertingSubsystem(CompletableFuture<AlertBreach> alertFuture) {
    AlertingSubsystem alertingSubsystem = AlertingSubsystem.create(alertFuture::complete, Executors.newSingleThreadExecutor());
    AlertingConfiguration config = AlertConfigParser.parse("--cpu-trigger-enabled true --cpu-threshold 80 --cpu-trigger-profilingDuration 30 --cpu-trigger-cooldown 14400", "--memory-trigger-enabled true --memory-threshold 20 --memory-trigger-profilingDuration 120 --memory-trigger-cooldown 14400", "--sampling-enabled true --sampling-rate 5 --sampling-profiling-duration 120", "--single --mode immediate --immediate-profiling-duration 120  --expiration 5249157885138288517 --settings-moniker a-settings-moniker");
    alertingSubsystem.initialize(config);
    return alertingSubsystem;
}
Also used : AlertingSubsystem(com.microsoft.applicationinsights.alerting.AlertingSubsystem) AlertingConfiguration(com.microsoft.applicationinsights.alerting.config.AlertingConfiguration)

Aggregations

AlertingConfiguration (com.microsoft.applicationinsights.alerting.config.AlertingConfiguration)7 CollectionPlanConfiguration (com.microsoft.applicationinsights.alerting.config.CollectionPlanConfiguration)5 DefaultConfiguration (com.microsoft.applicationinsights.alerting.config.DefaultConfiguration)5 AlertConfiguration (com.microsoft.applicationinsights.alerting.config.AlertingConfiguration.AlertConfiguration)4 Test (org.junit.jupiter.api.Test)4 AlertBreach (com.microsoft.applicationinsights.alerting.alert.AlertBreach)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 AlertingSubsystem (com.microsoft.applicationinsights.alerting.AlertingSubsystem)1 AlertConfigurationBuilder (com.microsoft.applicationinsights.alerting.config.AlertingConfiguration.AlertConfigurationBuilder)1