Skip to content

[Trendmicro Vision One] - Fixed cursor & pagination logic for "detections" data stream - #12916

Merged
ShourieG merged 10 commits into
elastic:mainfrom
ShourieG:vision_one/pagination_fix
Mar 20, 2025
Merged

[Trendmicro Vision One] - Fixed cursor & pagination logic for "detections" data stream#12916
ShourieG merged 10 commits into
elastic:mainfrom
ShourieG:vision_one/pagination_fix

Conversation

@ShourieG

@ShourieG ShourieG commented Feb 27, 2025

Copy link
Copy Markdown
Contributor

Type of change

  • Bug
  • Breaking Change

Proposed commit message

Fixed cursor & pagination logic for "detections" data stream to mirror a similar logic in implemented for a google_workspace fix.

Please refer to this issue to see the details.

NOTE

This will be a breaking change for the detections data stream as cursor values are completely changed, so existing state will get affected.

Checklist

  • I have reviewed tips for building integrations and this pull request is aligned with them.
  • I have verified that all data streams collect metrics or logs.
  • I have added an entry to my package's changelog.yml file.
  • I have verified that Kibana version constraints are current according to guidelines.
  • I have verified that any added dashboard complies with Kibana's Dashboard good practices

Author's Checklist

  • [ ]

How to test this PR locally

Related issues

Screenshots

@ShourieG ShourieG self-assigned this Feb 27, 2025
@ShourieG ShourieG added Integration:trend_micro_vision_one TrendAI Vision One Team:Security-Service Integrations Security Service Integrations team [elastic/security-service-integrations] bugfix Pull request that fixes a bug issue labels Feb 27, 2025
@ShourieG
ShourieG requested a review from efd6 February 27, 2025 08:52
@ShourieG

ShourieG commented Feb 27, 2025

Copy link
Copy Markdown
Contributor Author

TODO - test this with a live account

@ShourieG
ShourieG removed the request for review from efd6 February 27, 2025 08:55
@elastic-vault-github-plugin-prod

elastic-vault-github-plugin-prod Bot commented Feb 27, 2025

Copy link
Copy Markdown
Contributor

🚀 Benchmarks report

To see the full report comment with /test benchmark fullreport

@ShourieG
ShourieG marked this pull request as ready for review February 27, 2025 11:39
@ShourieG
ShourieG requested a review from a team as a code owner February 27, 2025 11:39
@elasticmachine

Copy link
Copy Markdown

Pinging @elastic/security-service-integrations (Team:Security-Service Integrations)

@ShourieG
ShourieG requested a review from efd6 February 27, 2025 11:40

@efd6 efd6 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This seems reasonable, but needs some commentary clean ups.

# If last pagination cycle was finished successfully
# we move the startDate pointer forward
# else we reprocess the last interval from the beginning.
# If none of the values are in the cursor it means is a fresh start

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
# If none of the values are in the cursor it means is a fresh start
# If none of the values are in the cursor it means it is a fresh start
- set:
target: url.params.startDateTime
value: '[[formatDate ((parseDate .cursor.last_update_at).Add (parseDuration "-{{additional_look_back}}"))]]'
# If last pagination cycle was finished successfully

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
# If last pagination cycle was finished successfully
# If the last pagination cycle was completed successfully
value: '[[formatDate ((parseDate .cursor.last_update_at).Add (parseDuration "-{{additional_look_back}}"))]]'
# If last pagination cycle was finished successfully
# we move the startDate pointer forward
# else we reprocess the last interval from the beginning.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
# else we reprocess the last interval from the beginning.
# otherwise we reprocess the last interval from the beginning.
# and we pick the default value.
value: >-
[[- if eq .cursor.pagination_finished "true" -]]
# look-back time should only be applied for fresh pagination intervals

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If you want to include comments in the Go template, you will need to use the template comment syntax.

Suggested change
# look-back time should only be applied for fresh pagination intervals
[[- /* look-back time should only be applied for fresh pagination intervals */ -]]

What is the precise definition of "fresh" here? I can see two possible interpretations; one matches the behaviour here (not started but after one that has completed), the other doesn't (never started). The immediately obvious interpretation is the second one, so I think this needs to be clearer.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

By fresh pagination cycle I meant a completely new pagination cycle that occurs on every new interval not between pages during a particular interval, I'll make it a bit clearer

@ShourieG

Copy link
Copy Markdown
Contributor Author

@efd6, addressed all the comments

@ShourieG
ShourieG requested a review from efd6 March 3, 2025 03:45

@efd6 efd6 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pending whether this TODO was TODONE and the change below.

# newer versions go on top
- version: "1.25.2"
changes:
- description: Added pagination and cursor fix to mirror the logic for a similar google_workspace scenario in pull - https://github.com/elastic/beats/pull/34274.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
- description: Added pagination and cursor fix to mirror the logic for a similar google_workspace scenario in pull - https://github.com/elastic/beats/pull/34274.
- description: Fixed pagination and cursor handling.

(users who want to know about pull requests will know how to find them, presenting them to other people is not really helpful, so instead of putting it here, put it in the commit message or just rely on the discussion in this PR — sorry, I missed this on the first round)

@ShourieG

Copy link
Copy Markdown
Contributor Author

cc: @narph @jamiehynds, planning on merging this soon but just as a fyi, this will be a breaking change for the detection data stream as the existing state will be lost due to a complete overhaul of the cursor logic. Should we give any other warnings for our customers before merging ?

@narph

narph commented Mar 14, 2025

Copy link
Copy Markdown
Contributor

cc: @narph @jamiehynds, planning on merging this soon but just as a fyi, this will be a breaking change for the detection data stream as the existing state will be lost due to a complete overhaul of the cursor logic. Should we give any other warnings for our customers before merging ?

@ShourieG lets not merge this till we discuss the impact on our users/customers

@jamiehynds

Copy link
Copy Markdown

@ShourieG what's the actual user impact? They upgrade the integration, we lose the state and they end up re-ingesting detections? Any ideas as to timeframe - will the last day, week, month worth of detections be re-ingested after upgrading the integration? If we don't implement this, we run the risk of incorrectly dropping data?

@ShourieG

ShourieG commented Mar 15, 2025

Copy link
Copy Markdown
Contributor Author

@jamiehynds, So if we implement this, the detections data stream will lose all existing state, the reingestion process will depend on the customers configuration as to how far they want to look back. If the customer does not change any configs and let things stay the way they are, the ingestion would start with the default startDateTime value which is calculated on the basis of (now - initial_interval) where initial_interval is user configured.
The timeframe would completely depend on the value of initial_interval.

If we don't implement this, we would end up in a similar state with what happened with google_workspace a couple of years back when the integration was dropping quite a bit of data due to how the api returned the responses. Basically we would get users complaining of data inconsistency which can vary from a small amount to quite large amounts on a case by case basis.

@jamiehynds

Copy link
Copy Markdown

@ShourieG while not ideal, I think implementing this change now is the less of two evils. Most users will likely prefer to deal with some reingestion than run the risk of dropping data due to current cursor logic. Plus, our default is 24h initial interval, and it's 'just' detections, so don't expect it do be a vast amount of data. We just need to make it clear in the changelog description that there's a breaking change included in this update and be clear on the impact (reingestion)

@elasticmachine

Copy link
Copy Markdown

💚 Build Succeeded

History

cc @ShourieG

@ShourieG
ShourieG merged commit 7424baf into elastic:main Mar 20, 2025
@ShourieG
ShourieG deleted the vision_one/pagination_fix branch March 20, 2025 10:29
@elastic-vault-github-plugin-prod

Copy link
Copy Markdown
Contributor

Package trend_micro_vision_one - 2.0.0 containing this change is available at https://epr.elastic.co/package/trend_micro_vision_one/2.0.0/

flexitrev pushed a commit that referenced this pull request Mar 25, 2025
…logic for "detections" data stream (#12916)

* added pagination and cursor fix to mirror the logic for a similar scenario in pull #34274

* updated changelog & manifest

* updated changelog

* updated look back calculation logic

* updated comments

* addressed Dan's suggestions

* updated changelog

* updated changelog with appropriate breaking-change type

* Update changelog with breaking change details
flexitrev pushed a commit that referenced this pull request Mar 28, 2025
…logic for "detections" data stream (#12916)

* added pagination and cursor fix to mirror the logic for a similar scenario in pull #34274

* updated changelog & manifest

* updated changelog

* updated look back calculation logic

* updated comments

* addressed Dan's suggestions

* updated changelog

* updated changelog with appropriate breaking-change type

* Update changelog with breaking change details
flexitrev pushed a commit that referenced this pull request Mar 28, 2025
…logic for "detections" data stream (#12916)

* added pagination and cursor fix to mirror the logic for a similar scenario in pull #34274

* updated changelog & manifest

* updated changelog

* updated look back calculation logic

* updated comments

* addressed Dan's suggestions

* updated changelog

* updated changelog with appropriate breaking-change type

* Update changelog with breaking change details
flexitrev pushed a commit that referenced this pull request Mar 28, 2025
…logic for "detections" data stream (#12916)

* added pagination and cursor fix to mirror the logic for a similar scenario in pull #34274

* updated changelog & manifest

* updated changelog

* updated look back calculation logic

* updated comments

* addressed Dan's suggestions

* updated changelog

* updated changelog with appropriate breaking-change type

* Update changelog with breaking change details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change bugfix Pull request that fixes a bug issue Integration:trend_micro_vision_one TrendAI Vision One Team:Security-Service Integrations Security Service Integrations team [elastic/security-service-integrations]

5 participants