@@ -7,12 +7,14 @@ package awshealth
7
7
import (
8
8
"context"
9
9
"crypto/fips140"
10
+ "errors"
10
11
"fmt"
11
12
"time"
12
13
13
14
awssdk "github.com/aws/aws-sdk-go-v2/aws"
14
15
"github.com/aws/aws-sdk-go-v2/service/health"
15
16
"github.com/aws/aws-sdk-go-v2/service/health/types"
17
+ "github.com/aws/smithy-go"
16
18
17
19
"github.com/elastic/beats/v7/libbeat/common/cfgwarn"
18
20
"github.com/elastic/beats/v7/metricbeat/mb"
@@ -126,7 +128,7 @@ func (m *MetricSet) Fetch(ctx context.Context, report mb.ReporterV2) error {
126
128
config .AWSConfig .FIPSEnabled = true
127
129
}
128
130
129
- awsConfig := m .MetricSet . AwsConfig .Copy ()
131
+ awsConfig := m .AwsConfig .Copy ()
130
132
131
133
health_client := health .NewFromConfig (awsConfig , func (o * health.Options ) {
132
134
if config .AWSConfig .FIPSEnabled {
@@ -200,7 +202,13 @@ func (m *MetricSet) getEventDetails(
200
202
// Perform actions for the current page
201
203
currentPage , err := dePage .NextPage (ctx )
202
204
if err != nil {
203
- m .Logger ().Errorf ("[AWS Health] DescribeEvents failed with : %w" , err )
205
+ var opErr * smithy.OperationError
206
+ if errors .As (err , & opErr ) {
207
+ m .Logger ().Errorf ("[AWS Health] DescribeEvents failed with: Operation=%s, UnderlyingError=%v" ,
208
+ opErr .Operation (), opErr .Err )
209
+ } else {
210
+ m .Logger ().Errorf ("[AWS Health] DescribeEvents failed with: %w" , err )
211
+ }
204
212
break
205
213
}
206
214
deEvents = currentPage .Events
@@ -227,7 +235,13 @@ func (m *MetricSet) getEventDetails(
227
235
Locale : & locale ,
228
236
})
229
237
if err != nil {
230
- m .Logger ().Errorf ("[AWS Health] DescribeEventDetails failed with : %w" , err )
238
+ var opErr * smithy.OperationError
239
+ if errors .As (err , & opErr ) {
240
+ m .Logger ().Errorf ("[AWS Health] DescribeEventDetails failed with: Operation=%s, UnderlyingError=%v" ,
241
+ opErr .Operation (), opErr .Err )
242
+ } else {
243
+ m .Logger ().Errorf ("[AWS Health] DescribeEventDetails failed with: %w" , err )
244
+ }
231
245
break
232
246
}
233
247
// Fetch event description for the current page of events
0 commit comments