Skip to content

Commit deb2fb0

Browse files
committed
Fix log parser
1 parent ef6f131 commit deb2fb0

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

config/envoy/envoy.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ static_resources:
2424
route:
2525
cluster: api_service
2626
prefix_rewrite: "/"
27-
timeout: 90s
27+
timeout: 180s
2828
- match:
2929
prefix: "/slackbot/"
3030
route:

services/log-parser/src/providers/coralogix/processor.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -90,18 +90,21 @@ def process_template_group(group):
9090
return df
9191

9292
df_enriched_clusters = df.groupby("EventTemplate").apply(process_template_group)
93-
df_enriched_clusters = df_enriched_clusters.reset_index().drop(
94-
columns=["level_1", "Content"]
95-
)
93+
df_enriched_clusters = df_enriched_clusters.reset_index()
9694
df_enriched_clusters["percentage"] = (
9795
df_enriched_clusters["occurrences"] / len(df) * 100
9896
)
9997
df_enriched_clusters = df_enriched_clusters.sort_values(
10098
"occurrences", ascending=False
10199
)
100+
try:
101+
df_enriched_clusters = df_enriched_clusters.drop(columns=["level_1", "Content"])
102+
except Exception as e:
103+
print("Error: ", e)
102104

103-
# Remove log groups with only one occurrence
104-
df_enriched_clusters = df_enriched_clusters[df_enriched_clusters["occurrences"] > 1]
105+
# Get top 10 clusters by occurrences
106+
# TODO: we can use the elbow method here to find the optimal number of clusters
107+
df_enriched_clusters = df_enriched_clusters.head(10)
105108

106109
records = df_enriched_clusters.to_dict(orient="records")
107110
for record in records:
@@ -132,6 +135,8 @@ def parse_raw_logs(logs: str):
132135
# Maybe we should use that in the future.
133136
if warning and not pd.isna(warning):
134137
continue
138+
if type(batch) != dict:
139+
continue
135140

136141
for result in batch["results"]:
137142
logs.append(result)

0 commit comments

Comments
 (0)