Skip to content

[Rule-based Auto-tagging] Add autotagging label resolving logic for multiple attributes#19486

Merged
jainankitk merged 3 commits intoopensearch-project:mainfrom
ruai0511:security-label-exact-match
Oct 1, 2025
Merged

[Rule-based Auto-tagging] Add autotagging label resolving logic for multiple attributes#19486
jainankitk merged 3 commits intoopensearch-project:mainfrom
ruai0511:security-label-exact-match

Conversation

@ruai0511
Copy link
Copy Markdown
Contributor

@ruai0511 ruai0511 commented Sep 30, 2025

Description

In the past, the auto tagging label resolving logic is only suitable for single attribute evaluation. Since we're adding more attributes into the feature now (username, role, index_pattern), we need a more comprehensive logic to find the best suited rule and label.

Feature documentation: https://docs.opensearch.org/latest/tuning-your-cluster/availability-and-recovery/rule-based-autotagging/autotagging/

Main classes & functions introduced:

  1. Entry Point – evaluateLabel
public Optional<String> evaluateLabel(List<AttributeExtractor<String>> attributeExtractors)
  • Sorts extractors by priority.
  • Delegates resolution to FeatureValueResolver.resolve(...).
  • Returns the final label from FeatureValueResolutionResult.resolveLabel().
  1. Central class to evaluate candidate values – FeatureValueResolver
  • Iterates over each AttributeExtractor.
  • For each extractor, delegates to FeatureValueCollector.
  • Maintains a running intersection across extractors (AND logic between attributes).
  1. Extracting values for a single attribute– FeatureValueCollector
  • Each extractor may have subfields (e.g., "principal.username", "principal.role").
  • If multiple values are extracted, merges them according to the extractor’s logical operator (OR/AND)

Related Issues

Resolves #[Issue number to be closed when this PR is merged]

Check List

  • Functionality includes testing.
  • API changes companion pull request created, if applicable.
  • Public documentation issue/PR created, if applicable.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@ruai0511 ruai0511 requested a review from a team as a code owner September 30, 2025 21:35
@ruai0511 ruai0511 force-pushed the security-label-exact-match branch from 53fdb71 to b3c9653 Compare September 30, 2025 21:37
@github-actions
Copy link
Copy Markdown
Contributor

❌ Gradle check result for b3c9653: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@ruai0511 ruai0511 force-pushed the security-label-exact-match branch from b3c9653 to c4ce839 Compare September 30, 2025 22:25
@github-actions
Copy link
Copy Markdown
Contributor

❌ Gradle check result for c4ce839: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@ruai0511 ruai0511 force-pushed the security-label-exact-match branch from c4ce839 to 6fc3ea6 Compare September 30, 2025 22:55
@github-actions
Copy link
Copy Markdown
Contributor

❌ Gradle check result for 6fc3ea6: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@ruai0511 ruai0511 force-pushed the security-label-exact-match branch from 6fc3ea6 to 12c5c98 Compare September 30, 2025 23:26
@github-actions
Copy link
Copy Markdown
Contributor

❌ Gradle check result for 12c5c98: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@ruai0511 ruai0511 force-pushed the security-label-exact-match branch from 12c5c98 to 43b2f02 Compare September 30, 2025 23:49
@ruai0511 ruai0511 force-pushed the security-label-exact-match branch 2 times, most recently from 139da8b to 291e67a Compare October 1, 2025 00:33
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Oct 1, 2025

❌ Gradle check result for 291e67a: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

@sandeshkr419
Copy link
Copy Markdown
Member

@ruai0511 Do you want to iterate this to green:

Execution failed for task ':modules:autotagging-commons:common:dependencyLicenses'.
> Missing SHA for commons-collections4-4.5.0.jar. Run "gradle updateSHAs" to create them

cc: @kaushalmahi12

Signed-off-by: Ruirui Zhang <mariazrr@amazon.com>
Signed-off-by: Ruirui Zhang <mariazrr@amazon.com>
@ruai0511 ruai0511 force-pushed the security-label-exact-match branch from 869da6e to 31fd4fb Compare October 1, 2025 18:22
@jainankitk
Copy link
Copy Markdown
Contributor

@ruai0511 - Can you look into precommit failure:

> Task :modules:lang-painless:compileJava

> Task :example-plugins:stream-transport-example:missingJavadoc
> Task :modules:aggs-matrix-stats:missingJavadoc
/home/runner/work/OpenSearch/OpenSearch/modules/autotagging-commons/common/src/main/java/org/opensearch/rule/RuleUtils.java:149: error: cannot find symbol
        return !attribute.getPrioritizedSubfields().isEmpty();
                         ^

  symbol:   method getPrioritizedSubfields()
  location: variable attribute of type Attribute
1 error
> Task :modules:autotagging-commons:common:compileJava FAILED

> Task :example-plugins:system-search-processor:missingJavadoc
> Task :client:benchmark:generatePomFileForNebulaPublication
> Task :server:javadoc


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':modules:autotagging-commons:common:compileJava'.
> Compilation failed; see the compiler output below.
  /home/runner/work/OpenSearch/OpenSearch/modules/autotagging-commons/common/src/main/java/org/opensearch/rule/RuleUtils.java:149: error: cannot find symbol
          return !attribute.getPrioritizedSubfields().isEmpty();
                           ^
    symbol:   method getPrioritizedSubfields()
    location: variable attribute of type Attribute
  1 error

* Try:
> Check your code and dependencies to fix the compilation error(s)
> Run with --scan to get full insights.

BUILD FAILED in 4m 35s

@ruai0511 ruai0511 force-pushed the security-label-exact-match branch from 31fd4fb to 23d82c0 Compare October 1, 2025 18:36
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Oct 1, 2025

❌ Gradle check result for 23d82c0: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Signed-off-by: Ruirui Zhang <mariazrr@amazon.com>
@ruai0511 ruai0511 force-pushed the security-label-exact-match branch from 23d82c0 to 4fb5ab2 Compare October 1, 2025 19:18
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Oct 1, 2025

❕ Gradle check result for 4fb5ab2: UNSTABLE

Please review all flaky tests that succeeded after retry and create an issue if one does not already exist to track the flaky failure.

@jainankitk jainankitk merged commit ed0c3a4 into opensearch-project:main Oct 1, 2025
31 checks passed
@codecov
Copy link
Copy Markdown

codecov bot commented Oct 1, 2025

Codecov Report

❌ Patch coverage is 79.64602% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.01%. Comparing base (32b6873) to head (4fb5ab2).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...earch/rule/labelresolver/FeatureValueResolver.java 88.23% 2 Missing and 4 partials ⚠️
...earch/rule/storage/DefaultAttributeValueStore.java 54.54% 5 Missing ⚠️
...opensearch/plugin/wlm/AutoTaggingActionFilter.java 58.33% 3 Missing and 2 partials ⚠️
...h/rule/attribute_extractor/AttributeExtractor.java 0.00% 3 Missing ⚠️
...opensearch/rule/InMemoryRuleProcessingService.java 81.81% 1 Missing and 1 partial ⚠️
...g/opensearch/rule/storage/AttributeValueStore.java 0.00% 1 Missing ⚠️
...wlm/rule/attribute_extractor/IndicesExtractor.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #19486      +/-   ##
============================================
+ Coverage     72.99%   73.01%   +0.01%     
+ Complexity    70416    70414       -2     
============================================
  Files          5708     5711       +3     
  Lines        322492   322585      +93     
  Branches      46704    46716      +12     
============================================
+ Hits         235412   235536     +124     
+ Misses        68161    68065      -96     
- Partials      18919    18984      +65     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants