Search in sources :

Example 11 with AlertConfiguration

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

the class AlertConfigParser method parseFromMemory.

public static AlertConfiguration parseFromMemory(String memoryConfig) {
    if (memoryConfig == null) {
        return new AlertConfiguration(AlertMetricType.MEMORY, false, 0f, 0, 0);
    }
    String[] tokens = memoryConfig.split(" ");
    Map<String, ParseConfigValue<AlertConfigurationBuilder>> parsers = new HashMap<>();
    parsers.put("memory-threshold", new ParseConfigValue<>(true, (config, arg) -> config.setThreshold(Float.parseFloat(arg))));
    parsers.put("memory-trigger-cooldown", new ParseConfigValue<>(true, (config, arg) -> config.setCooldown(Long.parseLong(arg))));
    parsers.put("memory-trigger-profilingDuration", new ParseConfigValue<>(true, (config, arg) -> config.setProfileDuration(Long.parseLong(arg))));
    parsers.put("memory-trigger-enabled", new ParseConfigValue<>(true, (config, arg) -> config.setEnabled(Boolean.parseBoolean(arg))));
    return parseConfig(new AlertConfigurationBuilder(), tokens, parsers).setType(AlertMetricType.MEMORY).createAlertConfiguration();
}
Also used : CollectionPlanConfiguration(com.microsoft.applicationinsights.alerting.config.CollectionPlanConfiguration) EngineMode(com.microsoft.applicationinsights.alerting.config.CollectionPlanConfiguration.EngineMode) DefaultConfigurationBuilder(com.microsoft.applicationinsights.alerting.config.DefaultConfigurationBuilder) HashMap(java.util.HashMap) Instant(java.time.Instant) CollectionPlanConfigurationBuilder(com.microsoft.applicationinsights.alerting.config.CollectionPlanConfigurationBuilder) DefaultConfiguration(com.microsoft.applicationinsights.alerting.config.DefaultConfiguration) ProfilerConfiguration(com.microsoft.applicationinsights.profiler.ProfilerConfiguration) Map(java.util.Map) AlertConfigurationBuilder(com.microsoft.applicationinsights.alerting.config.AlertingConfiguration.AlertConfigurationBuilder) AlertMetricType(com.microsoft.applicationinsights.alerting.config.AlertMetricType) AlertingConfiguration(com.microsoft.applicationinsights.alerting.config.AlertingConfiguration) ZoneOffset(java.time.ZoneOffset) AlertConfiguration(com.microsoft.applicationinsights.alerting.config.AlertingConfiguration.AlertConfiguration) HashMap(java.util.HashMap) AlertConfiguration(com.microsoft.applicationinsights.alerting.config.AlertingConfiguration.AlertConfiguration) AlertConfigurationBuilder(com.microsoft.applicationinsights.alerting.config.AlertingConfiguration.AlertConfigurationBuilder)

Aggregations

AlertConfiguration (com.microsoft.applicationinsights.alerting.config.AlertingConfiguration.AlertConfiguration)11 Test (org.junit.jupiter.api.Test)7 AlertingConfiguration (com.microsoft.applicationinsights.alerting.config.AlertingConfiguration)6 CollectionPlanConfiguration (com.microsoft.applicationinsights.alerting.config.CollectionPlanConfiguration)6 DefaultConfiguration (com.microsoft.applicationinsights.alerting.config.DefaultConfiguration)6 AlertPipelineTrigger (com.microsoft.applicationinsights.alerting.analysis.AlertPipelineTrigger)4 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)4 AlertBreach (com.microsoft.applicationinsights.alerting.alert.AlertBreach)2 AlertMetricType (com.microsoft.applicationinsights.alerting.config.AlertMetricType)2 AlertConfigurationBuilder (com.microsoft.applicationinsights.alerting.config.AlertingConfiguration.AlertConfigurationBuilder)2 EngineMode (com.microsoft.applicationinsights.alerting.config.CollectionPlanConfiguration.EngineMode)2 CollectionPlanConfigurationBuilder (com.microsoft.applicationinsights.alerting.config.CollectionPlanConfigurationBuilder)2 DefaultConfigurationBuilder (com.microsoft.applicationinsights.alerting.config.DefaultConfigurationBuilder)2 ProfilerConfiguration (com.microsoft.applicationinsights.profiler.ProfilerConfiguration)2 Instant (java.time.Instant)2 ZoneOffset (java.time.ZoneOffset)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2