Skip to content

Commit

Permalink
feat : convert module integration_aws-elasticsearch to gen format
Browse files Browse the repository at this point in the history
feat : convert module integration_aws-elasticache-common to gen format
feat : support for multiple signal in rules
feat : support for multiple time the same severity in rules
  • Loading branch information
haedri committed Nov 15, 2023
1 parent 33027d6 commit bd49248
Show file tree
Hide file tree
Showing 35 changed files with 1,716 additions and 871 deletions.
10 changes: 5 additions & 5 deletions modules/integration_aws-elasticache-common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Note the following parameters:

These 3 parameters along with all variables defined in [common-variables.tf](common-variables.tf) are common to all
[modules](../) in this repository. Other variables, specific to this module, are available in
[variables.tf](variables.tf).
[variables-gen.tf](variables-gen.tf).
In general, the default configuration "works" but all of these Terraform
[variables](https://www.terraform.io/language/values/variables) make it possible to
customize the detectors behavior to better fit your needs.
Expand All @@ -77,11 +77,11 @@ This module creates the following SignalFx detectors which could contain one or
|---|---|---|---|---|---|
|AWS ElastiCache heartbeat|X|-|-|-|-|
|AWS ElastiCache evictions|X|X|-|-|-|
|AWS ElastiCache connections over max allowed|X|-|-|-|-|
|AWS ElastiCache current connections|X|-|-|-|-|
|AWS ElastiCache max connection|X|-|-|-|-|
|AWS ElastiCache no connection|X|-|-|-|-|
|AWS ElastiCache swap|X|X|-|-|-|
|AWS ElastiCache freeable memory|-|X|X|-|-|
|AWS ElastiCache evictions changing rate grows|X|X|-|-|-|
|AWS ElastiCache free memory|-|X|X|-|-|
|AWS ElastiCache evictions growing|X|X|-|-|-|

## How to collect required metrics?

Expand Down

This file was deleted.

4 changes: 4 additions & 0 deletions modules/integration_aws-elasticache-common/common-filters.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
locals {
filters = "filter('aws_tag_env', '${var.environment}') and filter('aws_tag_sfx_monitored', 'true')"
}

This file was deleted.

44 changes: 44 additions & 0 deletions modules/integration_aws-elasticache-common/common-locals.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
locals {
heartbeat_auto_resolve_after = "1s"
not_running_vm_filters_gcp = "(not filter('gcp_status', '{Code=3, Name=STOPPING}', '{Code=4, Name=TERMINATED}'))"
not_running_vm_filters_aws = "(not filter('aws_state', '{Code: 32,Name: shutting-down}', '{Code: 48,Name: terminated}', '{Code: 64,Name: stopping}', '{Code: 80,Name: stopped}'))"
not_running_vm_filters_azure = "(not filter('azure_power_state', 'PowerState/stopping', 'PowerState/stopped', 'PowerState/deallocating', 'PowerState/deallocated'))"
not_running_vm_filters = format(
"%s and %s and %s",
local.not_running_vm_filters_aws,
local.not_running_vm_filters_gcp,
local.not_running_vm_filters_azure
)
detector_name_prefix = "${join("", formatlist("[%s]", var.prefixes))}[${var.environment}]"
common_tags = concat(["terraform", var.environment], var.teams)
rule_subject_prefix = "[{{ruleSeverity}}]{{{detectorName}}} {{{readableRule}}}"
rule_subject_suffix = "on {{{dimensions}}}"
rule_subject = format("%s ({{inputs.signal.value}}) %s", local.rule_subject_prefix, local.rule_subject_suffix)
rule_subject_novalue = format("%s %s", local.rule_subject_prefix, local.rule_subject_suffix)
rule_body = <<-EOF
**Alert**:
*[{{ruleSeverity}}]{{{detectorName}}} {{{readableRule}}} ({{inputs.signal.value}})*
{{#if anomalous}}
**Triggered at**:
*{{timestamp}}*
{{else}}
**Cleared at**:
*{{timestamp}}*
{{/if}}
{{#notEmpty dimensions}}
**Dimensions**:
*{{{dimensions}}}*
{{/notEmpty}}
{{#if anomalous}}
{{#if runbookUrl}}**Runbook**:
Go to [this page]({{{runbookUrl}}}) for help and analysis.
{{/if}}
{{#if tip}}**Tip**:
{{{tip}}}
{{/if}}
{{/if}}
EOF
}

This file was deleted.

8 changes: 8 additions & 0 deletions modules/integration_aws-elasticache-common/common-modules.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module "filtering" {
source = "../internal_filtering"

filtering_default = local.filters
filtering_custom = var.filtering_custom
append_mode = var.filtering_append
}

This file was deleted.

78 changes: 78 additions & 0 deletions modules/integration_aws-elasticache-common/common-variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Global

variable "environment" {
description = "Infrastructure environment"
type = string
}

variable "notifications" {
description = "Default notification recipients list per severity"
type = object({
critical = list(string)
major = list(string)
minor = list(string)
warning = list(string)
info = list(string)
})
}

variable "prefixes" {
description = "Prefixes list to prepend between brackets on every monitors names before environment"
type = list(string)
default = []
}

variable "filtering_custom" {
description = "Filters as SignalFlow string to either replace or append to default filtering convention which is the only one used if not defined"
type = string
default = null
}

variable "filtering_append" {
description = "If true, the `filtering_custom` string will be appended to the default filtering convention instead of fully replace it"
type = bool
default = false
}

variable "detectors_disabled" {
description = "Disable all detectors in this module"
type = bool
default = false
}

variable "runbook_url" {
description = "Default runbook URL to apply to all detectors (if not overridden at detector level)"
type = string
default = ""
}

variable "authorized_writer_teams" {
description = "List of teams IDs authorized (with admins) to edit the detector. If defined, it requires an user token to work"
type = list(string)
default = null
}

variable "teams" {
description = "List of teams IDs to associate the detector to"
type = list(string)
default = []
}

variable "message_subject" {
description = "The subject to use in alerting rules messages which overrides the default template"
type = string
default = ""
}

variable "message_body" {
description = "The body to use in alerting rules messages which overrides the default template"
type = string
default = ""
}

variable "extra_tags" {
description = "List of tags to add to the detectors resources, useful to find detectors "
type = list(string)
default = []
}

This file was deleted.

9 changes: 9 additions & 0 deletions modules/integration_aws-elasticache-common/common-versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
terraform {
required_providers {
signalfx = {
source = "splunk-terraform/signalfx"
version = ">= 7.0.0"
}
}
required_version = ">= 0.12.26"
}
12 changes: 12 additions & 0 deletions modules/integration_aws-elasticache-common/conf/00-heartbeat.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module: AWS ElastiCache
name: heartbeat

transformation: false
aggregation: ".mean(by=['CacheClusterId'])"
filtering: "filter('stat', 'mean') and filter('namespace', 'AWS/ElastiCache')"

signals:
signal:
metric: CPUUtilization
rules:
critical:
21 changes: 21 additions & 0 deletions modules/integration_aws-elasticache-common/conf/01-evictions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module: AWS ElastiCache
name: "Evictions"

transformation: ".sum(over='15m')"
aggregation: true

filtering: "filter('namespace', 'AWS/ElastiCache')"

signals:
signal:
metric: "Evictions"
filter: "filter('stat', 'mean') and filter('CacheNodeId', '*')"

rules:
major:
threshold: 0
comparator: ">"
dependency: critical
critical:
threshold: 30
comparator: ">"
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module: AWS ElastiCache
name: "Max connection"

transformation: ".max(over='5m')"
aggregation: true

filtering: "filter('namespace', 'AWS/ElastiCache')"

signals:
signal:
metric: "CurrConnections"
filter: "filter('stat', 'upper') and filter('CacheNodeId', '*')"

rules:
critical:
threshold: 64999
comparator: ">"
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module: AWS ElastiCache
name: "No connection"

transformation: ".min(over='5m')"
aggregation: true

filtering: "filter('namespace', 'AWS/ElastiCache')"

signals:
signal:
metric: "CurrConnections"
filter: "filter('stat', 'lower') and filter('CacheNodeId', '*')"

rules:
critical:
threshold: 0
comparator: "<="
21 changes: 21 additions & 0 deletions modules/integration_aws-elasticache-common/conf/04-swap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module: AWS ElastiCache
name: "Swap"

transformation: ".min(over='5m')"
aggregation: true

filtering: "filter('namespace', 'AWS/ElastiCache')"

signals:
signal:
metric: "SwapUsage"
filter: "filter('stat', 'upper') and filter('CacheNodeId', '*')"

rules:
major:
threshold: 0
comparator: ">"
dependency: critical
critical:
threshold: 50000000
comparator: ">"
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module: AWS ElastiCache
name: "Free memory"

transformation: ".rateofchange().mean(over='15m')"
aggregation: true

filtering: "filter('namespace', 'AWS/ElastiCache')"

signals:
signal:
metric: "FreeableMemory"
filter: "filter('stat', 'lower') and filter('CacheNodeId', '*')"

rules:
minor:
threshold: -50
comparator: "<"
dependency: major
major:
threshold: -70
comparator: "<"
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module: AWS ElastiCache
name: "Evictions growing"

transformation: ".mean(over='5m').rateofchange().scale(100)"
aggregation: true

filtering: "filter('namespace', 'AWS/ElastiCache')"

signals:
signal:
metric: "Evictions"
filter: "filter('stat', 'mean') and filter('CacheNodeId', '*')"

rules:
major:
threshold: 10
comparator: ">"
dependency: critical
critical:
threshold: 30
comparator: ">"
Loading

0 comments on commit bd49248

Please sign in to comment.