Skip to content

Commit

Permalink
#247 Apply suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
jmapro committed Feb 22, 2021
1 parent a29ca48 commit 9588fb1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
1 change: 0 additions & 1 deletion scripts/module/gen_detectors.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@ done
for detector in ${TARGET}/conf/[0-9][0-9]-*.yaml; do
for dst in variables detectors; do
j2 ./scripts/templates/$(echo ${dst} | sed 's/detectors/detector/').tf.j2 ${detector} >> ${TARGET}/${dst}-gen.tf
terraform fmt ${TARGET}/${dst}-gen.tf
done
done
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 }}}{%- if rule.lasting is string %}, lasting=${var.{{ id }}_lasting_{{severity}}}{%- endif %})
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
11 changes: 9 additions & 2 deletions scripts/templates/variables.tf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,18 @@ variable "{{ id }}_disabled_{{ severity }}" {
default = null
}
{% if rule.lasting is string %}
variable "{{ id }}_lasting_{{ severity }}" {
description = "Use lasting in {{ severity }} alerting rule for {{ id }} detector"
variable "{{ id }}_lasting_duration_{{ severity }}" {
description = "Minimum duration that conditions must be true before raising alert (in seconds)"
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

0 comments on commit 9588fb1

Please sign in to comment.