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

Introduce ElasticSearch event logger for server events #5488

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

bowenliang123
Copy link
Contributor

@bowenliang123 bowenliang123 commented Oct 20, 2023

Why are the changes needed?

  • introduce new event logger type ELASTICSEARCH for server
  • send server events to the ElasticSearch index
  • support auto-created index with dynamic mapping type
  • use elastic4s 8.9.1 as ElasticSearch client for Scala, which depends on the ElasticSearch Java Client elasticsearch-rest-client 8.9.x.
    • License: elastic4s and elasticsearch-rest-client released with Apache Licence 2.0. elasticsearch-rest-client does not depends on the ElasticSearch server library.
  • Tested with the latest release version of ElasticSearch server 7.x and 8.x

How was this patch tested?

  • Add some test cases that check the changes thoroughly including negative and positive cases if possible

  • Add screenshots for manual tests if appropriate

  • Run test locally before make a pull request

Was this patch authored or co-authored using generative AI tooling?

No.

@cfmcgrady
Copy link
Contributor

cfmcgrady commented Oct 20, 2023

@wForget has made similar contributions in #1689, and we have several questions regarding the Elasticsearch license, see #1689 (comment).

@bowenliang123
Copy link
Contributor Author

@wForget has made similar contributions in #1689, and we've got some queries regarding the Elasticsearch license. see #1689 (comment)

Oh, thanks for raising this. Sounds like more investigation is required in the scope of licence to clarify the impact for high/low-level client and the runtime usage of ES server for testing.

@bowenliang123
Copy link
Contributor Author

Hi @tisonkun, may I have your opinion on these licence concerns?
From your experience in different ASF projects, is it all right to use and ship with the ElasticSearch client (high-level Java client may depend on ElasticSearch common modules) , while ElasticSearch may declare a modified version of Apache Licence?

@tisonkun
Copy link
Member

tisonkun commented Oct 23, 2023

@bowenliang123 Thanks for reaching out to me.

I'm sure that elasticsearch-rest-client can be used under Apache License 2.0.

For elasticsearch-java you referred, Elastic released it under Apache License 2.0. From the dependencies it includes, the final JAR should be compatible with Apache License 2.0 to use and convey.

@tisonkun
Copy link
Member

FYI Pulsar Elastic connector uses this API client - apache/pulsar#14805.

Although, you may check the dependencies doesn't include any ELv2 licensed code with a certain version.

@pan3793
Copy link
Member

pan3793 commented Oct 23, 2023

Currently, the PR only considers ES 8, right? Actually, bunches of vendors are sticky on ES 7.10 (the last version released under AL2) or older versions, I think we should at least support ES 7 too.

@bowenliang123
Copy link
Contributor Author

Currently, the PR only considers ES 8, right? Actually, bunches of vendors are sticky on ES 7.10 (the last version released under AL2) or older versions, I think we should at least support ES 7 too.

Sure. This PR can be changed to base on ES 7 client and testing.

@bowenliang123 bowenliang123 force-pushed the es-logger branch 2 times, most recently from 602cd77 to a7c9932 Compare October 25, 2023 07:51
@bowenliang123 bowenliang123 requested a review from pan3793 October 26, 2023 15:08
@codecov-commenter
Copy link

codecov-commenter commented Oct 27, 2023

Codecov Report

Attention: Patch coverage is 0% with 110 lines in your changes missing coverage. Please review.

Project coverage is 0.00%. Comparing base (afc21d3) to head (dbb5bb1).
Report is 132 commits behind head on master.

Files with missing lines Patch % Lines
...nts/handler/ElasticSearchLoggingEventHandler.scala 0.00% 60 Missing ⚠️
...in/scala/org/apache/kyuubi/config/KyuubiConf.scala 0.00% 25 Missing ⚠️
...che/kyuubi/events/ServerEventHandlerRegister.scala 0.00% 14 Missing ⚠️
...ndler/ServerElasticSearchLoggingEventHandler.scala 0.00% 7 Missing ⚠️
...rg/apache/kyuubi/events/EventHandlerRegister.scala 0.00% 3 Missing ⚠️
...ala/org/apache/kyuubi/events/EventLoggerType.scala 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master   #5488    +/-   ##
=======================================
  Coverage    0.00%   0.00%            
=======================================
  Files         677     679     +2     
  Lines       41902   42010   +108     
  Branches     5721    5730     +9     
=======================================
- Misses      41902   42010   +108     

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

@bowenliang123
Copy link
Contributor Author

Tested with ElasticSearch server 7.x and 8.x. Now use the elastic4s lib for ES scala client shipping with ElasticSearch Java Client. Both elastic4s 7.x or 8.x uses elasticsearch-rest-client 8.x. So elastic4s 8.x is preferred.
Have a check on the implementation and clarification in PR description. cc @pan3793 @wForget

@github-actions github-actions bot added the kind:infra license, community building, project builds, asf infra related, etc. label Oct 28, 2023
@bowenliang123 bowenliang123 marked this pull request as ready for review October 28, 2023 00:52
private val objectMapper = new ObjectMapper().registerModule(DefaultScalaModule)

override def apply(event: KyuubiEvent): Unit = {
val fields = {
Copy link
Member

Choose a reason for hiding this comment

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

This does not seem to be a good solution that serializes the event into a json string and then deserializes it again into a map. elastic4s provides the indexInto(indexId).doc(XXX) method to directly index json string.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tried, but not working. Due to the nested fields that I have to serialize-deserialize-map again. Tried to implement a method for generating flat json, but not serializing properly.

Copy link
Member

Choose a reason for hiding this comment

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

but not serializing properly.

Are there any specific errors?


class ServerElasticSearchLoggingEventHandlerSuiteForEs7
extends ServerElasticSearchLoggingEventHandlerSuite {
override val imageTag = "7.17.14"
Copy link
Member

Choose a reason for hiding this comment

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

does it support ES 6?

a survey from another team in my company shows that we have bunches of customers still using ES 6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:build kind:documentation Documentation is a feature! kind:infra license, community building, project builds, asf infra related, etc. module:common module:events module:server
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants