Skip to content

[8.19](backport #45408) [AWS Health] Improve error message reporting #45481

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

Merged
merged 1 commit into from
Jul 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ otherwise no tag is added. {issue}42208[42208] {pull}42403[42403]
- Add check for http error codes in the Metricbeat's Prometheus query submodule {pull}44493[44493]
- Sanitize error messages in Fetch method of SQL module {pull}44577[44577]
- Add VPN metrics to meraki module {pull}44851[44851]
- Improve error messages in AWS Health {pull}45408[45408]

*Osquerybeat*

Expand Down
20 changes: 17 additions & 3 deletions x-pack/metricbeat/module/aws/awshealth/awshealth.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ package awshealth
import (
"context"
"crypto/fips140"
"errors"
"fmt"
"time"

awssdk "github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/health"
"github.com/aws/aws-sdk-go-v2/service/health/types"
"github.com/aws/smithy-go"

"github.com/elastic/beats/v7/libbeat/common/cfgwarn"
"github.com/elastic/beats/v7/metricbeat/mb"
Expand Down Expand Up @@ -126,7 +128,7 @@ func (m *MetricSet) Fetch(ctx context.Context, report mb.ReporterV2) error {
config.AWSConfig.FIPSEnabled = true
}

awsConfig := m.MetricSet.AwsConfig.Copy()
awsConfig := m.AwsConfig.Copy()

health_client := health.NewFromConfig(awsConfig, func(o *health.Options) {
if config.AWSConfig.FIPSEnabled {
Expand Down Expand Up @@ -200,7 +202,13 @@ func (m *MetricSet) getEventDetails(
// Perform actions for the current page
currentPage, err := dePage.NextPage(ctx)
if err != nil {
m.Logger().Errorf("[AWS Health] DescribeEvents failed with : %w", err)
var opErr *smithy.OperationError
if errors.As(err, &opErr) {
m.Logger().Errorf("[AWS Health] DescribeEvents failed with: Operation=%s, UnderlyingError=%v",
opErr.Operation(), opErr.Err)
} else {
m.Logger().Errorf("[AWS Health] DescribeEvents failed with: %w", err)
}
break
}
deEvents = currentPage.Events
Expand All @@ -227,7 +235,13 @@ func (m *MetricSet) getEventDetails(
Locale: &locale,
})
if err != nil {
m.Logger().Errorf("[AWS Health] DescribeEventDetails failed with : %w", err)
var opErr *smithy.OperationError
if errors.As(err, &opErr) {
m.Logger().Errorf("[AWS Health] DescribeEventDetails failed with: Operation=%s, UnderlyingError=%v",
opErr.Operation(), opErr.Err)
} else {
m.Logger().Errorf("[AWS Health] DescribeEventDetails failed with: %w", err)
}
break
}
// Fetch event description for the current page of events
Expand Down
Loading