Wonderful. It worked:
*- interval: 5minput_series:- series:
'probe_ssl_earliest_cert_expiry{instance="instance1", job="job-1"}'values:
''2*600000 2400000 2200000 2000000'
*- series: 'time'values: '100000000 20000000 25000000
30000000'alert_rule_test:- alertname: CertificateExpiryeval_time:
0mexp_alerts:- exp_labels:severity: warninginstance:
instance1exp_annotations:summary: "Certificate in instance1 is due to
expiry in less than 30 days"description: "Certificate in instance1 is due
to expiry in less than 30 days."*
Thank you sayf!
On Friday, 7 January 2022 at 16:38:57 UTC Emmanuel Alan Ferreyra Montes
wrote:
> Ohh, you mean, relaying on the current time of the test. Let me check if I
> can do it
>
> On Friday, 7 January 2022 at 16:36:15 UTC Emmanuel Alan Ferreyra Montes
> wrote:
>
>> At some point, I will need to define that time function (rather here or
>> in the recording rule) so it won't be enough to relay on the current time.
>>
>> On Friday, 7 January 2022 at 16:29:35 UTC [email protected] wrote:
>>
>>> Imo it is easier to generate your test cases dynamically, you can in
>>> that case choose the values based on the current time
>>>
>>> On Fri, Jan 7, 2022, 16:59 Emmanuel Alan Ferreyra Montes <
>>> [email protected]> wrote:
>>>
>>>> I'm trying to run some tests over an alert I've added but I haven't
>>>> been able to "mock" of defining the value of the function "time". Do you
>>>> know how to do it?
>>>>
>>>> I'm currently doing this:
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> *- interval: 5m input_series: - series:
>>>> 'probe_ssl_earliest_cert_expiry{instance="instance1", job="job-1"}'
>>>> values:
>>>> '17000000 35000000 5000000 10000000' - series: 'time' values: '100000000
>>>> 20000000 25000000 30000000' alert_rule_test: - alertname:
>>>> CertificateExpiry
>>>> eval_time: 0m exp_alerts: - exp_labels: severity: warning instance:
>>>> instance1 exp_annotations: summary: "Certificate in instance1 is due to
>>>> expiry in less than 30 days" description: "Certificate in instance1 is due
>>>> to expiry in less than 30 days."*
>>>>
>>>> and the alert is defined as follow:
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> *- alert: CertificateExpiry expr: probe_ssl_earliest_cert_expiry -
>>>> time() < 86400 * 30 labels: severity: warning annotations: summary:
>>>> "Certificate in {{ $labels.instance }} is due to expiry in less than 30
>>>> days" description: "Certificate in {{ $labels.instance }} is due to expiry
>>>> in less than 30 days."*
>>>>
>>>> Do you know how can I define the values of time in the same way I do it
>>>> with the series?
>>>>
>>>> Thanks in advance,
>>>>
>>>> Emmanuel
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Prometheus Users" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to [email protected].
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/prometheus-users/3d9e32d3-fa3a-4415-8ad7-4c5db5d1e7b8n%40googlegroups.com
>>>>
>>>> <https://groups.google.com/d/msgid/prometheus-users/3d9e32d3-fa3a-4415-8ad7-4c5db5d1e7b8n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>>
--
You received this message because you are subscribed to the Google Groups
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/prometheus-users/1d2c73d9-eb6d-48d2-8bea-f65218fd1f4an%40googlegroups.com.