Skip to content
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

Add access token support to stats endpoint #2053

Merged
merged 13 commits into from
May 3, 2023
Merged

Conversation

knolleary
Copy link
Member

Closes #2043

Description

This PR adds the ability to monitor the platform from tools such prometheus.

It has ended up touching lots of files, but I have structured the commits to make it easier to review.

Highlevel description:

  1. Enables token-based access to the admin stats endpoint
  2. Fixes up how admin access to api endpoints is managed
  3. Adds api endpoint to generate/delete a dedicated stats token
  4. Updates Admin Settings to allow admin to enable/disable the token
  5. Adds support for openmetrics-text format response in the stats end-point

Commits in order:

  1. Ensure all admin routes have explicit permissions declared - we previously used verifyAdmin as a catch-all preHandler to ensure a request comes from an admin. But to support tokens with reduced scope, we cannot do that. So I've added explicitly needsPermission preHandler to all admin routes. To go alongside this, I've added much better Unit Test coverage of needsPermission to cater for the growing number of scenarios.
  2. Add support for OpenMetrics format on /api/v1/admin/stats - return the new format if the accept header requests it
  3. Add team billing info to stats - include counts of subscriptions by state. Useful to get a sense of trial/non-trial etc
  4. Add api endpoints to manage platform stats token - basic endpoints to generate/delete the token, inc unit tests
  5. Make FormRow description field more consistent - noticed inconsistent css for the 'description' field in FormRow
  6. Add platform stats option to Admin Settings page - Adds UI to admin settings to manage the stats token
  7. Add docs on platform monitoring - doc updates

Checklist

  • I have read the contribution guidelines
  • Suitable unit/system level tests have been added and they pass
  • Documentation has been updated
    • Upgrade instructions
    • Configuration details
    • Concepts
  • Changes flowforge.yml?
    • Issue/PR raised on flowforge/helm to update ConfigMap Template
    • Issue/PR raised on flowforge/CloudProject to update values for Staging/Production

Labels

  • Backport needed? -> add the backport label
  • Includes a DB migration? -> add the area:migration label

@knolleary knolleary requested a review from Pezmc April 27, 2023 10:05
@knolleary knolleary changed the title 2043 monitor endpoint token Add access token support to stats endpoint Apr 27, 2023
forge/routes/api/admin.js Outdated Show resolved Hide resolved
forge/routes/api/admin.js Outdated Show resolved Hide resolved
knolleary and others added 3 commits May 2, 2023 21:32
Co-authored-by: Pez Cuckow <email@pezcuckow.com>
Co-authored-by: Pez Cuckow <email@pezcuckow.com>
Co-authored-by: Pez Cuckow <email@pezcuckow.com>
@knolleary knolleary requested a review from Pezmc May 2, 2023 20:32
Co-authored-by: Pez Cuckow <email@pezcuckow.com>
Co-authored-by: Pez Cuckow <email@pezcuckow.com>
@knolleary knolleary merged commit 88bdcf3 into main May 3, 2023
@knolleary knolleary deleted the 2043-monitor-endpoint-token branch May 3, 2023 13:21
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.

Add api token scoped to just admin/stats end-point for system monitoring
2 participants