Skip to content

Commit fe8de07

Browse files
lucian-ioanmergify[bot]
authored andcommitted
[AWS Health] Improve error message reporting (#45408)
* parse error message * remove comment * fix CI * add changelog entry (cherry picked from commit 1637c55) # Conflicts: # x-pack/metricbeat/module/aws/awshealth/awshealth.go
1 parent fd3c6b4 commit fe8de07

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

CHANGELOG.next.asciidoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff]
4141
- Add support for Kibana status metricset in v8 format {pull}40275[40275]
4242
- Mark system process metricsets as running if metrics are partially available {pull}40565[40565]
4343
- Fixed a bug where `event.duration` could be missing from an event on Windows systems due to low-resolution clock. {pull}44440[44440]
44+
- Add check for http error codes in the Metricbeat's Prometheus query submodule {pull}44493[44493]
45+
- Sanitize error messages in Fetch method of SQL module {pull}44577[44577]
46+
- Add NTP metricset to system module. {pull}44884[44884]
47+
- Add VPN metrics to meraki module {pull}44851[44851]
48+
- Improve error messages in AWS Health {pull}45408[45408]
4449

4550
*Osquerybeat*
4651

x-pack/metricbeat/module/aws/awshealth/awshealth.go

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,18 @@ package awshealth
66

77
import (
88
"context"
9+
<<<<<<< HEAD
10+
=======
11+
"crypto/fips140"
12+
"errors"
13+
>>>>>>> 1637c556c ([AWS Health] Improve error message reporting (#45408))
914
"fmt"
1015
"time"
1116

1217
awssdk "github.com/aws/aws-sdk-go-v2/aws"
1318
"github.com/aws/aws-sdk-go-v2/service/health"
1419
"github.com/aws/aws-sdk-go-v2/service/health/types"
20+
"github.com/aws/smithy-go"
1521

1622
"github.com/elastic/beats/v7/libbeat/common/cfgwarn"
1723
"github.com/elastic/beats/v7/metricbeat/mb"
@@ -117,7 +123,19 @@ func (m *MetricSet) Fetch(ctx context.Context, report mb.ReporterV2) error {
117123
return err
118124
}
119125

126+
<<<<<<< HEAD
120127
awsConfig := m.MetricSet.AwsConfig.Copy()
128+
=======
129+
// Starting from Go 1.24, when FIPS 140-3 mode is active, fips140.Enabled() will return true.
130+
// So, regardless of whether `fips_enabled` is set to true or false, when FIPS 140-3 mode is active, the
131+
// resolver will resolve to the FIPS endpoint.
132+
// See: https://go.dev/doc/security/fips140#fips-140-3-mode
133+
if fips140.Enabled() {
134+
config.AWSConfig.FIPSEnabled = true
135+
}
136+
137+
awsConfig := m.AwsConfig.Copy()
138+
>>>>>>> 1637c556c ([AWS Health] Improve error message reporting (#45408))
121139

122140
health_client := health.NewFromConfig(awsConfig, func(o *health.Options) {
123141
if config.AWSConfig.FIPSEnabled {
@@ -191,7 +209,13 @@ func (m *MetricSet) getEventDetails(
191209
// Perform actions for the current page
192210
currentPage, err := dePage.NextPage(ctx)
193211
if err != nil {
194-
m.Logger().Errorf("[AWS Health] DescribeEvents failed with : %w", err)
212+
var opErr *smithy.OperationError
213+
if errors.As(err, &opErr) {
214+
m.Logger().Errorf("[AWS Health] DescribeEvents failed with: Operation=%s, UnderlyingError=%v",
215+
opErr.Operation(), opErr.Err)
216+
} else {
217+
m.Logger().Errorf("[AWS Health] DescribeEvents failed with: %w", err)
218+
}
195219
break
196220
}
197221
deEvents = currentPage.Events
@@ -218,7 +242,13 @@ func (m *MetricSet) getEventDetails(
218242
Locale: &locale,
219243
})
220244
if err != nil {
221-
m.Logger().Errorf("[AWS Health] DescribeEventDetails failed with : %w", err)
245+
var opErr *smithy.OperationError
246+
if errors.As(err, &opErr) {
247+
m.Logger().Errorf("[AWS Health] DescribeEventDetails failed with: Operation=%s, UnderlyingError=%v",
248+
opErr.Operation(), opErr.Err)
249+
} else {
250+
m.Logger().Errorf("[AWS Health] DescribeEventDetails failed with: %w", err)
251+
}
222252
break
223253
}
224254
// Fetch event description for the current page of events

0 commit comments

Comments
 (0)