Skip to content

feat: Add CLI Plugin for monitor-api#845

Open
pmajali wants to merge 14 commits intolinode:devfrom
pmajali:dev
Open

feat: Add CLI Plugin for monitor-api#845
pmajali wants to merge 14 commits intolinode:devfrom
pmajali:dev

Conversation

@pmajali
Copy link
Copy Markdown

@pmajali pmajali commented Jan 1, 2026

📝 Description

A CLI plugin for the ACLP metric-read-api

✔️ How to Test

What are the steps to reproduce the issue or verify the changes?
linode-cli get_metrics dbaas --entity-ids 123 --duration 15 --duration-unit min --metrics cpu_usage:avg --filters 'node_type:in:primary,secondary'

the help command prints the list of sample commands. A JWE token is required to be set to make these calls.
details on generating JWE token https://techdocs.akamai.com/linode-api/reference/post-get-token
API details: https://techdocs.akamai.com/linode-api/reference/post-read-metric

How do I run the relevant unit/integration tests?
python -m pytest tests/unit/test_plugin_get_metrics.py -v

for integration set, set a JWE_TOKEN env var for service type objectstorage
python -m pytest tests/integration/monitor/test_plugin_get_metrics.py -v

@pmajali pmajali requested a review from a team as a code owner January 1, 2026 10:26
@pmajali pmajali requested review from lgarber-akamai and zliang-akamai and removed request for a team January 1, 2026 10:26
@yec-akamai yec-akamai requested review from a team, Copilot, jriddle-linode, vshanthe and yec-akamai and removed request for a team January 7, 2026 14:22
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@yec-akamai yec-akamai requested a review from Copilot January 9, 2026 15:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.


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

Comment thread tests/integration/monitor/test_plugin_get_metrics.py Outdated
Comment thread linodecli/plugins/get_metrics.py Outdated
Comment thread linodecli/plugins/get_metrics.py Outdated
Copy link
Copy Markdown
Contributor

@yec-akamai yec-akamai left a comment

Choose a reason for hiding this comment

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

The command looks not quite right in regards to the url call. Can you make changes according to the comments?

Comment thread linodecli/plugins/get_metrics.py Outdated
Comment thread linodecli/plugins/get_metrics.py Outdated
@susharma-beep susharma-beep requested a review from a team as a code owner April 8, 2026 05:47
@susharma-beep susharma-beep requested review from ckulinsk and removed request for a team and vshanthe April 8, 2026 05:47
@susharma-beep
Copy link
Copy Markdown

The cli command has been updated to below
linode-cli monitor-api get-metrics dbaas --entity-ids 123 --duration 15 --duration-unit min --metrics cpu_usage:avg --filters 'node_type:in:primary,secondary'

help commands
linode-cli monitor-api get-metrics --help

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.


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

Comment thread linodecli/plugins/monitor-api.py Outdated
Comment thread linodecli/plugins/monitor-api.py Outdated
Comment thread linodecli/plugins/monitor-api.py
Comment thread linodecli/plugins/monitor-api.py Outdated
Comment thread tests/integration/monitor/test_plugin_get_metrics.py
Comment thread linodecli/plugins/monitor-api.py Outdated
@susharma-beep susharma-beep force-pushed the dev branch 2 times, most recently from d3cc043 to 87c3278 Compare April 9, 2026 06:27
pmajali and others added 6 commits April 9, 2026 17:28
- Changed plugin base from 'linode-cli get_metrics' to 'linode-cli monitor-api' with 'get-metrics' as a subcommand
- Refactored API_BASE_URL to be more generic, allowing API version specification
- Updated all help text and examples to reflect new command structure
- Updated unit and integration tests accordingly
…de#873)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) from 3.12.0 to 4.0.0.
- [Release notes](https://github.com/docker/setup-buildx-action/releases)
- [Commits](docker/setup-buildx-action@8d2750c...4d04d5d)

---
updated-dependencies:
- dependency-name: docker/setup-buildx-action
  dependency-version: 4.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
ezilber-akamai and others added 5 commits April 9, 2026 17:29
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
- Add validation for aggregate function values (must be in AGGREGATE_FUNCTIONS)
- Add validation for duration-unit and granularity-unit (must be min/hr/day)
- Enforce entity-ids requirement for non-objectstorage services
- Validate that granularity and granularity-unit are provided together
- Add -h flag handling for help (in addition to --help)
- Make payload printing debug-only (only shown with --debug flag)
- Add @requires_jwe_token skip decorator for integration tests
- Add new test cases for validation improvements
@yec-akamai yec-akamai added new-feature for new features in the changelog. community-contribution for contributions made by a non-DX author labels Apr 9, 2026
@yec-akamai yec-akamai changed the title plugin for MR Add CLI Plugin for monitor-api Apr 9, 2026
@pmajali pmajali changed the title Add CLI Plugin for monitor-api feat: Add CLI Plugin for monitor-api Apr 10, 2026
@kmuddapo
Copy link
Copy Markdown

@yec-akamai Could this review and testing be expedited, please? This has been pending for a few months now. :) Thanks!!

@yec-akamai
Copy link
Copy Markdown
Contributor

@yec-akamai Could this review and testing be expedited, please? This has been pending for a few months now. :) Thanks!!

Thanks for the nudge, @kmuddapo. Now that the feedback from January has been addressed as of last week, our QA and I are actively reviewing the updates. We’ll provide comments or approval shortly.

Comment thread tests/integration/monitor/test_plugin_get_metrics.py
print(
" linode-cli monitor-api get-metrics dbaas --entity-ids 123 --duration 15 "
"--duration-unit min --metrics cpu_usage:avg "
"--filters 'node_type:in:primary,secondary'"
Copy link
Copy Markdown
Contributor

@yec-akamai yec-akamai Apr 14, 2026

Choose a reason for hiding this comment

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

This example with filters seems not correct. I tried this command and got api error:

Error response: {
  "errors": [
    {
      "field": "Filters",
      "reason": "Invalid filter"
    }
  ]
}

Can you verify if it's an issue with the filter parser or just the example?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

added the logic

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.

Still not correct:

API request failed with status 400
Error response: {
  "errors": [
    {
      "field": "filters",
      "reason": "['primary', 'secondary'] is not of type 'string'"
    }
  ]
}

Comment thread linodecli/plugins/monitor-api.py Outdated
Comment thread linodecli/plugins/monitor-api.py
Comment thread linodecli/plugins/monitor-api.py
- Remove print_help() from error cases (invalid command, missing service,
  unknown args, invalid arguments) to avoid burying error messages
- Add 'Invalid arguments. Run with --help for usage.' message
- Fix ALLOWED_TIME_UNITS: 'day' -> 'days' to match API spec
- Fix filter parser: 'in' operator sends value as list, others as string
- Fix --duration-unit and --granularity-unit help text: 'day' -> 'days'
- Fix help example: --duration-unit hour -> hr
- Fix filter help examples: use valid operators
- Add JWE token generation instructions to help page and integration test
- Add API doc link for token generation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution for contributions made by a non-DX author new-feature for new features in the changelog.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants