Skip to content

Commit f559d6b

Browse files
authored
Merge pull request #110 from andrewm4894/alert-plot-cleanup
Alert plot cleanup
2 parents 0921246 + ab9f744 commit f559d6b

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

anomstack/alerts/slack.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ def send_alert_slack(
122122
response = client.chat_postMessage(
123123
channel=channel_id, text=f"*{title}*\n{message}"
124124
)
125-
logger.debug(f"Slack response: {response}")
126125
except SlackApiError as e:
127126
logger.error(f"Error sending message to Slack: {e.response['error']}")
128127

anomstack/jobs/alert.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def alert(df_alerts) -> pd.DataFrame:
115115
"metric_batch": metric_batch,
116116
"metric_name": metric_name,
117117
"metric_timestamp": metric_timestamp_max,
118-
"alert_type": "ml",
118+
"alert_type": "anomaly",
119119
**metric_tags.get(metric_name, {}),
120120
}
121121
logger.debug(f"metric tags:\n{tags}")

anomstack/plots/plot.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,18 @@ def make_alert_plot(
4545
n = len(df_plot)
4646

4747
ax1 = df_plot["metric_value"].plot(
48-
title=f"{metric_name} (n={n})", ax=axes[0], style="-o", color="royalblue"
48+
title=f"{metric_name} (n={n})",
49+
ax=axes[0],
50+
style="-",
51+
color="royalblue",
52+
markersize=3,
4953
)
5054
if "metric_value_smooth" in df_plot.columns:
5155
df_plot["metric_value_smooth"].plot(
52-
ax=axes[0], style="--", color="darkorange", label="Value Smooth"
56+
ax=axes[0],
57+
style="--",
58+
color="darkorange",
59+
label="metric_value_smooth"
5360
)
5461
ax1.axes.get_xaxis().set_visible(False)
5562
ax1.grid(True, which="both", linestyle="--", linewidth=0.5)
@@ -67,9 +74,10 @@ def make_alert_plot(
6774
alert_points = df_plot[df_plot["metric_alert"] == 1]
6875
ax2.scatter(
6976
alert_points.index,
70-
alert_points["metric_alert"],
77+
alert_points["metric_score"],
7178
color="red",
72-
label=alert_type
79+
label=alert_type,
80+
s=5,
7381
)
7482
ax2.axhline(
7583
threshold, color="lightgrey", linestyle="-.",
@@ -90,8 +98,8 @@ def make_alert_plot(
9098
ax2.locator_params(axis="x", nbins=25)
9199

92100
for idx in alert_points.index:
93-
ax1.axvline(idx, color="yellow", alpha=0.3)
94-
ax2.axvline(idx, color="yellow", alpha=0.3)
101+
ax1.axvline(idx, color="grey", alpha=0.2)
102+
ax2.axvline(idx, color="grey", alpha=0.2)
95103

96104
plt.tight_layout()
97105

0 commit comments

Comments
 (0)