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

Feature/lasting #248

Merged
merged 4 commits into from
Feb 22, 2021
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion scripts/templates/detector.tf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ resource "signalfx_detector" "{{ id }}" {
{%- else %}
{%- set negative_comparator = reverse_comparator ~ '=' %}
{%- endif %}
detect(when(signal {{ rule.comparator }} ${var.{{ id }}_threshold_{{ severity }}})
detect(when(signal {{ rule.comparator }} ${var.{{ id }}_threshold_{{ severity }}}{%- if rule.lasting is string %}, lasting='${var.{{ id }}_lasting_duration_{{severity}}}'{%- endif %}{%- if rule.at_least is number %}, at_least=${var.{{ id }}_at_least_percentage_{{ severity }}}{%- endif %})
{%- if 'dependency' in rule %} and when(signal {{ negative_comparator }} ${var.{{ id }}_threshold_{{ rule.dependency }}}){%- endif -%})
{%- endif -%}
.publish('{{ severity_label }}')
Expand Down
12 changes: 12 additions & 0 deletions scripts/templates/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,15 @@ rules:
## This will add another condition to negate the dependecy like:
## when(signal > {{severity}}) and when(signal <= {{severity.dependency}})
#dependency:

## @param lasting - string - optional
## Minimum duration that conditions must be true
## before raising alert (in seconds)
jmapro marked this conversation as resolved.
Show resolved Hide resolved
lasting:
jmapro marked this conversation as resolved.
Show resolved Hide resolved

## @param at_least - number - option
## Percentage of lasting that conditions must be true
## before raising alert (>= 0.0 and <= 1.0)
## lasting value is mandatory to use this parameter
at_least:
jmapro marked this conversation as resolved.
Show resolved Hide resolved

15 changes: 14 additions & 1 deletion scripts/templates/variables.tf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,20 @@ variable "{{ id }}_disabled_{{ severity }}" {
type = bool
default = null
}

{% if rule.lasting is string %}
variable "{{ id }}_lasting_duration_{{ severity }}" {
description = "Minimum duration that conditions must be true before raising alert (in seconds)"
jmapro marked this conversation as resolved.
Show resolved Hide resolved
type = string
default = "{{ rule.lasting }}"
}
{% endif -%}
{% if rule.at_least is number %}
variable "{{ id }}_at_least_percentage_{{ severity }}" {
description = "Percentage of lasting that conditions must be true before raising alert (>= 0.0 and <= 1.0)"
type = number
default = "{{ rule.at_least }}"
}
{% endif %}
{% endfor -%}
{% endif -%}

Expand Down