feat: support add Monitor api plugin#879
Open
susharma-beep wants to merge 3 commits intolinode:devfrom
Open
Conversation
This plugin provides access to the Linode Monitor API, allowing users to query metrics for various services with options for filtering and time duration.
Add unit tests for monitor-api metrics functionality
Added integration tests for the get_metrics plugin, covering various scenarios including missing arguments, invalid service names, and handling of filters.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 Description
What does this PR do and why is this change necessary?
This PR adds a new monitor-api plugin for the Linode CLI that provides access to the Linode Monitor API for querying metrics across various services.
Key features:
Query metrics for multiple services: DBaaS, NodeBalancer, NetLoadBalancer, Linode, Firewall, ObjectStorage, BlockStorage, and LKE
Support for both relative time duration (--duration/--duration-unit) and absolute time ranges (--start-time/--end-time)
Mandatory aggregate functions for all metrics (sum, avg, max, min, count)
Optional filtering, grouping, and granularity controls
Region-based queries for services like ObjectStorage
Comprehensive validation for all input parameters
✔️ How to Test
What are the steps to reproduce the issue or verify the changes?
Set the authentication token:
export JWE_TOKEN='your_jwe_token_here'
Test basic metrics query:
linode-cli monitor-api get-metrics objectstorage
--entity-region us-east-1 --duration 15 --duration-unit min
--metrics obj_requests_num:sum
Test with filters:
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'
Test help command:
linode-cli monitor-api get-metrics --help
How do I run the relevant unit/integration tests?
Run unit tests (no authentication required)
pytest tests/unit/test_plugin_get_metrics.py -v
Run integration tests (requires JWE_TOKEN)
export JWE_TOKEN='your_token'
pytest tests/integration/monitor/test_plugin_get_metrics.py -v
Run linting
make lint