Skip to content

Conversation

houssain-barouni
Copy link
Collaborator

@houssain-barouni houssain-barouni commented Jul 30, 2025

Description

Adds a new property in Elasticsearch and Opensearch exporters configuration

  • zeebe.broker.exporters.elasticsearch.args.index.template-priority
  • zeebe.broker.exporters.opensearch.args.index.template-priority

This configuration is set in zeebe records index templates priority setting, and it defaults to 20 when the configuration is not provided. 20 being the hardcoded value that was part of the existing index templates.

Checklist

Related issues

closes #36084

@houssain-barouni houssain-barouni requested a review from Copilot July 30, 2025 08:17
@github-actions github-actions bot added the component/zeebe Related to the Zeebe component/team label Jul 30, 2025
Copilot

This comment was marked as outdated.

@houssain-barouni houssain-barouni requested a review from Copilot July 30, 2025 09:18
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds configurable priority support for index templates in both Elasticsearch and OpenSearch exporters. It allows users to set custom priority values for Zeebe record index templates, providing better control over template precedence in environments with multiple index templates.

  • Adds priority configuration field to both exporters with validation (>= 0)
  • Implements a mutable builder pattern for Template DTOs to enable safe modification
  • Updates template readers to use the configured priority value when creating index templates

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
OpensearchExporterConfiguration.java Adds priority field with default value of 20 and getter/setter methods
ElasticsearchExporterConfiguration.java Adds templatePriority field with default value of 20 and getter/setter methods
OpensearchExporter.java Adds validation to ensure priority is non-negative
ElasticsearchExporter.java Adds validation to ensure templatePriority is non-negative
opensearch/.../dto/Template.java Implements MutableCopyBuilder pattern for safe template modification
elasticsearch/.../dto/Template.java Implements MutableCopyBuilder pattern for safe template modification
opensearch/.../TemplateReader.java Updates to use builder pattern and set priority from configuration
elasticsearch/.../TemplateReader.java Updates to use builder pattern and set templatePriority from configuration
OpensearchExporterTest.java Adds test for negative priority validation
ElasticsearchExporterTest.java Adds test for negative templatePriority validation
OpensearchExporterIT.java Adds integration tests for priority configuration and default behavior
ElasticsearchExporterIT.java Adds integration tests for templatePriority configuration and default behavior
Comments suppressed due to low confidence (3)

zeebe/exporters/opensearch-exporter/src/main/java/io/camunda/zeebe/exporter/opensearch/OpensearchExporterConfiguration.java:219

  • The field name 'priority' is inconsistent with the Elasticsearch exporter which uses 'templatePriority'. For consistency between the two exporters, consider renaming this field to 'templatePriority'.
    private int priority = DEFAULT_INDEX_TEMPLATE_PRIORITY;

zeebe/exporters/opensearch-exporter/src/main/java/io/camunda/zeebe/exporter/opensearch/OpensearchExporterConfiguration.java:237

  • The method name 'getPriority' is inconsistent with the Elasticsearch exporter which uses 'getTemplatePriority'. For consistency between the two exporters, consider renaming this method to 'getTemplatePriority'.
    public int getPriority() {

zeebe/exporters/opensearch-exporter/src/main/java/io/camunda/zeebe/exporter/opensearch/OpensearchExporterConfiguration.java:241

  • The method name 'setPriority' is inconsistent with the Elasticsearch exporter which uses 'setTemplatePriority'. For consistency between the two exporters, consider renaming this method to 'setTemplatePriority'.
    public void setPriority(final int priority) {

aliases.clear();
aliases.put(aliasName, Collections.emptyMap());
})
.withPriority(Long.valueOf(config.getPriority()))
Copy link
Preview

Copilot AI Jul 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using Long.valueOf() for autoboxing is unnecessary. Since getPriority() returns an int, you can cast directly to long: (long) config.getPriority().

Suggested change
.withPriority(Long.valueOf(config.getPriority()))
.withPriority((long) config.getPriority())

Copilot uses AI. Check for mistakes.

aliases.clear();
aliases.put(aliasName, Collections.emptyMap());
})
.withPriority(Long.valueOf(config.index.getTemplatePriority()))
Copy link
Preview

Copilot AI Jul 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using Long.valueOf() for autoboxing is unnecessary. Since getTemplatePriority() returns an int, you can cast directly to long: (long) config.index.getTemplatePriority().

Suggested change
.withPriority(Long.valueOf(config.index.getTemplatePriority()))
.withPriority((long) config.index.getTemplatePriority())

Copilot uses AI. Check for mistakes.

@houssain-barouni houssain-barouni added the backport main Forward-port a pull request to main label Jul 30, 2025
@houssain-barouni houssain-barouni requested a review from a team July 30, 2025 10:41
@houssain-barouni houssain-barouni marked this pull request as ready for review July 30, 2025 10:42
Copy link
Contributor

@RomanJRW RomanJRW left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some small comments but generally LGTM 👍

@github-actions github-actions bot added component/operate Related to the Operate component/team component/tasklist Related to the Tasklist component/team component/optimize Related to Optimize component/team labels Jul 31, 2025
@@ -896,6 +896,7 @@
#
# numberOfShards: 3
# numberOfReplicas: 0
# templatePriority: 100
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ should this not be the default of 20 then?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is just an example, like the number of shards above is not the default one

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting, I thought we always aimed to match these templates up to the default values. But all good, no big deal 👍

@@ -978,6 +979,7 @@
#
# numberOfShards: 3
# numberOfReplicas: 0
# templatePriority: 100
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

@@ -831,6 +832,7 @@
#
# numberOfShards: 3
# numberOfReplicas: 0
# templatePriority: 100
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above in this file too

@houssain-barouni houssain-barouni added the deploy-preview Requests creation of a Preview Environment for a PR label Aug 5, 2025
@houssain-barouni houssain-barouni added this pull request to the merge queue Aug 7, 2025
Merged via the queue into stable/8.7 with commit 78e03a4 Aug 7, 2025
71 checks passed
@houssain-barouni houssain-barouni deleted the hb-36084 branch August 7, 2025 15:07
@backport-action
Copy link
Collaborator

Created backport PR for main:

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin backport-36207-to-main
git worktree add --checkout .worktree/backport-36207-to-main backport-36207-to-main
cd .worktree/backport-36207-to-main
git reset --hard HEAD^
git cherry-pick -x 3816688dd321d5f68018e55bdb12f4d5bcb40352 42980cbaff84bfaae5b6598f2ecd86c090e30eec 71a40d3a2bb67e111baeedefce61a7d67230bb06
git push --force-with-lease

github-merge-queue bot pushed a commit that referenced this pull request Aug 7, 2025
…ndex templates (#36573)

# Description
Backport of #36207 to `main`.

relates to #36084
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport main Forward-port a pull request to main component/operate Related to the Operate component/team component/optimize Related to Optimize component/team component/tasklist Related to the Tasklist component/team component/zeebe Related to the Zeebe component/team deploy-preview Requests creation of a Preview Environment for a PR version:dryrun-8.8.0-alpha6-rc999 version:8.8.0-alpha8-rc1 version:8.8.0-alpha8
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enable configurable priority for zeebe-record Index templates (8.7 & 8.8)
3 participants