feat(plugin): add get events command with Loki source#929
Open
rohan2794 wants to merge 1 commit into
Open
Conversation
Contributor
|
Tick the box to add this pull request to the merge queue (same as
|
niladrih
reviewed
Jul 10, 2026
Comment on lines
+27
to
+28
| events-api = { path = "../../dependencies/control-plane/utils/dependencies/apis/events" } | ||
| prettytable-rs = "0.10.0" |
Member
There was a problem hiding this comment.
This needs to be pinned on the repo's root level Cargo.toml?
And this needs to use the workspace version
Comment on lines
+18
to
+43
| #[clap(long)] | ||
| loki_endpoint: Option<String>, | ||
|
|
||
| /// Filter by event category (repeatable or comma-separated), e.g. volume, pool. | ||
| #[clap(long = "category", value_delimiter = ',')] | ||
| categories: Vec<String>, | ||
|
|
||
| /// Filter by event action (repeatable or comma-separated), e.g. create, delete. | ||
| #[clap(long = "action", value_delimiter = ',')] | ||
| actions: Vec<String>, | ||
|
|
||
| /// Filter by node name. | ||
| #[clap(long)] | ||
| node: Option<String>, | ||
|
|
||
| /// Filter by target resource ID. | ||
| #[clap(long)] | ||
| target: Option<String>, | ||
|
|
||
| /// Events from last duration (e.g. 1h, 30m). | ||
| #[clap(long, default_value = "24h")] | ||
| since: humantime::Duration, | ||
|
|
||
| /// Maximum number of events to return (0 = unlimited). | ||
| #[clap(long, default_value_t = DEFAULT_LIMIT)] | ||
| limit: usize, |
Member
There was a problem hiding this comment.
nit: we shouldn't use clap() for new codebases, should be arg. clap() is older, and although clap v4 has backwards compatibility for it, we should use the newer API.
Comment on lines
+243
to
+251
| let mut label_filters: String = label_selector | ||
| .split(',') | ||
| .map(|key_value_pair| { | ||
| let pairs = key_value_pair.split('=').collect::<Vec<&str>>(); | ||
| format!("{}=\"{}\",", pairs[0], pairs[1]) | ||
| .replace('.', "_") | ||
| .replace('/', "_") | ||
| }) | ||
| .collect::<String>(); |
Add kubectl mayastor get events subcommand that queries the eventing-aggregator's structured event logs from Loki. - New EventsArgs clap struct with --loki-endpoint, --category, --action, --node, --target, --since (default 24h), --limit flags - EventRecord type: display fields (#[serde(skip)]) for table output, #[serde(flatten)] EventMessage for full JSON/YAML output - parse_line() strips tracing prefix and deserialises the mbus_event JSON envelope into a typed EventMessage (events-api) - Filters applied in-memory after fetch; results sorted newest-first - LogQL filter mbus_event pre-filters Loki lines server-side - Diagnostic hint when Loki returns no lines (suggests --since widening) vs when lines were fetched but no events matched the applied filters - Wired into GetResourcesK8s enum in resources/mod.rs - Added events-api and prettytable-rs dependencies to k8s/plugin Signed-off-by: rohan2794 <rohan2794@gmial.com>
a59cb40 to
febfcb7
Compare
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.
Add
kubectl mayastor get eventssubcommand that queries theeventing-aggregator's structured event logs from Loki.
EventsArgsclap struct with --loki-endpoint, --category,--action, --node, --target, --since (default 24h), --limit flags
EventRecordtype: display fields (#[serde(skip)]) for table output,#[serde(flatten)] EventMessage for full JSON/YAML output
parse_line()strips tracing prefix and deserialises the mbus_eventJSON envelope into a typed EventMessage (events-api)
|= "mbus_event"pre-filters Loki lines server-sidevs when lines were fetched but no events matched the applied filters