Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ELE-2501 - Remove long columns from alerts_v2 population #1408

Merged
merged 6 commits into from
Feb 13, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
{% endif %}
{% endfor %}

{% do elementary.insert_rows(alerts_v2_relation, unhandled_alerts) %}
{% do elementary.insert_rows(alerts_v2_relation, unhandled_alerts, on_query_exceed=populate_alerts_on_query_exceed) %}
{% endif %}
{% do return('') %}
{% endmacro %}
Expand Down Expand Up @@ -57,3 +57,20 @@

{% do return(alert_ids) %}
{% endmacro %}


{% macro populate_alerts_on_query_exceed(alert_row) %}
{% set row_max_size = elementary.get_config_var('query_max_size') %}

{# alert data contains data that could exceed the query size limit #}
{# We remove the problematic fields to insure the query is in the right size #}
{% set alert_data = alert_row['data'] %}
{% set alert_data_dict = fromjson(alert_data) %}
{% set risky_fields = ['test_rows_sample', 'test_results_query'] %}
{% for risky_field in risky_fields %}
{% if (tojson(alert_data_dict[risky_field]) | length) > (row_max_size / 3) %}
{% do alert_data_dict.update({risky_field: none}) %}
{% endif %}
{% endfor %}
{% do alert_row.update({'data': tojson(alert_data_dict)}) %}
{% endmacro %}
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@
}
%}

{% set column_size = elementary.get_column_size() %}
{% if column_size and ((tojson(test_alert_data) | length) > column_size) %}
{% do test_alert_data.update({'test_rows_sample': none}) %}
{% endif %}

{% set test_alert = elementary_cli.generate_alert_object(
raw_test_alert.alert_id,
raw_test_alert.alert_class_id,
Expand Down
Loading