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

Elasticsearch v8 Support #1215

Merged
merged 6 commits into from
Aug 31, 2023
Merged

Elasticsearch v8 Support #1215

merged 6 commits into from
Aug 31, 2023

Conversation

huseyinbabal
Copy link
Contributor

@huseyinbabal huseyinbabal commented Aug 28, 2023

Description

Changes proposed in this pull request:

  • Added v8 support to Elasticsearch sink

Testing

v8 Test

  • Follow doc here to test Botkube against es v8 cluster

v7 Test

  • Create v7 cluster (You can use Elastic Cloud)
  • Configure and run botkube to ship events to es.

In both tests, you shouldn't see 400 errors.

Related issue(s)

#887

@huseyinbabal huseyinbabal marked this pull request as ready for review August 29, 2023 11:42
@huseyinbabal huseyinbabal requested review from PrasadG193 and a team as code owners August 29, 2023 11:42
@huseyinbabal huseyinbabal linked an issue Aug 29, 2023 that may be closed by this pull request
@pkosiec pkosiec self-assigned this Aug 30, 2023
Copy link
Member

@pkosiec pkosiec left a comment

Choose a reason for hiding this comment

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

Works well for both v7 and v8 👍 Please see one small comment before merge. Thanks!

Comment on lines 165 to 171
if err != nil && err.(*elastic.Error).Details.Type != "resource_already_exists_exception" {
return fmt.Errorf("while creating index: %w", err)
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if err != nil && err.(*elastic.Error).Details.Type != "resource_already_exists_exception" {
return fmt.Errorf("while creating index: %w", err)
}
if err != nil && elastic.ErrorReason(err) != "resource_already_exists_exception" {
return fmt.Errorf("while creating index: %w", err)
}

BTW please move this reason to consts 👍

return fmt.Errorf("while creating index: %w", err)
}
}

// Send event to els
_, err = e.client.Index().Index(indexName).Type(indexCfg.Type).BodyJson(event).Do(ctx)
indexService := e.client.Index().Index(indexName)
if strings.HasPrefix(e.clusterVersion, "7.") {
Copy link
Member

@pkosiec pkosiec Aug 30, 2023

Choose a reason for hiding this comment

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

BTW, shouldn't we also check for versions below? E.g. 6? WDYT?
Maybe we can split this string by ., parse the first item as int and see whether is 7 or below?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good question :) Let me add check for that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pkosiec also added test 3eaf756

@huseyinbabal huseyinbabal added the enhancement New feature or request label Aug 31, 2023
Copy link
Member

@pkosiec pkosiec left a comment

Choose a reason for hiding this comment

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

Thank you @huseyinbabal! Looks great 🚀

@huseyinbabal huseyinbabal merged commit 6a97a68 into kubeshop:main Aug 31, 2023
14 checks passed
@huseyinbabal huseyinbabal deleted the es-v8 branch August 31, 2023 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update Elasticsearch integration to support ELS v8
2 participants