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

Jinja template is not updated when using an alert-specific alert_text #653

Closed
thib12 opened this issue Jan 11, 2022 · 1 comment · Fixed by #654
Closed

Jinja template is not updated when using an alert-specific alert_text #653

thib12 opened this issue Jan 11, 2022 · 1 comment · Fixed by #654

Comments

@thib12
Copy link

thib12 commented Jan 11, 2022

To reproduce, in rule.yml add the following parameters:

alert_text_type: alert_text_jinja
alert_text: "Test"
alert:
  - slack:
      alert_text_type: alert_text_jinja
      alert_text: |
        An abnormal number ({{spike_count}}) of events occurred.

This is done as described in the documentation
You will then notice that your alert on Slack will not use the relevant Jinja template when using the FileRulesLoader.

The most likely cause is that the Jinja template is not recompiled as in https://github.com/jertel/elastalert2/blob/master/elastalert/loaders.py#L469, and therefore a wrong template (the one using the alert_text at the root of the config) is used.

@thib12 thib12 changed the title Jira template is not updated when using an alert-specific alert_text Jinja template is not updated when using an alert-specific alert_text Jan 11, 2022
@jertel
Copy link
Owner

jertel commented Jan 11, 2022

It looks like you could take lines 469-474 and and re-use them after line 522, preferably in a re-usable load_template() function. Feel free to submit a PR if you're interested in seeing this behavior changed for the next release.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants