Skip to content

[Behavioral Analytics] Add a final_pipeline to event data streams. #95198

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

Merged
merged 10 commits into from
Apr 18, 2023

Conversation

afoucret
Copy link
Contributor

@afoucret afoucret commented Apr 12, 2023

Description:

  • Add a final_pipeline to behavioral analytics events data streams
  • Process URLs in the event (page.url, page.referrer and search.results.items[*].page.url
  • Mapping update
    • Update page.url to be an object
    • Update page.referrer to be an object
    • Update search.results.items[*].page.url to be an object

Other:

@elasticsearchmachine elasticsearchmachine added external-contributor Pull request authored by a developer outside the Elasticsearch team v8.8.0 labels Apr 12, 2023
@@ -9,7 +9,8 @@
"refresh_interval": "1s",
"number_of_shards": 1,
"number_of_replicas": 0,
"auto_expand_replicas": "0-1"
"auto_expand_replicas": "0-1",
"final_pipeline": "behavioral_analytics-events-final_pipeline"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ℹ️ Updating the template to set the pipeline (as a final_pipeline)

@afoucret afoucret changed the title Pipeline registry [Behavioral Analytics] Add a final_pipeline to event data streams. Apr 12, 2023
@@ -0,0 +1,51 @@
{
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ℹ️ The pipeline that will installed automatically when the cluster start by the AnalyticsIngestPipelineRegistry

@@ -0,0 +1,201 @@
/*
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ℹ️ This class may be moved to xpack core but I preferred to keep the code in our utils for now.

Copy link
Member

Choose a reason for hiding this comment

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

From my perspective, it makes sense to move it to x-pack/core from the beginning.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would prefer to move it later because it will require other teams to validate which can add an additional delay to gets reviewed.

Copy link
Member

Choose a reason for hiding this comment

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

I am OK with moving it later considering we're very close to FF.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kderusso Being very close to FF is indeed part of my rationale here.

@afoucret afoucret force-pushed the pipeline-registry branch 2 times, most recently from 0945429 to fd92bce Compare April 13, 2023 13:15
package org.elasticsearch.xpack.application.analytics;

public class AnalyticsConstants {
// Data stream related constants.
Copy link
Member

Choose a reason for hiding this comment

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

👍

Copy link
Member

@tutelaris tutelaris left a comment

Choose a reason for hiding this comment

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

Great job! 🚀

@@ -62,16 +62,84 @@
"page": {
"properties": {
"url": {
"ignore_above": 1024,
"type": "keyword"
"properties": {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ℹ️ URLs are now object into the mapping (previously strings).

@afoucret afoucret marked this pull request as ready for review April 17, 2023 11:46
@elasticsearchmachine elasticsearchmachine added the needs:triage Requires assignment of a team area label label Apr 17, 2023
@HiDAl HiDAl added >feature cloud-deploy Publish cloud docker image for Cloud-First-Testing :EnterpriseSearch/Application Enterprise Search Team:Enterprise Search Meta label for Enterprise Search team and removed needs:triage Requires assignment of a team area label labels Apr 17, 2023
@HiDAl
Copy link

HiDAl commented Apr 17, 2023

assigning to the right team

@elasticsearchmachine
Copy link
Collaborator

Hi @afoucret, I've created a changelog YAML for you.

@afoucret afoucret removed external-contributor Pull request authored by a developer outside the Elasticsearch team cloud-deploy Publish cloud docker image for Cloud-First-Testing labels Apr 17, 2023
Copy link
Member

@kderusso kderusso left a comment

Choose a reason for hiding this comment

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

👍

@@ -0,0 +1,201 @@
/*
Copy link
Member

Choose a reason for hiding this comment

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

I am OK with moving it later considering we're very close to FF.

Copy link
Member

@carlosdelest carlosdelest left a comment

Choose a reason for hiding this comment

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

LGTM. Some lang level nitpicking.

I think we would need some review from the Platform teams on the approach for the PipelineRegistry - you probably did that already - to ensure we're not reinventing the wheel.


package org.elasticsearch.xpack.application.analytics;

public class AnalyticsConstants {
Copy link
Member

Choose a reason for hiding this comment

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

can we add a private constructor to make the class non-instantiable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.


package org.elasticsearch.xpack.application.analytics;

public class AnalyticsConstants {
Copy link
Member

Choose a reason for hiding this comment

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

I'm not super fond of making a specific class for holding constants that are related to different concerns in the codebase.

Can't these constants be included into already existing classes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will probably refactor this in the near future to create an AnalytisEventDataStream class with more utils methods.
I propose to keep it for now and remove it later since these constants does not clearly belong to one of the existing class.

if (ingestPipelineExists(state, newPipeline.getId())) {
IngestMetadata ingestMetadata = state.metadata().custom(IngestMetadata.TYPE);
PipelineConfiguration existingPipeline = ingestMetadata.getPipelines().get(newPipeline.getId());
boolean newPipelineHasVersion = Objects.isNull(newPipeline.getVersion()) == false;
Copy link
Member

Choose a reason for hiding this comment

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

why not a direct comparison with null? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It makes more sense right now because the code is

boolean newPipelineHasVersion = Objects.nonNull(newPipeline.getVersion())

It removes the need of == and I find it easier to read.

* @param pipelineId the pipeline that failed to be created.
* @param e The exception that caused the failure.
*/
protected void onPutPipelineFailure(String pipelineId, Exception e) {
Copy link
Member

Choose a reason for hiding this comment

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

Is this method meant to be overriden by subclasses? We might use other visibility otherwise

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can see valid use case for overriding it.
The same is done in the template registry.

@afoucret afoucret force-pushed the pipeline-registry branch from a3ba148 to 6233ed5 Compare April 18, 2023 06:34
@afoucret afoucret force-pushed the pipeline-registry branch from 6233ed5 to 4d39402 Compare April 18, 2023 06:36
@afoucret afoucret merged commit e03378f into elastic:main Apr 18, 2023
yuliacech added a commit to elastic/kibana that referenced this pull request May 9, 2023
## Summary
Fixes #156015
Fixes #156014
Fixes #155924 
Fixes #155914

The Ingest Pipelines tests were broken because of a new pipeline
introduced in elastic/elasticsearch#95198 but
there was a fix added in
elastic/elasticsearch#95621. The last PR fixes
the error where it was not possible to delete the pipeline in the tests.
This PR unskips the tests since they should now work as expected.
yuliacech added a commit to yuliacech/kibana that referenced this pull request May 10, 2023
## Summary
Fixes elastic#156015
Fixes elastic#156014
Fixes elastic#155924
Fixes elastic#155914

The Ingest Pipelines tests were broken because of a new pipeline
introduced in elastic/elasticsearch#95198 but
there was a fix added in
elastic/elasticsearch#95621. The last PR fixes
the error where it was not possible to delete the pipeline in the tests.
This PR unskips the tests since they should now work as expected.

(cherry picked from commit 32bc5c7)

# Conflicts:
#	x-pack/test/accessibility/apps/ingest_node_pipelines.ts
#	x-pack/test/functional/apps/ingest_pipelines/ingest_pipelines.ts
yuliacech added a commit to elastic/kibana that referenced this pull request May 10, 2023
…157257)

# Backport

This will backport the following commits from `main` to `8.8`:
- [[Ingest Pipelines] Unskip functional and a11y tests
(#157173)](#157173)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Yulia
Čech","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-05-09T16:08:15Z","message":"[Ingest
Pipelines] Unskip functional and a11y tests (#157173)\n\n##
Summary\r\nFixes
https://github.com/elastic/kibana/issues/156015\r\nFixes
https://github.com/elastic/kibana/issues/156014\r\nFixes
#155924 \r\nFixes
https://github.com/elastic/kibana/issues/155914\r\n\r\nThe Ingest
Pipelines tests were broken because of a new pipeline\r\nintroduced in
elastic/elasticsearch#95198 but\r\nthere was a
fix added in\r\nhttps://github.com/elastic/elasticsearch/pull/95621. The
last PR fixes\r\nthe error where it was not possible to delete the
pipeline in the tests.\r\nThis PR unskips the tests since they should
now work as
expected.","sha":"32bc5c77bbe5b17215715ea56c4a13593855323c","branchLabelMapping":{"^v8.9.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Deployment
Management","release_note:skip","Feature:Ingest Node
Pipelines","v8.8.0","v8.9.0"],"number":157173,"url":"https://github.com/elastic/kibana/pull/157173","mergeCommit":{"message":"[Ingest
Pipelines] Unskip functional and a11y tests (#157173)\n\n##
Summary\r\nFixes
https://github.com/elastic/kibana/issues/156015\r\nFixes
https://github.com/elastic/kibana/issues/156014\r\nFixes
#155924 \r\nFixes
https://github.com/elastic/kibana/issues/155914\r\n\r\nThe Ingest
Pipelines tests were broken because of a new pipeline\r\nintroduced in
elastic/elasticsearch#95198 but\r\nthere was a
fix added in\r\nhttps://github.com/elastic/elasticsearch/pull/95621. The
last PR fixes\r\nthe error where it was not possible to delete the
pipeline in the tests.\r\nThis PR unskips the tests since they should
now work as
expected.","sha":"32bc5c77bbe5b17215715ea56c4a13593855323c"}},"sourceBranch":"main","suggestedTargetBranches":["8.8"],"targetPullRequestStates":[{"branch":"8.8","label":"v8.8.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.9.0","labelRegex":"^v8.9.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/157173","number":157173,"mergeCommit":{"message":"[Ingest
Pipelines] Unskip functional and a11y tests (#157173)\n\n##
Summary\r\nFixes
https://github.com/elastic/kibana/issues/156015\r\nFixes
https://github.com/elastic/kibana/issues/156014\r\nFixes
#155924 \r\nFixes
https://github.com/elastic/kibana/issues/155914\r\n\r\nThe Ingest
Pipelines tests were broken because of a new pipeline\r\nintroduced in
elastic/elasticsearch#95198 but\r\nthere was a
fix added in\r\nhttps://github.com/elastic/elasticsearch/pull/95621. The
last PR fixes\r\nthe error where it was not possible to delete the
pipeline in the tests.\r\nThis PR unskips the tests since they should
now work as
expected.","sha":"32bc5c77bbe5b17215715ea56c4a13593855323c"}}]}]
BACKPORT-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:EnterpriseSearch/Application Enterprise Search >feature Team:Enterprise Search Meta label for Enterprise Search team v8.8.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants