Skip to content

fix(cloud-aws-cloudwatchlogs): fix paws custom mode for get-logs and list-groups - #6538

Open
rmorandell-pgum wants to merge 1 commit into
centreon:developfrom
i-Vertix:cloud-aws-cloudwatchlogs
Open

rmorandell-pgum wants to merge 1 commit into
centreon:developfrom
i-Vertix:cloud-aws-cloudwatchlogs

Conversation

@rmorandell-pgum

@rmorandell-pgum rmorandell-pgum commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Community contributors

Description

With --custommode=paws, the modes get-logs and list-groups of the CloudWatch Logs plugin (cloud::aws::cloudwatchlogs::plugin) do not work: get-logs never sees any log event, so it is always OK: 0 problem(s) detected, and list-groups --disco-show has no group names. The awscli custom mode is not affected. This PR fixes the paws custom mode so that both custom modes return the same results.

Root causes in src/cloud/aws/custom/paws.pm:

  • cloudwatchlogs_filter_log_events reads the field logGroups of the FilterLogEvents answer instead of Events, so it never returns an event.
  • --stream-name is ignored: the mode passes stream_names, but the paws custom mode reads $options{LogStreamNames}.
  • Paws returns its attributes in PascalCase (LogGroupName, LogStreamName, Timestamp, Message), while the modes expect the keys of the aws CLI JSON output (logGroupName, logStreamName, timestamp, message). list-groups handled both cases for its text output only, --disco-show used logGroupName and stayed empty with paws.
  • The --endpoint option of the paws custom mode (already used by the cloudtrail plugin) is not passed to the CloudWatch Logs service.

Changes:

  • src/cloud/aws/custom/paws.pm
    • New helper cloudwatchlogs_service(): builds the CloudWatchLogs service with the region and, if set, --endpoint.
    • cloudwatchlogs_describe_log_groups() and cloudwatchlogs_filter_log_events() return the same keys as the awscli custom mode, read Events, pass LogStreamNames from stream_names and keep paginating with NextToken.
    • --endpoint is documented in the help.
  • src/cloud/aws/cloudwatchlogs/mode/listgroups.pm: manage_selection() returns the sorted list of group names for both custom modes, used by the text output and by --disco-show.
  • No change to the awscli custom mode, to the get-logs mode or to the options. With awscli, the only visible change is that the list-groups output is now sorted.

Fixes # (no existing issue)

Type of change

  • Patch fixing an issue (non-breaking change)
  • New functionality (non-breaking change)
  • Functionality enhancement or optimization (non-breaking change)
  • Breaking change (patch or feature) that might cause side effects breaking part of the Software

How this pull request can be tested ?

New Robot Framework tests in tests/cloud/aws/cloudwatchlogs/. Every case runs with both custom modes, so the tests also check that paws and awscli give the same results:

  • listgroups.robot (5 cases): text output, --disco-format, --disco-show.
  • getlogs.robot (11 cases): no status threshold, --warning-status / --critical-status on %{message}, --stream-name filter, status on %{stream_name}.
  • paws: Mockoon mock cloud-aws-cloudwatchlogs.json, reached with --endpoint=http://localhost:3000/logs/.... It answers DescribeLogGroups and FilterLogEvents and returns only the events of app-stream-2 when the request body contains logStreamNames.
  • awscli: fake aws command in bin/ (--command-path) that prints the JSON fixtures of data/.
  • All test data is fake (demo-* log groups, key / secret credentials).
robot --exclude notauto tests/cloud/aws/cloudwatchlogs/
Cloudwatchlogs.Getlogs :: AWS CloudWatch Logs get-logs mode       | PASS |
11 tests, 11 passed, 0 failed
Cloudwatchlogs.Listgroups :: AWS CloudWatch Logs list-groups mode | PASS |
5 tests, 5 passed, 0 failed

…list-groups

- paws: read the Events field of FilterLogEvents (get-logs always found 0 events)
- paws: pass --stream-name to FilterLogEvents (the filter was ignored)
- paws: return log groups and events with the same keys as awscli
- paws: support --endpoint for CloudWatch Logs and document the option
- list-groups: sorted output, group names also with paws in --disco-show
- add robot tests for get-logs and list-groups with paws (Mockoon) and awscli
@rmorandell-pgum
rmorandell-pgum requested review from a team as code owners November 11, 2026 15:07
@rmorandell-pgum
rmorandell-pgum requested review from jean-christophe81 and omercier and removed request for a team November 11, 2026 15:07

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant