Skip to content

Commit

Permalink
First pass at embedding existing jmx integrations
Browse files Browse the repository at this point in the history
Using copy/paste from integrations-core.  Will depend on a new jmxfetch release with DataDog/jmxfetch#205 before this will work.
  • Loading branch information
tylerbenson committed Jan 8, 2019
1 parent db425bb commit de166e5
Show file tree
Hide file tree
Showing 7 changed files with 1,351 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@

import com.google.common.collect.ImmutableList;
import datadog.trace.api.Config;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.datadog.jmxfetch.App;
import org.datadog.jmxfetch.AppConfig;

Expand All @@ -27,6 +34,7 @@ private static void run(final Config config) {
return;
}

final List<String> internalMetricsConfigs = getInternalMetricFiles();
final List<String> metricsConfigs = config.getJmxFetchMetricsConfigs();
final Integer checkPeriod = config.getJmxFetchCheckPeriod();
final Integer refreshBeansPeriod = config.getJmxFetchRefreshBeansPeriod();
Expand All @@ -36,7 +44,8 @@ private static void run(final Config config) {
final String logLevel = getLogLevel();

log.error(
"JMXFetch config: {} {} {} {} {} {} {}",
"JMXFetch config: {} {} {} {} {} {} {} {}",
internalMetricsConfigs,
metricsConfigs,
checkPeriod,
refreshBeansPeriod,
Expand All @@ -47,6 +56,7 @@ private static void run(final Config config) {
final AppConfig appConfig =
AppConfig.create(
DEFAULT_CONFIGS,
internalMetricsConfigs,
metricsConfigs,
checkPeriod,
refreshBeansPeriod,
Expand Down Expand Up @@ -95,6 +105,29 @@ private static String getReporter(final Config config) {
return "statsd:" + host + ":" + config.getJmxFetchStatsdPort();
}

private static List<String> getInternalMetricFiles() {
try {
final InputStream metricConfigsStream =
JMXFetch.class.getResourceAsStream("metricconfigs.txt");
if (metricConfigsStream == null) {
log.debug("metricconfigs not found. returning empty set");
return Collections.emptyList();
} else {
final String configs = IOUtils.toString(metricConfigsStream, StandardCharsets.UTF_8);
final String[] split = configs.split("\n");
final List<String> result = new ArrayList<>(split.length);
for (final String config : split) {
final URL resource = JMXFetch.class.getResource("metricconfigs/" + config);
result.add(resource.getPath().split("\\.jar!/")[1]);
}
return result;
}
} catch (final IOException e) {
log.debug("error reading metricconfigs. returning empty set", e);
return Collections.emptyList();
}
}

private static String getLogLocation() {
return System.getProperty("org.slf4j.simpleLogger.logFile", "System.err");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
activemq.yaml
cassandra.yaml
kafka.yaml
solr.yaml
tomcat.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Default metrics collected by this check. You should not have to modify this.
jmx_metrics:
- include:
destinationType: Queue
attribute:
AverageEnqueueTime:
alias: activemq.queue.avg_enqueue_time
metric_type: gauge
ConsumerCount:
alias: activemq.queue.consumer_count
metric_type: gauge
ProducerCount:
alias: activemq.queue.producer_count
metric_type: gauge
MaxEnqueueTime:
alias: activemq.queue.max_enqueue_time
metric_type: gauge
MinEnqueueTime:
alias: activemq.queue.min_enqueue_time
metric_type: gauge
MemoryPercentUsage:
alias: activemq.queue.memory_pct
metric_type: gauge
QueueSize:
alias: activemq.queue.size
metric_type: gauge
DequeueCount:
alias: activemq.queue.dequeue_count
metric_type: counter
DispatchCount:
alias: activemq.queue.dispatch_count
metric_type: counter
EnqueueCount:
alias: activemq.queue.enqueue_count
metric_type: counter
ExpiredCount:
alias: activemq.queue.expired_count
metric_type: counter
InFlightCount:
alias: activemq.queue.in_flight_count
metric_type: counter

- include:
type: Broker
attribute:
StorePercentUsage:
alias: activemq.broker.store_pct
metric_type: gauge
TempPercentUsage:
alias: activemq.broker.temp_pct
metric_type: gauge
MemoryPercentUsage:
alias: activemq.broker.memory_pct
metric_type: gauge
Loading

0 comments on commit de166e5

Please sign in to comment.