@@ -120,8 +120,6 @@ def main():
120120 return
121121
122122 z = zipfile .ZipFile (io .BytesIO (x .content ))
123- # z.extractall('/app')
124- #log_folder = '/Users/ykoer/Workspace/ykoer/github-actions-example-workflows/.github/actions/log_to_splunk/tmp'
125123 log_folder = '/tmp'
126124 z .extractall (log_folder )
127125
@@ -158,8 +156,6 @@ def main():
158156 batch += 1
159157 event = {'event' :x ,'sourcetype' :SPLUNK_SOURCETYPE ,'source' :SPLUNK_SOURCE ,'host' :host ,'time' :timestamp ,'fields' :fields }
160158 eventBatch = eventBatch + json .dumps (event )
161- # else:
162- # print("skipped line "+str(count))
163159
164160 # push every 1000 log lines to splunk as a batch
165161 if batch >= 1000 :
@@ -174,11 +170,10 @@ def main():
174170
175171 # push the last batch
176172 if batch > 0 :
177- print (f'log_file={ name } , batch_number={ batch_number } , line_number={ count } ' )
178- # x=requests.post(SPLUNK_HEC_URL, data=eventBatch, headers=headers)
179- # print(f'log_file={name}, batch_number={batch_number}, line_number={count}, request_status_code:{x.status_code}')
173+ # print(f'log_file={name}, batch_number={batch_number}, line_number={count}')
174+ x = requests .post (SPLUNK_HEC_URL , data = eventBatch , headers = headers )
175+ print (f'log_file={ name } , batch_number={ batch_number } , line_number={ count } , request_status_code:{ x .status_code } ' )
180176 eventBatch = ""
181- batch_number += 1
182177
183178if __name__ == '__main__' :
184179 main ()
0 commit comments