Skip to content

Commit

Permalink
Merge pull request #42 from PandelisZ/main
Browse files Browse the repository at this point in the history
feat: allow setting a service name for unknown services
  • Loading branch information
dasfmi authored Mar 27, 2024
2 parents a7cb8f4 + d19aa4f commit 03a3789
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
axiom_dataset = os.getenv("AXIOM_DATASET")
disable_json = os.getenv("DISABLE_JSON", "false") == "true"
data_tags_string = os.getenv("DATA_TAGS")
data_service_name = os.getenv("DATA_MESSAGE_KEY")

data_tags = {}
if data_tags_string != "":
Expand Down Expand Up @@ -123,9 +124,16 @@ def split_log_group(log_group: str):
pattern_obj = re.compile("^/aws/(lambda|apigateway|eks|rds)/(.*)")
parsed = pattern_obj.match(log_group)
if parsed is None:
return {"serviceName": "unknown", "logGroupName": log_group}
return {
"serviceName": data_service_name
if data_service_name is not None
else "unknown",
"logGroupName": log_group,
}

service_name = parsed.group(1)
service_name = (
data_service_name if data_service_name is not None else parsed.group(1)
)
log_group_name = parsed.group(2)

return {
Expand Down

0 comments on commit 03a3789

Please sign in to comment.