@@ -69,6 +69,7 @@ def __init__(self, dt_url: str, dt_api_key_parameter: str, verify_ssl: bool = Tr
69
69
self ._approx_buffered_messages_size = LIST_BRACKETS_LENGTH
70
70
self ._messages = []
71
71
self ._batch_num = 1
72
+ self ._s3_source = ""
72
73
73
74
retry_strategy = Retry (
74
75
total = 3 ,
@@ -96,6 +97,9 @@ def is_empty(self):
96
97
def get_environment_url (self ):
97
98
return self ._environment_url
98
99
100
+ def set_s3_source (self , bucket : str , key : str ):
101
+ self ._s3_source = f"{ bucket } /{ key } "
102
+
99
103
def push (self , message : dict ):
100
104
# Validate that the message size doesn't reach DT limits. If so,
101
105
# truncate the "content" field.
@@ -128,6 +132,7 @@ def empty_sink(self):
128
132
self ._messages = []
129
133
self ._approx_buffered_messages_size = LIST_BRACKETS_LENGTH
130
134
self ._batch_num = 1
135
+ self ._s3_source = ""
131
136
132
137
def check_log_message_size_and_truncate (self , message : dict ):
133
138
'''
@@ -211,28 +216,28 @@ def ingest_logs(self, logs: list, session=None,
211
216
unit = MetricUnit .Count , value = 1 )
212
217
elif resp .status_code == 200 :
213
218
logger .warning (
214
- '%s: Parts of batch %s were not successfully posted: %s' ,tenant_id , batch_num , resp .text )
219
+ '%s: Parts of batch %s were not successfully posted: %s. Source file: %s ' ,tenant_id , batch_num , resp .text , self . _s3_source )
215
220
metrics .add_metric (
216
221
name = 'DynatraceHTTP200PartialSuccess' , unit = MetricUnit .Count , value = 1 )
217
222
elif resp .status_code == 400 :
218
223
logger .warning (
219
- '%s: Parts of batch %s were not successfully posted: %s' ,tenant_id , batch_num , resp .text )
224
+ '%s: Parts of batch %s were not successfully posted: %s. Source file: %s ' ,tenant_id , batch_num , resp .text , self . _s3_source )
220
225
metrics .add_metric (
221
226
name = 'DynatraceHTTP400InvalidLogEntries' , unit = MetricUnit .Count , value = 1 )
222
227
elif resp .status_code == 429 :
223
- logger .error ("%s: Throttled by Dynatrace. Exhausted retry attempts..." , tenant_id )
228
+ logger .error ("%s: Throttled by Dynatrace. Exhausted retry attempts... Source file: %s " , tenant_id , self . _s3_source )
224
229
metrics .add_metric (name = 'DynatraceHTTP429Throttled' ,unit = MetricUnit .Count , value = 1 )
225
230
metrics .add_metric (name = 'DynatraceHTTPErrors' , unit = MetricUnit .Count , value = 1 )
226
231
raise DynatraceThrottlingException
227
232
elif resp .status_code == 503 :
228
- logger .error ("%s: Usable space limit reached. Exhausted retry attempts..." , tenant_id )
233
+ logger .error ("%s: Usable space limit reached. Exhausted retry attempts... Source file: %s" , tenant_id , self . _s3_source )
229
234
metrics .add_metric (name = 'DynatraceHTTP503SpaceLimitReached' ,unit = MetricUnit .Count , value = 1 )
230
235
metrics .add_metric (name = 'DynatraceHTTPErrors' , unit = MetricUnit .Count , value = 1 )
231
236
raise DynatraceThrottlingException
232
237
else :
233
238
logger .error (
234
- "%s: There was a HTTP %d error posting batch %d to Dynatrace. %s" ,
235
- tenant_id ,resp .status_code , batch_num , resp .text )
239
+ "%s: There was a HTTP %d error posting batch %d to Dynatrace. %s. Source file: %s " ,
240
+ tenant_id ,resp .status_code , batch_num , resp .text , self . _s3_source )
236
241
metrics .add_metric (name = 'DynatraceHTTPErrors' ,
237
242
unit = MetricUnit .Count , value = 1 )
238
243
raise DynatraceIngestionException
0 commit comments