Move logstash-states template into the main logstash template (elastic/x-pack-elasticsearch#1490)

This is a revert of elastic/x-pack-elasticsearch@1940d79d13.
and also moves the template to boot

Original commit: elastic/x-pack-elasticsearch@434183b0e9
This commit is contained in:
Andrew Cholakian 2017-05-23 09:20:46 -05:00 committed by GitHub
parent 275bfc0e51
commit ae778cc66f
7 changed files with 61 additions and 117 deletions

View File

@ -12,8 +12,7 @@ public enum MonitoredSystem {
ES("es"),
KIBANA("kibana"),
LOGSTASH("logstash"),
BEATS("beats"),
LOGSTASH_STATES("logstash-states");
BEATS("beats");
private final String system;
@ -26,23 +25,17 @@ public enum MonitoredSystem {
}
public static MonitoredSystem fromSystem(String system) {
switch (transformSystemName(system)) {
switch (system.toLowerCase(Locale.ROOT)) {
case "es":
return ES;
case "kibana":
return KIBANA;
case "logstash":
return LOGSTASH;
case "logstash-states":
return LOGSTASH_STATES;
case "beats":
return BEATS;
default:
throw new IllegalArgumentException("Unknown monitoring system [" + system + "]");
}
}
public static String transformSystemName(String systemName) {
return systemName.toLowerCase(Locale.ROOT).replace("_", "-");
}
}

View File

@ -49,7 +49,6 @@ public class ResolversRegistry implements Iterable<MonitoringIndexNameResolver>
// register resolvers for monitored systems
registerMonitoredSystem(MonitoredSystem.KIBANA, settings);
registerMonitoredSystem(MonitoredSystem.LOGSTASH, settings);
registerMonitoredSystem(MonitoredSystem.LOGSTASH_STATES, settings);
registerMonitoredSystem(MonitoredSystem.BEATS, settings);
}

View File

@ -1,98 +0,0 @@
{
"index_patterns": ".monitoring-logstash-states-${monitoring.template.version}-*",
"version": 6000002,
"settings": {
"index.number_of_shards": 1,
"index.number_of_replicas": 1,
"index.codec": "best_compression"
},
"mappings": {
"doc": {
"dynamic": "false",
"properties": {
"cluster_uuid": {
"type": "keyword"
},
"timestamp": {
"type": "date",
"format": "date_time"
},
"type": {
"type": "keyword"
},
"source_node": {
"properties": {
"uuid": {
"type": "keyword"
},
"host": {
"type": "keyword"
},
"transport_address": {
"type": "keyword"
},
"ip": {
"type": "keyword"
},
"name": {
"type": "keyword"
}
}
},
"logstash_state": {
"properties": {
"timestamp": {
"type": "date"
},
"uuid": {
"type": "keyword"
},
"name": {
"type": "keyword"
},
"host": {
"type": "keyword"
},
"http_address": {
"type": "keyword"
},
"version": {
"type": "keyword"
},
"snapshot": {
"type": "boolean"
},
"status": {
"type": "keyword"
},
"pipeline": {
"properties": {
"name": {
"type": "keyword"
},
"hash": {
"type": "keyword"
},
"workers": {
"type": "short"
},
"batch_size": {
"type": "integer"
},
"format": {
"type": "keyword"
},
"version": {
"type": "keyword"
},
"representation": {
"enabled": false
}
}
}
}
}
}
}
}
}

View File

@ -329,6 +329,59 @@
}
}
}
},
"logstash_state": {
"properties": {
"timestamp": {
"type": "date"
},
"uuid": {
"type": "keyword"
},
"name": {
"type": "keyword"
},
"host": {
"type": "keyword"
},
"http_address": {
"type": "keyword"
},
"version": {
"type": "keyword"
},
"snapshot": {
"type": "boolean"
},
"status": {
"type": "keyword"
},
"pipeline": {
"properties": {
"name": {
"type": "keyword"
},
"hash": {
"type": "keyword"
},
"workers": {
"type": "short"
},
"batch_size": {
"type": "integer"
},
"format": {
"type": "keyword"
},
"version": {
"type": "keyword"
},
"representation": {
"enabled": false
}
}
}
}
}
}
}

View File

@ -19,14 +19,16 @@ public class MonitoredSystemTests extends ESTestCase {
public void testGetSystem() {
// everything is just lowercased...
for (final MonitoredSystem system : MonitoredSystem.values()) {
assertEquals(MonitoredSystem.transformSystemName(system.name()), system.getSystem());
assertEquals(system.name().toLowerCase(Locale.ROOT), system.getSystem());
}
}
public void testFromSystem() {
for (final MonitoredSystem system : MonitoredSystem.values()) {
final String lowercased = system.name().toLowerCase(Locale.ROOT);
assertSame(system, MonitoredSystem.fromSystem(system.name()));
assertSame(system, MonitoredSystem.fromSystem(MonitoredSystem.transformSystemName(system.name())));
assertSame(system, MonitoredSystem.fromSystem(lowercased));
}
}
@ -40,9 +42,4 @@ public class MonitoredSystemTests extends ESTestCase {
assertThat(e.getMessage(), containsString(unknownSystem));
}
public void testTransformSystemName() {
final String systemName = "MiXED_System_Name";
assertEquals(MonitoredSystem.transformSystemName(systemName), "mixed-system-name");
}
}

View File

@ -54,7 +54,7 @@ public class HttpExporterResourceTests extends AbstractPublishableHttpResourceTe
* kibana, logstash, beats
*/
private final int EXPECTED_TYPES = MonitoringTemplateUtils.NEW_DATA_TYPES.length;
private final int EXPECTED_TEMPLATES = 7;
private final int EXPECTED_TEMPLATES = 6;
private final int EXPECTED_WATCHES = 4;
private final RestClient client = mock(RestClient.class);

View File

@ -357,7 +357,7 @@ public class HttpExporterTests extends ESTestCase {
equalTo(version + typeMappings.size() + templates.size() + pipelines.size() + watcherCheck.size() + bwc.size()));
assertThat(version, equalTo(1));
assertThat(typeMappings, hasSize(MonitoringTemplateUtils.NEW_DATA_TYPES.length));
assertThat(templates, hasSize(7));
assertThat(templates, hasSize(6));
assertThat(pipelines, hasSize(useIngest ? 1 : 0));
assertThat(watcherCheck, hasSize(clusterAlertManagement ? 1 : 0));
assertThat(watches, hasSize(clusterAlertManagement ? ClusterAlertsUtil.WATCH_IDS.length : 0));