Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explore how to use the ISM features from another plugin #12

Open
1 of 5 tasks
AlexRuiz7 opened this issue Jul 11, 2024 · 3 comments
Open
1 of 5 tasks

Explore how to use the ISM features from another plugin #12

AlexRuiz7 opened this issue Jul 11, 2024 · 3 comments
Labels
level/task Task issue type/enhancement Enhancement issue

Comments

@AlexRuiz7
Copy link
Member

AlexRuiz7 commented Jul 11, 2024

Description

The initialization plugin needs to ensure that the index templates, indices and ISM policies are created during startup.

In the Spike, we demonstrated how to create an index using custom mappings and settings, but not how to do the same with the Index Templates or the ISM policies. This issue aims to close this gap.

We need to explore how to create index templates (using the Index Management plugin), as a way to overcome the problems stated above. The strategy of creating single indices with mappings and settings only works for that particular index, and won't apply to rotated stream indices.

OpenSearch Playground has 2 composable index templates. Searching the name .opensearch-sap-detectors-queries-index-template, I found out there is an API at opensearch.admin.indices.template.put.

  1. playground.opensearch.org
  2. DetectorMonitorConfig.java#L22
  3. RuleTopicIndices.java#L16
  4. PutComposableIndexTemplateAction.java#L61

Originally posted by @AlexRuiz7 in #11 (comment)

Tasks

  • Explore how to create index templates programmatically
  • Explore how to create composable index templates programmatically
  • Explore how to create ISM policies programmatically
  • Explore how to create stuff above from JSON files (same format as using the REST API)
  • Add functionality to the plugin
@AlexRuiz7 AlexRuiz7 added level/task Task issue type/enhancement Enhancement issue labels Jul 11, 2024
@AlexRuiz7 AlexRuiz7 self-assigned this Jul 11, 2024
@AlexRuiz7
Copy link
Member Author

AlexRuiz7 commented Jul 11, 2024

I managed to create a very simple index template on startup.

public void putTemplate(ActionListener<AcknowledgedResponse> actionListener) {
    String indexTemplate = "wazuh";
    PutIndexTemplateRequest putRequest = new PutIndexTemplateRequest()
            .name(indexTemplate)
            .patterns(List.of("wazuh-*"));
    try {
        client.admin().indices().putTemplate(putRequest, actionListener);

    } catch (Exception e) {
        String errorMessage = new MessageFormat(
                "failed to create index template [{0}]",
                Locale.ROOT
        ).format(indexTemplate);
        log.error(errorMessage, e);
        throw new IllegalStateException(errorMessage, e);
    }
}

image

[2024-07-11T13:31:50,192][INFO ][o.w.s.WazuhIndexerSetupPlugin] [integTest-0] template created

We need no improve this approach by reading the index templates from the file system.

@wazuhci wazuhci moved this to In progress in Release 5.0.0 Jul 11, 2024
@wazuhci wazuhci moved this from In progress to On hold in Release 5.0.0 Aug 5, 2024
@wazuhci wazuhci moved this from On hold to In progress in Release 5.0.0 Aug 23, 2024
@wazuhci wazuhci moved this from In progress to On hold in Release 5.0.0 Aug 26, 2024
@AlexRuiz7 AlexRuiz7 changed the title Integrate ISM features (index templates, policies) Explore how to use the ISM features from another plugin Sep 4, 2024
@AlexRuiz7
Copy link
Member Author

Moved to the Feature Complete stage.

@AlexRuiz7 AlexRuiz7 removed their assignment Nov 4, 2024
@wazuhci wazuhci moved this from On hold to Backlog in Release 5.0.0 Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
level/task Task issue type/enhancement Enhancement issue
Projects
Status: Backlog
Development

No branches or pull requests

1 participant