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

Improve Health Status of security-auditlog Index in Single Node Clusters #5030

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Ganesh-RB
Copy link

@Ganesh-RB Ganesh-RB commented Jan 15, 2025

Description

Bug Fix: Improve Health Status of security-auditlog Index in Single Node Clusters

This pull request addresses an issue where the security-auditlog index was showing a yellow health status in single node clusters. The problem was caused by the use of indexrequest default settings, which were not optimal for single node environments.

Changes:

  • Modified the replica settings for the security-auditlog index to:
    {
      "index.number_of_shards": 1,
      "index.auto_expand_replicas": "0-1"
    }
    
    

Issues Resolved

Testing

  • Created a single node cluster and verified that the security-auditlog index health changed from yellow to green.
  • Confirmed that the new settings do not negatively impact multi-node clusters.

Check List

  • New functionality includes testing
  • New functionality has been documented
  • New Roles/Permissions have a corresponding security dashboards plugin PR
  • API changes companion pull request created
  • Commits are signed per the DCO using --signoff

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.

.isExists();
}

private boolean createIndexIfAbsent(String indexName){
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: this could be moved to common/utils class.

@Ganesh-RB Ganesh-RB force-pushed the auditlog_index_health_single_node_case branch from 7d60d06 to 0bceb07 Compare January 23, 2025 19:32
@@ -64,6 +88,12 @@ public boolean doStore(final AuditMessage msg, String indexName) {

try (StoredContext ctx = threadPool.getThreadContext().stashContext()) {
try {
boolean ok = createIndexIfAbsent(indexName);
if (!ok) {
log.error("Server not acknowledge for creation of index {}", indexName);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: error message could be something like

 Failed to create index [index_name]

}

@Override
public void close() throws IOException {

}

private boolean createIndexIfAbsent(String indexName) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: cover this function in UTs

log.info("Index {} created?: {}", indexName, ok);
return ok;
} catch (ResourceAlreadyExistsException resourceAlreadyExistsException) {
log.info("Index {} already exists", indexName);
Copy link
Member

@cwperks cwperks Jan 24, 2025

Choose a reason for hiding this comment

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

Shouldn't lastUsedIndexName be set here?

What happens in the case of node reboot and the audit log index exists? lastUsedIndexName would be null when the node starts. Shouldn't this catch clause be used to populate it if it is null and the index already exists?

Copy link
Member

@cwperks cwperks Jan 24, 2025

Choose a reason for hiding this comment

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

FYI I experimented around with passing the clusterService to the internal opensearch sinks which can be used to check if an index exists without having to issue an Exists request. Take a look at the change on my fork cwperks#44. That change also shows an example of how to use the integration test framework in this repo to write an integration test for this case.

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.

4 participants