Skip to content

Conversation

@chrisberkhout
Copy link
Contributor

@chrisberkhout chrisberkhout commented Jan 6, 2025

Proposed commit message

[jamf_pro] Inventory pagination fix * Always include the General section of inventory data. * Update the cursor whenever there is new data. * Assume there isn't another page if the current page isn't full. * Correct the name of the `enable_section_content_caching` variable. * Adjust the `page_size` variable description to correct the maximum. * Simplify code to set the inventory filter parameter. This has been manually tested against the live API. 

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

Discussion

I ran this against the live endpoint and checked a couple of pagination sequences. Here's some partial data from the logs (not the full results objects), that shows the cursor updates and sequence continuation/end are done correctly:

Expand for the partial request log data
// first sequence { "@timestamp": "2025-01-06T11:14:20.308Z", "url.query": "page-size=4&section=GENERAL&section=HARDWARE&section=OPERATING_SYSTEM&sort=general.reportDate%3Aasc" } { "http.response.body.content": { "totalCount": 8, "results": [ { "reportDate": "2024-06-19T15:54:33.186Z" }, { "reportDate": "2024-06-19T15:54:34.353Z" }, { "reportDate": "2024-06-19T15:54:37.692Z" }, { "reportDate": "2024-06-19T15:54:39.687Z" } ] } } { "@timestamp": "2025-01-06T11:14:21.195Z", "url.query": "filter=general.reportDate%3E%3D%222024-06-19T15%3A54%3A39.687Z%22&page-size=4&section=GENERAL&section=HARDWARE&section=OPERATING_SYSTEM&sort=general.reportDate%3Aasc" } { "http.response.body.content": { "totalCount": 5, "results": [ { "reportDate": "2024-06-19T15:54:39.687Z" }, { "reportDate": "2024-06-19T15:54:41.981Z" }, { "reportDate": "2024-06-19T15:54:43.956Z" }, { "reportDate": "2024-06-19T15:54:46.34Z" } ] } } { "@timestamp": "2025-01-06T11:14:21.939Z", "url.query": "filter=general.reportDate%3E%3D%222024-06-19T15%3A54%3A46.34Z%22&page-size=4&section=GENERAL&section=HARDWARE&section=OPERATING_SYSTEM&sort=general.reportDate%3Aasc" } { "http.response.body.content": { "totalCount": 2, "results": [ { "reportDate": "2024-06-19T15:54:46.34Z" }, { "reportDate": "2024-06-19T15:54:47.471Z" } ] } } // after interval, second sequence { "@timestamp": "2025-01-06T11:16:22.707Z", "url.query": "filter=general.reportDate%3E%3D%222024-06-19T15%3A54%3A47.471Z%22&page-size=4&section=GENERAL&section=HARDWARE&section=OPERATING_SYSTEM&sort=general.reportDate%3Aasc" } { "http.response.body.content": { "totalCount": 1, "results": [ { "reportDate": "2024-06-19T15:54:47.471Z" } ] } }

API documentation: GET /api/v1/computers-inventory

Related issues

@chrisberkhout chrisberkhout added bugfix Pull request that fixes a bug issue Integration:jamf_pro Jamf Pro labels Jan 6, 2025
@chrisberkhout chrisberkhout self-assigned this Jan 6, 2025
@elastic-vault-github-plugin-prod

🚀 Benchmarks report

To see the full report comment with /test benchmark fullreport

@chrisberkhout chrisberkhout changed the title [jamf_pro] Pagination fix [jamf_pro] Inventory pagination fix Jan 6, 2025
@chrisberkhout chrisberkhout marked this pull request as ready for review January 6, 2025 12:27
@chrisberkhout chrisberkhout requested a review from a team as a code owner January 6, 2025 12:27
@andrewkroh andrewkroh added the Team:Security-Service Integrations Security Service Integrations team [elastic/security-service-integrations] label Jan 6, 2025
@elasticmachine
Copy link

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

@elasticmachine
Copy link

💚 Build Succeeded

History

  • 💚 Build #20039 succeeded 808b09c2a20754a5062e2974886834d61ff62311

cc @chrisberkhout

@chrisberkhout chrisberkhout added the Team:Security-External Integrations Label for the Security External Integrations team label Jan 6, 2025
@elasticmachine
Copy link

Pinging @elastic/security-external-integrations (Team:Security-External Integrations)

@chrisberkhout chrisberkhout removed the Team:Security-External Integrations Label for the Security External Integrations team label Jan 6, 2025
Copy link
Contributor

@ShourieG ShourieG left a comment

Choose a reason for hiding this comment

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

LGTM

@chrisberkhout chrisberkhout merged commit d93bf87 into elastic:main Jan 7, 2025
5 checks passed
@elastic-vault-github-plugin-prod

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

harnish-crest-data pushed a commit to chavdaharnish/integrations that referenced this pull request Feb 4, 2025
* Always include the General section of inventory data. * Update the cursor whenever there is new data. * Assume there isn't another page if the current page isn't full. * Correct the name of the `enable_section_content_caching` variable. * Adjust the `page_size` variable description to correct the maximum. * Simplify code to set the inventory filter parameter. This has been manually tested against the live API.
harnish-crest-data pushed a commit to chavdaharnish/integrations that referenced this pull request Feb 5, 2025
* Always include the General section of inventory data. * Update the cursor whenever there is new data. * Assume there isn't another page if the current page isn't full. * Correct the name of the `enable_section_content_caching` variable. * Adjust the `page_size` variable description to correct the maximum. * Simplify code to set the inventory filter parameter. This has been manually tested against the live API.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can I clarify that this is "want_more": !(size(body.results) < state.page_size) and the > component of the inequality is a consequence of that? Is there any case that size(body.results) > state.page_size is true? That would seem like a bug in the API.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's the intent.

If the page is not full, stop.
Otherwise continue.

Also continue if it's over-full, but I haven't seen it and I don't expect that to happen.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks

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 Team:Security-Service Integrations Security Service Integrations team [elastic/security-service-integrations]

5 participants