|
28 | 28 | import java.util.Arrays;
|
29 | 29 | import java.util.Collection;
|
30 | 30 | import java.util.Collections;
|
| 31 | +import java.util.HashMap; |
31 | 32 | import java.util.Iterator;
|
32 | 33 | import java.util.List;
|
33 | 34 | import java.util.ListIterator;
|
@@ -899,6 +900,15 @@ public void init(final boolean forceNewConnection) {
|
899 | 900 | }
|
900 | 901 | }
|
901 | 902 |
|
| 903 | + // Enables jmxfetch telemetry if there are other checks active and it's been enabled |
| 904 | + if (appConfig.getJmxfetchTelemetry() && newInstances.size() >= 1) { |
| 905 | + log.info("Adding jmxfetch telemetry check"); |
| 906 | + final Instance instance = instantiate(getTelemetryInstanceConfig(), |
| 907 | + getTelemetryInitConfig(), "jmxfetch_telemetry_check", |
| 908 | + this.appConfig); |
| 909 | + newInstances.add(instance); |
| 910 | + } |
| 911 | + |
902 | 912 | final List<InstanceTask<Void>> instanceInitTasks =
|
903 | 913 | new ArrayList<>(newInstances.size());
|
904 | 914 | for (Instance instance : newInstances) {
|
@@ -947,6 +957,33 @@ public TaskStatusHandler invoke(
|
947 | 957 | }
|
948 | 958 | }
|
949 | 959 |
|
| 960 | + private Map<String,Object> getTelemetryInitConfig() { |
| 961 | + Map<String,Object> config = new HashMap<String,Object>(); |
| 962 | + config.put("is_jmx",true); |
| 963 | + return config; |
| 964 | + } |
| 965 | + |
| 966 | + private Map<String,Object> getTelemetryInstanceConfig() { |
| 967 | + Map<String,Object> config = new HashMap<String,Object>(); |
| 968 | + config.put("name","jmxfetch_telemetry_instance"); |
| 969 | + config.put("collect_default_jvm_metrics",true); |
| 970 | + config.put("new_gc_metrics",true); |
| 971 | + config.put("process_name_regex",".*org.datadog.jmxfetch.App.*"); |
| 972 | + |
| 973 | + List<Object> conf = new ArrayList<Object>(); |
| 974 | + Map<String,Object> confMap = new HashMap<String,Object>(); |
| 975 | + Map<String,Object> includeMap = new HashMap<String,Object>(); |
| 976 | + includeMap.put("domain","jmxfetch"); |
| 977 | + confMap.put("include", includeMap); |
| 978 | + conf.add(confMap); |
| 979 | + config.put("conf",conf); |
| 980 | + |
| 981 | + List<String> tags = new ArrayList<String>(); |
| 982 | + config.put("tags", tags); |
| 983 | + |
| 984 | + return config; |
| 985 | + } |
| 986 | + |
950 | 987 | static TaskStatusHandler processRecoveryResults(
|
951 | 988 | final Instance instance,
|
952 | 989 | final Future<Void> future,
|
|
0 commit comments