Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

fix(alerts): phase2 bugs #1010

Merged
merged 3 commits into from
Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ frontend
.env
docker
.venv
.envrc
.direnv
.cache
6 changes: 5 additions & 1 deletion chaos_genius/alerts/anomaly_alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,11 @@ def kpi_link(self):

def alert_dashboard_link(self):
"""Returns a link to the alert dashboard."""
return f"{webapp_url_prefix()}api/digest?alert={self.alert_id}"
subdim_part = ""
if self.include_subdims:
subdim_part = "&subdims=true"

return f"{webapp_url_prefix()}api/digest?alert={self.alert_id}{subdim_part}"

def date_formatted(self):
"""Returns date formatted for readability."""
Expand Down
2 changes: 1 addition & 1 deletion chaos_genius/alerts/email_templates/common.html
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@
-->{% if point.relevant_subdims is not none -%}
<ul>
<li>
<span style="{{ non_important_text }}">Key dimensions impacted:</span>
<span style="{{ non_important_text }}">Reasons for change:</span>
{% for point in point.top_relevant_subdims() %}
{{ subdim_name_link(point, value_only=true) }}<!--
-->{% if not loop.last -%}
Expand Down
5 changes: 3 additions & 2 deletions chaos_genius/alerts/slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def anomaly_point_formatting(
else:
out += " detected "
if point.is_subdim:
out += f" in {subdim_name_link(point)} "
out += f"in {subdim_name_link(point)} "

if point.previous_value is None:
out += f"- changed to *{point.y_readable}*"
Expand Down Expand Up @@ -318,7 +318,7 @@ def anomaly_point_formatting(
else:
out += " detected "
if point.is_subdim:
out += f" in {subdim_name_link(point)} "
out += f"in {subdim_name_link(point)} "

out += f"- changed to *{point.y_readable}*"

Expand All @@ -335,6 +335,7 @@ def anomaly_point_formatting(
out += "\n - Reasons for change: "
for point in point.top_relevant_subdims() or []:
out += f"{subdim_name_link(point, value_only=True)}, "
out = out[:-2]

out += "\n"

Expand Down
2 changes: 1 addition & 1 deletion chaos_genius/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def create_app(config_object="chaos_genius.settings"):

:param config_object: The configuration object to use.
"""
app = Flask(__name__.split(".")[0])
app = Flask(__name__.split(".")[0], static_url_path="/api/static")
app.config.from_object(config_object)
register_extensions(app)
register_blueprints(app)
Expand Down
5 changes: 5 additions & 0 deletions chaos_genius/controllers/digest_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,15 @@ def kpi_link_prefix() -> str:

def alert_dashboard_link(self) -> str:
"""Return the link to the alert dashboard."""
subdim_part = ""
if self.top_subdim_anomalies:
subdim_part = "&subdims=true"

return (
f"{webapp_url_prefix()}api/digest"
+ "?date="
+ quote_plus(self.report_date.strftime(ALERT_DATE_FORMAT))
+ subdim_part
)

def report_date_formatted(self) -> str:
Expand Down
17 changes: 9 additions & 8 deletions frontend/nginx/nginx-default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ server {
index index.html index.htm;
root /usr/share/nginx/html;

# anything to do with the API must be passed to it
location ^~ /api/ {
resolver 127.0.0.11 valid=30s;
set $chaosgenius_server chaosgenius-server;
proxy_read_timeout 1h;
proxy_pass http://$chaosgenius_server:5000;
proxy_set_header Host $http_host;
}

# Any route containing a file extension (e.g. /devicesfile.js)
location ~ ^.+\..+$ {
try_files $uri =404;
Expand All @@ -15,14 +24,6 @@ server {
try_files $uri $uri/ /index.html;
}

location /api/ {
resolver 127.0.0.11 valid=30s;
set $chaosgenius_server chaosgenius-server;
proxy_read_timeout 1h;
proxy_pass http://$chaosgenius_server:5000;
proxy_set_header Host $http_host;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
Expand Down