Search in sources :

Example 1 with AlertMetricType

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

the class AlertingServiceFactory method addObserver.

private static void addObserver(AlertingSubsystem alertingSubsystem, TelemetryObservers telemetryObservers) {
    telemetryObservers.addObserver(telemetry -> {
        MonitorDomain data = telemetry.getData().getBaseData();
        if (!(data instanceof MetricsData)) {
            return;
        }
        MetricDataPoint point = ((MetricsData) data).getMetrics().get(0);
        AlertMetricType alertMetricType = null;
        if (point.getName().equals(TOTAL_CPU_PC_METRIC_NAME)) {
            alertMetricType = AlertMetricType.CPU;
        }
        if (alertMetricType != null) {
            alertingSubsystem.track(alertMetricType, point.getValue());
        }
    });
}
Also used : MetricsData(com.microsoft.applicationinsights.agent.internal.exporter.models.MetricsData) AlertMetricType(com.microsoft.applicationinsights.alerting.config.AlertMetricType) MetricDataPoint(com.microsoft.applicationinsights.agent.internal.exporter.models.MetricDataPoint) MonitorDomain(com.microsoft.applicationinsights.agent.internal.exporter.models.MonitorDomain)

Aggregations

MetricDataPoint (com.microsoft.applicationinsights.agent.internal.exporter.models.MetricDataPoint)1 MetricsData (com.microsoft.applicationinsights.agent.internal.exporter.models.MetricsData)1 MonitorDomain (com.microsoft.applicationinsights.agent.internal.exporter.models.MonitorDomain)1 AlertMetricType (com.microsoft.applicationinsights.alerting.config.AlertMetricType)1