Search in sources :

Example 16 with ServiceMetricEvent

use of org.apache.druid.java.util.emitter.service.ServiceMetricEvent in project druid by apache.

the class WhiteListBasedDruidToTimelineEventConverterTest method testDefaultIsInWhiteList.

@Test
@Parameters({ "query/time, true", "query/node/ttfb, true", "query/segmentAndCache/time, true", "query/time/balaba, true", "query/tim, false", "segment/added/bytes, true", "segment/count, true", "segment/size, true", "segment/cost/raw, false", "coordinator/TIER_1 /cost/raw, false", "segment/Kost/raw, false", ", false", "word, false", "coordinator, false", "server/, false", "ingest/persists/time, true", "jvm/mem/init, true", "jvm/gc/count, true" })
public void testDefaultIsInWhiteList(String key, boolean expectedValue) {
    ServiceMetricEvent event = ServiceMetricEvent.builder().setFeed("metrics").build(createdTime, key, 10).build(serviceName, hostname);
    boolean isIn = defaultWhiteListBasedDruidToTimelineEventConverter.druidEventToTimelineMetric(event) != null;
    Assert.assertEquals(expectedValue, isIn);
}
Also used : ServiceMetricEvent(org.apache.druid.java.util.emitter.service.ServiceMetricEvent) Parameters(junitparams.Parameters) Test(org.junit.Test)

Example 17 with ServiceMetricEvent

use of org.apache.druid.java.util.emitter.service.ServiceMetricEvent in project druid by apache.

the class InfluxdbEmitterTest method setUp.

@Before
public void setUp() {
    DateTime date = new DateTime(2017, 10, 30, 10, 00, // 10:00am on 30/10/2017 = 1509357600000000000 in epoch nanoseconds
    DateTimeZone.UTC);
    String metric = "metric/te/st/value";
    Number value = 1234;
    ImmutableMap<String, String> serviceDims = ImmutableMap.of("service", "druid/historical", "host", "localhost", "version", "0.10.0");
    ServiceMetricEvent.Builder builder = ServiceMetricEvent.builder();
    builder.setDimension("nonWhiteListedDim", "test");
    builder.setDimension("dataSource", "test_datasource");
    ServiceEventBuilder eventBuilder = builder.build(date, metric, value);
    event = (ServiceMetricEvent) eventBuilder.build(serviceDims);
}
Also used : ServiceEventBuilder(org.apache.druid.java.util.emitter.service.ServiceEventBuilder) ServiceMetricEvent(org.apache.druid.java.util.emitter.service.ServiceMetricEvent) DateTime(org.joda.time.DateTime) Before(org.junit.Before)

Example 18 with ServiceMetricEvent

use of org.apache.druid.java.util.emitter.service.ServiceMetricEvent in project druid by apache.

the class InfluxdbEmitterTest method testMetricIsInDefaultDimensionWhitelist.

@Test
public void testMetricIsInDefaultDimensionWhitelist() {
    DateTime date = new DateTime(2017, 10, 30, 10, 00, // 10:00am on 30/10/2017 = 1509357600000000000 in epoch nanoseconds
    DateTimeZone.UTC);
    String metric = "metric/time";
    Number value = 1234;
    ImmutableMap<String, String> serviceDims = ImmutableMap.of("service", "druid/historical", "host", "localhost", "version", "0.10.0");
    ServiceMetricEvent.Builder builder = ServiceMetricEvent.builder();
    ServiceEventBuilder eventBuilder = builder.build(date, metric, value);
    builder.setDimension("dataSource", "wikipedia");
    builder.setDimension("taskType", "index");
    ServiceMetricEvent event = (ServiceMetricEvent) eventBuilder.build(serviceDims);
    InfluxdbEmitterConfig config = new InfluxdbEmitterConfig("localhost", 8086, null, null, null, null, "dbname", 10000, 15000, 30000, "adam", "password", null);
    InfluxdbEmitter influxdbEmitter = new InfluxdbEmitter(config);
    String expected = "druid_metric,service=druid/historical,hostname=localhost,dataSource=wikipedia,taskType=index druid_time=1234 1509357600000000000" + "\n";
    String actual = influxdbEmitter.transformForInfluxSystems(event);
    Assert.assertEquals(expected, actual);
}
Also used : ServiceEventBuilder(org.apache.druid.java.util.emitter.service.ServiceEventBuilder) ServiceMetricEvent(org.apache.druid.java.util.emitter.service.ServiceMetricEvent) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 19 with ServiceMetricEvent

use of org.apache.druid.java.util.emitter.service.ServiceMetricEvent in project druid by apache.

the class WhiteListBasedConverterTest method testDefaultIsInWhiteList.

@Test
@Parameters({ "query/time, true", "query/node/ttfb, true", "query/segmentAndCache/time, true", "query/time/balaba, true", "query/tim, false", "segment/added/bytes, false", "segment/count, true", "segment/size, true", "segment/cost/raw, false", "coordinator/TIER_1 /cost/raw, false", "segment/Kost/raw, false", ", false", "word, false", "coordinator, false", "server/, false", "ingest/persists/time, true", "jvm/mem/init, true", "jvm/gc/count, true" })
public void testDefaultIsInWhiteList(String key, boolean expectedValue) {
    ServiceMetricEvent event = ServiceMetricEvent.builder().build(createdTime, key, 10).build(serviceName, hostname);
    boolean isIn = defaultWhiteListBasedConverter.druidEventToGraphite(event) != null;
    Assert.assertEquals(expectedValue, isIn);
}
Also used : ServiceMetricEvent(org.apache.druid.java.util.emitter.service.ServiceMetricEvent) Parameters(junitparams.Parameters) Test(org.junit.Test)

Example 20 with ServiceMetricEvent

use of org.apache.druid.java.util.emitter.service.ServiceMetricEvent in project druid by apache.

the class WhiteListBasedConverterTest method testWhiteListedStringArrayDimension.

@Test
public void testWhiteListedStringArrayDimension() throws IOException {
    File mapFile = File.createTempFile("testing-" + System.nanoTime(), ".json");
    mapFile.deleteOnExit();
    try (OutputStream outputStream = new FileOutputStream(mapFile)) {
        IOUtils.copyLarge(getClass().getResourceAsStream("/testWhiteListedStringArrayDimension.json"), outputStream);
    }
    WhiteListBasedConverter converter = new WhiteListBasedConverter(prefix, false, false, false, mapFile.getAbsolutePath(), new DefaultObjectMapper());
    ServiceMetricEvent event = new ServiceMetricEvent.Builder().setDimension("gcName", new String[] { "g1" }).build(createdTime, "jvm/gc/cpu", 10).build(serviceName, hostname);
    GraphiteEvent graphiteEvent = converter.druidEventToGraphite(event);
    Assert.assertNotNull(graphiteEvent);
    Assert.assertEquals(defaultNamespace + ".g1.jvm/gc/cpu", graphiteEvent.getEventPath());
}
Also used : OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) ServiceMetricEvent(org.apache.druid.java.util.emitter.service.ServiceMetricEvent) DefaultObjectMapper(org.apache.druid.jackson.DefaultObjectMapper) File(java.io.File) Test(org.junit.Test)

Aggregations

ServiceMetricEvent (org.apache.druid.java.util.emitter.service.ServiceMetricEvent)64 Test (org.junit.Test)56 DateTime (org.joda.time.DateTime)18 HashMap (java.util.HashMap)14 ServiceEventBuilder (org.apache.druid.java.util.emitter.service.ServiceEventBuilder)14 Emitter (org.apache.druid.java.util.emitter.core.Emitter)12 Event (org.apache.druid.java.util.emitter.core.Event)12 SpanData (io.opentelemetry.sdk.trace.data.SpanData)10 ImmutableMap (com.google.common.collect.ImmutableMap)6 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 File (java.io.File)4 FileOutputStream (java.io.FileOutputStream)4 OutputStream (java.io.OutputStream)4 ArrayList (java.util.ArrayList)4 Map (java.util.Map)4 Parameters (junitparams.Parameters)4 DefaultObjectMapper (org.apache.druid.jackson.DefaultObjectMapper)4 AlertEvent (org.apache.druid.java.util.emitter.service.AlertEvent)4 ServiceEmitter (org.apache.druid.java.util.emitter.service.ServiceEmitter)4 ImmutableList (com.google.common.collect.ImmutableList)2