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);
}
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);
}
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);
}
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);
}
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());
}
Aggregations