Search in sources :

Example 1 with MetricDimension

use of com.netflix.titus.api.appscale.model.MetricDimension in project titus-control-plane by Netflix.

the class CloudWatchClient method buildMetricDimensions.

@VisibleForTesting
static List<Dimension> buildMetricDimensions(AlarmConfiguration alarmConfiguration, String autoScalingGroup) {
    List<Dimension> metricDimensions = new ArrayList<>(1);
    if (alarmConfiguration.getDimensions() != null && !alarmConfiguration.getDimensions().isEmpty()) {
        for (MetricDimension customMetricDimension : alarmConfiguration.getDimensions()) {
            Dimension dimension = new Dimension();
            dimension.setName(customMetricDimension.getName());
            dimension.setValue(customMetricDimension.getValue());
            metricDimensions.add(dimension);
        }
    } else {
        Dimension dimension = new Dimension();
        dimension.setName(AUTO_SCALING_GROUP_NAME);
        dimension.setValue(autoScalingGroup);
        metricDimensions.add(dimension);
    }
    return metricDimensions;
}
Also used : ArrayList(java.util.ArrayList) Dimension(com.amazonaws.services.cloudwatch.model.Dimension) MetricDimension(com.netflix.titus.api.appscale.model.MetricDimension) MetricDimension(com.netflix.titus.api.appscale.model.MetricDimension) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 2 with MetricDimension

use of com.netflix.titus.api.appscale.model.MetricDimension in project titus-control-plane by Netflix.

the class CloudWatchClientTest method buildCustomMetricDimensions.

@Test
public void buildCustomMetricDimensions() {
    MetricDimension md1 = MetricDimension.newBuilder().withName("foo").withValue("bar").build();
    MetricDimension md2 = MetricDimension.newBuilder().withName("service-tier").withValue("1").build();
    List<MetricDimension> customMetricDimensions = Arrays.asList(md1, md2);
    AlarmConfiguration alarmConfiguration = getAlarmConfigBuilder().withDimensions(customMetricDimensions).build();
    List<Dimension> dimensions = CloudWatchClient.buildMetricDimensions(alarmConfiguration, "foo-bar");
    assertThat(dimensions).isNotNull();
    assertThat(dimensions.size()).isEqualTo(2);
    assertThat(dimensions.get(0).getName()).isEqualTo("foo");
    assertThat(dimensions.get(0).getValue()).isEqualTo("bar");
    assertThat(dimensions.get(1).getName()).isEqualTo("service-tier");
    assertThat(dimensions.get(1).getValue()).isEqualTo("1");
}
Also used : AlarmConfiguration(com.netflix.titus.api.appscale.model.AlarmConfiguration) Dimension(com.amazonaws.services.cloudwatch.model.Dimension) MetricDimension(com.netflix.titus.api.appscale.model.MetricDimension) MetricDimension(com.netflix.titus.api.appscale.model.MetricDimension) Test(org.junit.Test)

Aggregations

Dimension (com.amazonaws.services.cloudwatch.model.Dimension)2 MetricDimension (com.netflix.titus.api.appscale.model.MetricDimension)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 AlarmConfiguration (com.netflix.titus.api.appscale.model.AlarmConfiguration)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1