Search in sources :

Example 11 with InstanceMetrics

use of com.microsoft.dhalion.metrics.InstanceMetrics in project incubator-heron by apache.

the class MetricsCacheMetricsProvider method parse.

@VisibleForTesting
@SuppressWarnings("unchecked")
Map<String, InstanceMetrics> parse(TopologyMaster.MetricResponse response, String component, String metric, Instant startTime) {
    Map<String, InstanceMetrics> metricsData = new HashMap<>();
    if (response == null || !response.getStatus().getStatus().equals(StatusCode.OK)) {
        LOG.info(String.format("Query failure from MetricsCache for %s:%s ", component, metric));
        return metricsData;
    }
    if (response.getMetricCount() == 0) {
        LOG.info(String.format("Did not get any metrics from MetricsCache for %s:%s ", component, metric));
        return metricsData;
    }
    // convert heron.protobuf.taskMetrics to dhalion.InstanceMetrics
    for (TaskMetric tm : response.getMetricList()) {
        String instanceId = tm.getInstanceId();
        InstanceMetrics instanceMetrics = new InstanceMetrics(instanceId);
        for (IndividualMetric im : tm.getMetricList()) {
            String metricName = im.getName();
            Map<Instant, Double> values = new HashMap<>();
            // case 1
            for (IntervalValue iv : im.getIntervalValuesList()) {
                MetricInterval mi = iv.getInterval();
                String value = iv.getValue();
                values.put(Instant.ofEpochSecond(mi.getStart()), Double.parseDouble(value));
            }
            // case 2
            if (im.hasValue()) {
                values.put(startTime, Double.parseDouble(im.getValue()));
            }
            if (!values.isEmpty()) {
                instanceMetrics.addMetric(metricName, values);
            }
        }
        metricsData.put(instanceId, instanceMetrics);
    }
    return metricsData;
}
Also used : InstanceMetrics(com.microsoft.dhalion.metrics.InstanceMetrics) HashMap(java.util.HashMap) TaskMetric(com.twitter.heron.proto.tmaster.TopologyMaster.MetricResponse.TaskMetric) Instant(java.time.Instant) MetricInterval(com.twitter.heron.proto.tmaster.TopologyMaster.MetricInterval) IndividualMetric(com.twitter.heron.proto.tmaster.TopologyMaster.MetricResponse.IndividualMetric) IntervalValue(com.twitter.heron.proto.tmaster.TopologyMaster.MetricResponse.IndividualMetric.IntervalValue) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 12 with InstanceMetrics

use of com.microsoft.dhalion.metrics.InstanceMetrics in project incubator-heron by apache.

the class TestUtils method addInstanceMetric.

private static void addInstanceMetric(ComponentMetrics metrics, int i, double val, String metric) {
    InstanceMetrics instanceMetric = new InstanceMetrics("container_1_bolt_" + i, metric, val);
    metrics.addInstanceMetric(instanceMetric);
}
Also used : InstanceMetrics(com.microsoft.dhalion.metrics.InstanceMetrics)

Example 13 with InstanceMetrics

use of com.microsoft.dhalion.metrics.InstanceMetrics in project incubator-heron by apache.

the class ComponentMetricsHelper method computeMinMaxStats.

public MetricsStats computeMinMaxStats(String metric) {
    double metricMax = 0;
    double metricMin = Double.MAX_VALUE;
    for (InstanceMetrics instance : componentMetrics.getMetrics().values()) {
        Double metricValue = instance.getMetricValueSum(metric);
        if (metricValue == null) {
            continue;
        }
        metricMax = metricMax < metricValue ? metricValue : metricMax;
        metricMin = metricMin > metricValue ? metricValue : metricMin;
    }
    return new MetricsStats(metricMin, metricMax);
}
Also used : InstanceMetrics(com.microsoft.dhalion.metrics.InstanceMetrics)

Example 14 with InstanceMetrics

use of com.microsoft.dhalion.metrics.InstanceMetrics in project incubator-heron by apache.

the class ComponentMetricsHelper method computeBpStats.

public void computeBpStats() {
    for (InstanceMetrics instanceMetrics : componentMetrics.getMetrics().values()) {
        Double bpValue = instanceMetrics.getMetricValueSum(METRIC_BACK_PRESSURE.text());
        if (bpValue != null && bpValue > 0) {
            boltsWithBackpressure.add(instanceMetrics);
            totalBackpressure += bpValue;
        }
    }
}
Also used : InstanceMetrics(com.microsoft.dhalion.metrics.InstanceMetrics)

Example 15 with InstanceMetrics

use of com.microsoft.dhalion.metrics.InstanceMetrics in project incubator-heron by apache.

the class ComponentMetricsHelper method computeBufferSizeTrend.

public void computeBufferSizeTrend() {
    for (InstanceMetrics instanceMetrics : componentMetrics.getMetrics().values()) {
        Map<Instant, Double> bufferMetrics = instanceMetrics.getMetrics().get(METRIC_BUFFER_SIZE.text());
        if (bufferMetrics == null || bufferMetrics.size() < 3) {
            // missing of insufficient data for creating a trend line
            continue;
        }
        SimpleRegression simpleRegression = new SimpleRegression(true);
        for (Instant timestamp : bufferMetrics.keySet()) {
            simpleRegression.addData(timestamp.getEpochSecond(), bufferMetrics.get(timestamp));
        }
        double slope = simpleRegression.getSlope();
        instanceMetrics.addMetric(METRIC_WAIT_Q_GROWTH_RATE.text(), slope);
        if (maxBufferChangeRate < slope) {
            maxBufferChangeRate = slope;
        }
    }
}
Also used : InstanceMetrics(com.microsoft.dhalion.metrics.InstanceMetrics) SimpleRegression(org.apache.commons.math3.stat.regression.SimpleRegression) Instant(java.time.Instant)

Aggregations

InstanceMetrics (com.microsoft.dhalion.metrics.InstanceMetrics)24 ComponentMetrics (com.microsoft.dhalion.metrics.ComponentMetrics)15 HashMap (java.util.HashMap)11 Test (org.junit.Test)8 Symptom (com.microsoft.dhalion.detector.Symptom)7 Instant (java.time.Instant)7 HealthPolicyConfig (com.twitter.heron.healthmgr.HealthPolicyConfig)4 Diagnosis (com.microsoft.dhalion.diagnoser.Diagnosis)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 ComponentMetricsHelper (com.twitter.heron.healthmgr.common.ComponentMetricsHelper)2 MetricsStats (com.twitter.heron.healthmgr.common.MetricsStats)2 BufferSizeSensor (com.twitter.heron.healthmgr.sensors.BufferSizeSensor)2 ExecuteCountSensor (com.twitter.heron.healthmgr.sensors.ExecuteCountSensor)2 TopologyMaster (com.twitter.heron.proto.tmaster.TopologyMaster)2 DocumentContext (com.jayway.jsonpath.DocumentContext)1 Action (com.microsoft.dhalion.resolver.Action)1 ContainerRestart (com.twitter.heron.healthmgr.common.HealthManagerEvents.ContainerRestart)1 MetricInterval (com.twitter.heron.proto.tmaster.TopologyMaster.MetricInterval)1 IndividualMetric (com.twitter.heron.proto.tmaster.TopologyMaster.MetricResponse.IndividualMetric)1 IntervalValue (com.twitter.heron.proto.tmaster.TopologyMaster.MetricResponse.IndividualMetric.IntervalValue)1