Skip to content

Website: log number of android enterprise requests in the past minute - #50780

Merged
eashaw merged 3 commits into
mainfrom
website-log-number-android-api-requests
Aug 7, 2026
Merged

Website: log number of android enterprise requests in the past minute#50780
eashaw merged 3 commits into
mainfrom
website-log-number-android-api-requests

Conversation

@eashaw

@eashaw eashaw commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Related to: #49212

Changes:

  • Updated the custom hook to create sails.androidProxyApiRequestCount, and to log and reset the value every minute
  • Updated android proxy endpoints to increment sails.androidProxyApiRequestCount every time a request to the Android management API is sent

Summary by CodeRabbit

  • Monitoring
    • Added comprehensive tracking for Android Management API requests across enrollment, enterprise, device, application, policy, and command operations.
    • Added periodic request-count logging and automatic resets when Android Enterprise credentials are configured.
    • Improved reporting alignment with minute-based API limits while keeping logs quiet during periods without requests.

Copilot AI lite review requested due to automatic review settings August 7, 2026 16:15
fleet-release
fleet-release previously approved these changes Aug 7, 2026

Copilot AI 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.

Pull request overview

Adds lightweight request-rate telemetry for the website’s Android Management API proxy by tracking the number of Android Management API calls made and emitting a per-minute log line.

Changes:

  • Initialize a global sails.androidProxyApiRequestCount and set up a per-minute timer to log and reset the count.
  • Increment the counter in each website/api/controllers/android-proxy/* controller right before making an Android Management API request.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
website/api/hooks/custom/index.js Initializes a global Android Management API request counter and logs/resets it every minute (aligned to wall-clock minutes).
website/api/controllers/android-proxy/modify-enterprise-app-policy.js Increments the global counter before the Android Management API policy-applications request.
website/api/controllers/android-proxy/modify-android-policies.js Increments the global counter before the Android Management API policies.patch request.
website/api/controllers/android-proxy/modify-android-device.js Increments the global counter before the Android Management API devices.patch request.
website/api/controllers/android-proxy/issue-command-on-android-device.js Increments the global counter before the Android Management API devices.issueCommand request.
website/api/controllers/android-proxy/get-enterprise-applications.js Increments the global counter before the Android Management API enterprises.applications.get request.
website/api/controllers/android-proxy/get-android-enterprises.js Increments the global counter for each page of Android Management API enterprises.list requests.
website/api/controllers/android-proxy/get-android-devices.js Increments the global counter before the Android Management API devices.list request.
website/api/controllers/android-proxy/get-android-device.js Increments the global counter before the Android Management API devices.get request.
website/api/controllers/android-proxy/delete-one-android-enterprise.js Increments the global counter before the Android Management API enterprises.delete request.
website/api/controllers/android-proxy/delete-android-device.js Increments the global counter before the Android Management API devices.delete request.
website/api/controllers/android-proxy/create-enterprise-webapp.js Increments the global counter before the Android Management API webApps.create request.
website/api/controllers/android-proxy/create-android-signup-url.js Increments the global counter before the Android Management API signupUrls.create request.
website/api/controllers/android-proxy/create-android-enterprise.js Increments the global counter before the Android Management API enterprises.create request.
website/api/controllers/android-proxy/create-android-enrollment-token.js Increments the global counter before the Android Management API enrollmentTokens.create request.
Suppressed comments (1)

website/api/hooks/custom/index.js:153

  • Linked issue #49212 asks for per-Android-Enterprise-project and per-resource (policy vs device) counts. This implementation logs only a single global total for all Android Management API calls, and the log line doesn’t include project/resource identifiers, so it can’t satisfy the per-project/per-resource breakdown.
          sails.log.info(`Android proxy: ${requestCountInLastMinute} Android Management API request(s) in the last minute.`);

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread website/api/hooks/custom/index.js Outdated
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 4497c9df-f697-4351-9c5b-812d958142a4

📥 Commits

Reviewing files that changed from the base of the PR and between 57eebd6 and 8515006.

📒 Files selected for processing (2)
  • website/api/helpers/android-proxy/get-is-enterprise-managed-by-fleet.js
  • website/api/hooks/custom/index.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • website/api/hooks/custom/index.js

Walkthrough

The custom hook initializes and monitors sails.androidProxyApiRequestCount when Android Enterprise credentials are configured. Android proxy controllers and the enterprise-management helper increment this counter before Android Management API requests, including paginated requests and repeated command, patch, or policy operations.

Possibly related PRs

  • fleetdm/fleet#49488: Modifies create-android-signup-url.js for Android Management API rate-limit handling.
  • fleetdm/fleet#49918: Modifies the same Android proxy controllers for Android Management API error handling.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the main changes and references the issue, but it omits the required checklist and testing status. Use the repository template and record applicable checklist items, including automated testing and manual QA results.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: logging Android Enterprise Management API requests over the past minute.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch website-log-number-android-api-requests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@website/api/controllers/android-proxy/create-android-signup-url.js`:
- Line 66: Update the enterprise existence-check flow around
getIsEnterpriseManagedByFleet() so every
androidManagementConnection.enterprises.list() request increments
sails.androidProxyApiRequestCount before or when it is issued. Preserve the
existing signupUrls.create() increment and avoid double-counting requests if
reusing an already-counted helper.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: ffcdc824-b3a0-4455-97f7-acfb87c62eba

📥 Commits

Reviewing files that changed from the base of the PR and between 9b5e977 and 57eebd6.

📒 Files selected for processing (15)
  • website/api/controllers/android-proxy/create-android-enrollment-token.js
  • website/api/controllers/android-proxy/create-android-enterprise.js
  • website/api/controllers/android-proxy/create-android-signup-url.js
  • website/api/controllers/android-proxy/create-enterprise-webapp.js
  • website/api/controllers/android-proxy/delete-android-device.js
  • website/api/controllers/android-proxy/delete-one-android-enterprise.js
  • website/api/controllers/android-proxy/get-android-device.js
  • website/api/controllers/android-proxy/get-android-devices.js
  • website/api/controllers/android-proxy/get-android-enterprises.js
  • website/api/controllers/android-proxy/get-enterprise-applications.js
  • website/api/controllers/android-proxy/issue-command-on-android-device.js
  • website/api/controllers/android-proxy/modify-android-device.js
  • website/api/controllers/android-proxy/modify-android-policies.js
  • website/api/controllers/android-proxy/modify-enterprise-app-policy.js
  • website/api/hooks/custom/index.js

Comment thread website/api/controllers/android-proxy/create-android-signup-url.js
@eashaw
eashaw merged commit f145c77 into main Aug 7, 2026
12 checks passed
@eashaw
eashaw deleted the website-log-number-android-api-requests branch August 7, 2026 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants