Yelp / elastalert

Easy & Flexible Alerting With ElasticSearch
https://elastalert.readthedocs.org
Apache License 2.0
7.99k stars 1.74k forks source link

percentage_match question #1597

Open galileochoy opened 6 years ago

galileochoy commented 6 years ago

hi,

I have setup the percentage rule like below:

percentage_format_string: '0.2%'

alert: 
- email

alert_text: |
  {0:.2}% of call meet the criteria

  Please check

alert_text_args:
- percentage

But in the email i got this:

2.3e+01% of call meet the criteria

Please check

Percentage violation, value: 23.0769230769 (min: None max : 20)

num_hits: 4998 num_matches: 1 percentage: 23.0769230769 syslog_dateTime: 2018-03-08T11:29:06.115250Z

How to change my setting in order to display 23.08% instead of 2.3e+01% my version is 0.1.21

SpencerMalone commented 5 years ago

{0:.2f}% will do what you want!

nsano-rururu commented 3 years ago

https://github.com/Yelp/elastalert/pull/2537/files

.. note:: If you want to change the percentage format inside your alert, you must specify the format there cause ``percentage_format_string`` wont't be applied.
    Exemple: ``alerta_value: "%(percentage).2f%%"``