diff --git a/README.md b/README.md index 2591929..29be9c7 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,8 @@ Elasticsearch is used when `STORAGE=elasticsearch`. * `ES_INDEX_PREFIX`: index prefix of Jaeger indices. By default unset. * `ES_TIME_RANGE`: How far in the past the job should look to for spans, the maximum and default is `24h`. Any value accepted by [date-math](https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#date-math) can be used here, but the anchor is always `now`. + * `ES_USE_ALIASES`: Set to true to use index alias names to read from and write to. + Usually required when using rollover indices. Example usage: diff --git a/jaeger-spark-dependencies-elasticsearch/src/main/java/io/jaegertracing/spark/dependencies/elastic/ElasticsearchDependenciesJob.java b/jaeger-spark-dependencies-elasticsearch/src/main/java/io/jaegertracing/spark/dependencies/elastic/ElasticsearchDependenciesJob.java index 42426c0..c629e94 100644 --- a/jaeger-spark-dependencies-elasticsearch/src/main/java/io/jaegertracing/spark/dependencies/elastic/ElasticsearchDependenciesJob.java +++ b/jaeger-spark-dependencies-elasticsearch/src/main/java/io/jaegertracing/spark/dependencies/elastic/ElasticsearchDependenciesJob.java @@ -60,6 +60,7 @@ public static final class Builder { Boolean nodesWanOnly = Boolean.parseBoolean(Utils.getEnv("ES_NODES_WAN_ONLY", "false")); String indexPrefix = Utils.getEnv("ES_INDEX_PREFIX", null); String spanRange = Utils.getEnv("ES_TIME_RANGE", "24h"); + Boolean useAliases = Boolean.parseBoolean(Utils.getEnv("ES_USE_ALIASES", "false")); final Map sparkProperties = new LinkedHashMap<>(); @@ -166,6 +167,7 @@ private static String getSystemPropertyAsFileResource(String key) { private final SparkConf conf; private final String indexPrefix; private final String spanRange; + private final Boolean useAliases; ElasticsearchDependenciesJob(Builder builder) { this.day = builder.day; @@ -195,6 +197,7 @@ private static String getSystemPropertyAsFileResource(String key) { } this.indexPrefix = builder.indexPrefix; this.spanRange = builder.spanRange; + this.useAliases = builder.useAliases; } /** @@ -209,7 +212,21 @@ private static String prefix(String prefix) { } public void run(String peerServiceTag) { - run(indexDate("jaeger-span"), indexDate("jaeger-dependencies") ,peerServiceTag); + + String[] readIndices; + String[] writeIndex; + + // use alias indices common when using index rollover + if (this.useAliases) { + readIndices = new String[]{prefix(indexPrefix) + "jaeger-span-read", prefixBefore19(indexPrefix) + "jaeger-span-read"}; + writeIndex = new String[] {prefix(indexPrefix) + "jaeger-dependencies-write", prefixBefore19(indexPrefix) + "jaeger-dependencies-write"}; + } + else { + readIndices = indexDate("jaeger-span"); + writeIndex = indexDate("jaeger-dependencies"); + } + + run(readIndices, writeIndex, peerServiceTag); } String[] indexDate(String index) {