Skip to content

Commit 0d30313

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 41ab2f7 commit 0d30313

File tree

2 files changed

+50
-2
lines changed

2 files changed

+50
-2
lines changed

CHANGELOG.next.asciidoc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,24 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff]
4040
- Add support for `_nodes/stats` URIs that work with legacy versions of Elasticsearch {pull}44307[44307]
4141
- Setting period for counter cache for Prometheus remote_write at least to 60sec {pull}38553[38553]
4242
- Remove fallback to the node limit for the `kubernetes.pod.cpu.usage.limit.pct` and `kubernetes.pod.memory.usage.limit.pct` metrics calculation
43+
- Add support for Kibana status metricset in v8 format {pull}40275[40275]
44+
- Mark system process metricsets as running if metrics are partially available {pull}40565[40565]
45+
- Added back `elasticsearch.node.stats.jvm.mem.pools.*` to the `node_stats` metricset {pull}40571[40571]
46+
- Add GCP organization and project details to ECS cloud fields. {pull}40461[40461]
47+
- Add support for specifying a custom endpoint for GCP service clients. {issue}40848[40848] {pull}40918[40918]
48+
- Fix incorrect handling of types in SQL module. {issue}40090[40090] {pull}41607[41607]
49+
- Remove kibana.settings metricset since the API was removed in 8.0 {issue}30592[30592] {pull}42937[42937]
50+
- Removed support for the Enterprise Search module {pull}42915[42915]
51+
- Update NATS module compatibility. Oldest version supported is now 2.2.6 {pull}43310[43310]
52+
- Fix the function to determine CPU cores on windows {issue}42593[42593] {pull}43409[43409]
53+
- Updated list of supported vSphere versions in the documentation. {pull}43642[43642]
54+
- Handle permission errors while collecting data from Windows services and don't interrupt the overall collection by skipping affected services {issue}40765[40765] {pull}43665[43665]
55+
- Fixed a bug where `event.duration` could be missing from an event on Windows systems due to low-resolution clock. {pull}44440[44440]
56+
- Add check for http error codes in the Metricbeat's Prometheus query submodule {pull}44493[44493]
57+
- Sanitize error messages in Fetch method of SQL module {pull}44577[44577]
58+
- Add NTP metricset to system module. {pull}44884[44884]
59+
- Add VPN metrics to meraki module {pull}44851[44851]
60+
- Improve error messages in AWS Health {pull}45408[45408]
4361

4462
*Osquerybeat*
4563

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)