Skip to content

Commit

Permalink
Merge pull request #45 from pomjuice/master
Browse files Browse the repository at this point in the history
Fix fluentd timestamp
  • Loading branch information
ddbnl authored Mar 6, 2024
2 parents 958a5b4 + 2e8571b commit 4a5e15a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Source/Interfaces/FluentdInterface.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from . import _Interface
import logging
import datetime
from fluent import sender


Expand Down Expand Up @@ -39,9 +40,13 @@ def logger(self):

def _send_message(self, msg, content_type, **kwargs):

creation_time = datetime.datetime.strptime(msg['CreationTime'], "%Y-%m-%dT%H:%M:%S").replace(tzinfo=datetime.timezone.utc)
unixtime = int(creation_time.timestamp())

try:
msg['tenant'] = self.tenant_name
self.logger.emit(content_type, msg)
self.logger.emit_with_time(content_type, unixtime, msg)

self.successfully_sent += 1
except Exception as e:
logging.error("Error outputting to Fluentd: {}".format(e))
Expand Down

0 comments on commit 4a5e15a

Please sign in to comment.