Github user cestella commented on a diff in the pull request:
https://github.com/apache/metron/pull/793#discussion_r143473906
--- Diff:
metron-platform/metron-elasticsearch/src/main/java/org/apache/metron/elasticsearch/utils/ElasticsearchUtils.java
---
@@ -45,15 +49,30 @@ public static SimpleDateFormat
getIndexFormat(Map<String, Object> globalConfig)
return DATE_FORMAT_CACHE.get().computeIfAbsent(format,
SimpleDateFormat::new);
}
+ /**
+ * Builds the name of an Elasticsearch index.
+ * @param sensorType The sensor type; bro, yaf, snort, ...
+ * @param indexPostfix The index postfix; most often a formatted date.
+ * @param configurations User-defined configuration for the writers.
+ */
public static String getIndexName(String sensorType, String
indexPostfix, WriterConfiguration configurations) {
String indexName = sensorType;
if (configurations != null) {
indexName = configurations.getIndex(sensorType);
}
- indexName = indexName + "_index_" + indexPostfix;
+ indexName = indexName + getIndexDelimiter() + "_" + indexPostfix;
return indexName;
}
+ /**
+ * Returns the delimiter that is appended to the user-defined index name
to separate
+ * the index's date postfix. For example, if the user-defined index
name is 'bro'
+ * and the delimiter is '_index_', then one likely index name is
'bro_index_2017.10.03.19'.
+ */
+ public static String getIndexDelimiter() {
--- End diff --
I'm more curious than opposed to this, but is there a strong reason why
this isn't just a `public static final String`?
---