Skip to content

forgerock: fix endTime query parameter handling - #11409

Merged
efd6 merged 3 commits into
elastic:mainfrom
efd6:11331-forgerock
Oct 17, 2024
Merged

efd6 merged 3 commits into
elastic:mainfrom
efd6:11331-forgerock

Conversation

@efd6

@efd6 efd6 commented Oct 15, 2024 •

Copy link
Copy Markdown
Contributor

Proposed commit message

In #11240 we attempted to fix preparation of endTime where it could be more than
24 hours after the startTime parameter, a case that is invalid for the API. To
do this, we just always added 24 hours to the startTime on the basis that the
API would crop at the present moment, and — notably — under the assumption that
the returned document would be used to construct the next startTime. Clearly
this is not the case, since we use the actual endTime parameter to construct the
next startTime; the API does not provide an HTTPJSON-easy way to get the last
timestamp. So set the endTime query parameter to the earliest of now and 24
hours after startTime.

Queries with an end time of now may not get all documents up to now. Since we
are using the query parameter to define the end of the range of documents that
have definitively been retrieved, this means that we will never try to get these
missed documents. We could us the maximum timestamp of the collected documents
to define this range, but that less easy to do here, so just set the end of the
time range to be some short period before now. Ten seconds is chosen as a
conservative value (the report claimed milliseconds of documents were lost).

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

@efd6 efd6 added bugfix Pull request that fixes a bug issue Integration:forgerock ForgeRock Team:Security-Service Integrations Security Service Integrations team [elastic/security-service-integrations] labels Oct 15, 2024
@efd6 efd6 self-assigned this Oct 15, 2024
In elastic#11240 we attempted to fix preparation of endTime where it could be more than
24 hours after the startTime parameter, a case that is invalid for the API. To
do this, we just always added 24 hours to the startTime on the basis that the
API would crop at the present moment, and — notably — under the assumption that
the returned document would be used to construct the next startTime. Clearly
this is not the case, since we use the actual endTime parameter to construct the
next startTime; the API does not provide an HTTPJSON-easy way to get the last
timestamp. So set the endTime query parameter to the earliest of now and 24
hours after startTime.
@elastic-vault-github-plugin-prod

Copy link
Copy Markdown
Contributor

🚀 Benchmarks report

To see the full report comment with /test benchmark fullreport

@efd6
efd6 marked this pull request as ready for review October 15, 2024 03:11
@efd6
efd6 requested a review from a team as a code owner October 15, 2024 03:11
@elasticmachine

Copy link
Copy Markdown

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

@igrujic-ap

Copy link
Copy Markdown

Hi @efd6 I see that this PR is aiming to solve issue that I reported. However I noticed one additional thing that I noticed so not sure if this PR is going to solve it or should I create a new issue. When we use "now" as endtime, events that happened few millisecond before it are not immediately exposed in ForgeRock audit logs and they get lost as next request starts with that end date and these logs belong to previous request. My suggestion would be to reduce "now" (when used) by few milliseconds or even seconds. In this case those logs would be picked up with next request. Thanks

@efd6

efd6 commented Oct 15, 2024

Copy link
Copy Markdown
Contributor Author

@igrujic-ap Thanks for the heads up. I will include that in the change here. There are two options:

  1. set the endTime back a few seconds when it is constructed as you propose — this moves our endpoint to before what looks like a refractory period.
  2. set the startTime back a few seconds when it is derived from the stored cursor when it is used — this repeats collection to before the refractory period. (I think this one is safer at the cost of potentially collecting some data twice; we would need to add a fingerprinting processor to handle this)

Queries with an end time of now may not get all documents up to now. Since we
are using the query parameter to define the end of the range of documents that
have definitively been retrieved, this means that we will never try to get these
missed documents. We could us the maximum timestamp of the collected documents
to define this range, but that less easy to do here, so just set the end of the
time range to be some short period before now. Ten seconds is chosed as a
conservative value (the report claimed milliseconds of documents were lost).
@efd6
efd6 requested a review from chrisberkhout October 16, 2024 02:54
@elasticmachine

Copy link
Copy Markdown

💚 Build Succeeded

History

cc @efd6

@elastic-sonarqube

Copy link
Copy Markdown

@igrujic-ap

Copy link
Copy Markdown

Thank you @efd6. Do you know release schedule for this fix? We would like to test and let you know if everything is working as expected.

@efd6

efd6 commented Oct 16, 2024

Copy link
Copy Markdown
Contributor Author

@igrujic-ap Just waiting for approval for the most recent additions.

@chrisberkhout chrisberkhout 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.

Good

@efd6
efd6 merged commit 8242c93 into elastic:main Oct 17, 2024
@elastic-vault-github-plugin-prod

Copy link
Copy Markdown
Contributor

Package forgerock - 1.18.4 containing this change is available at https://epr.elastic.co/search?package=forgerock

harnish-crest-data pushed a commit to chavdaharnish/integrations that referenced this pull request Feb 4, 2025
In elastic#11240 we attempted to fix preparation of endTime where it could be more than
24 hours after the startTime parameter, a case that is invalid for the API. To
do this, we just always added 24 hours to the startTime on the basis that the
API would crop at the present moment, and — notably — under the assumption that
the returned document would be used to construct the next startTime. Clearly
this is not the case, since we use the actual endTime parameter to construct the
next startTime; the API does not provide an HTTPJSON-easy way to get the last
timestamp. So set the endTime query parameter to the earliest of now and 24
hours after startTime.

Queries with an end time of now may not get all documents up to now. Since we
are using the query parameter to define the end of the range of documents that
have definitively been retrieved, this means that we will never try to get these
missed documents. We could us the maximum timestamp of the collected documents
to define this range, but that less easy to do here, so just set the end of the
time range to be some short period before now. Ten seconds is chosen as a
conservative value (the report claimed milliseconds of documents were lost).
harnish-crest-data pushed a commit to chavdaharnish/integrations that referenced this pull request Feb 5, 2025
In elastic#11240 we attempted to fix preparation of endTime where it could be more than
24 hours after the startTime parameter, a case that is invalid for the API. To
do this, we just always added 24 hours to the startTime on the basis that the
API would crop at the present moment, and — notably — under the assumption that
the returned document would be used to construct the next startTime. Clearly
this is not the case, since we use the actual endTime parameter to construct the
next startTime; the API does not provide an HTTPJSON-easy way to get the last
timestamp. So set the endTime query parameter to the earliest of now and 24
hours after startTime.

Queries with an end time of now may not get all documents up to now. Since we
are using the query parameter to define the end of the range of documents that
have definitively been retrieved, this means that we will never try to get these
missed documents. We could us the maximum timestamp of the collected documents
to define this range, but that less easy to do here, so just set the end of the
time range to be some short period before now. Ten seconds is chosen as a
conservative value (the report claimed milliseconds of documents were lost).
@efd6
efd6 deleted the 11331-forgerock branch February 5, 2025 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Pull request that fixes a bug issue Integration:forgerock ForgeRock Team:Security-Service Integrations Security Service Integrations team [elastic/security-service-integrations]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[forgerock]: Logs being pulled for wrong date time range

4 participants