-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add signalfx detector for azure cdn * Improve cdn detector * Improve cdn detector * Multiple fix on CDN detector * make update-module --------- Co-authored-by: Jérôme Respaut <[email protected]>
- Loading branch information
Showing
15 changed files
with
293 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
# AZURE-CDN SignalFx detectors | ||
|
||
<!-- START doctoc generated TOC please keep comment here to allow auto update --> | ||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> | ||
:link: **Contents** | ||
|
||
- [How to use this module?](#how-to-use-this-module) | ||
- [What are the available detectors in this module?](#what-are-the-available-detectors-in-this-module) | ||
- [How to collect required metrics?](#how-to-collect-required-metrics) | ||
- [Metrics](#metrics) | ||
- [Related documentation](#related-documentation) | ||
|
||
<!-- END doctoc generated TOC please keep comment here to allow auto update --> | ||
|
||
## How to use this module? | ||
|
||
This directory defines a [Terraform](https://www.terraform.io/) | ||
[module](https://www.terraform.io/language/modules/syntax) you can use in your | ||
existing [stack](https://github.com/claranet/terraform-signalfx-detectors/wiki/Getting-started#stack) by adding a | ||
`module` configuration and setting its `source` parameter to URL of this folder: | ||
|
||
```hcl | ||
module "signalfx-detectors-integration-azure-cdn" { | ||
source = "github.com/claranet/terraform-signalfx-detectors.git//modules/integration_azure-cdn?ref={revision}" | ||
environment = var.environment | ||
notifications = local.notifications | ||
} | ||
``` | ||
|
||
Note the following parameters: | ||
|
||
* `source`: Use this parameter to specify the URL of the module. The double slash (`//`) is intentional and required. | ||
Terraform uses it to specify subfolders within a Git repo (see [module | ||
sources](https://www.terraform.io/language/modules/sources)). The `ref` parameter specifies a specific Git tag in | ||
this repository. It is recommended to use the latest "pinned" version in place of `{revision}`. Avoid using a branch | ||
like `master` except for testing purpose. Note that every modules in this repository are available on the Terraform | ||
[registry](https://registry.terraform.io/modules/claranet/detectors/signalfx) and we recommend using it as source | ||
instead of `git` which is more flexible but less future-proof. | ||
|
||
* `environment`: Use this parameter to specify the | ||
[environment](https://github.com/claranet/terraform-signalfx-detectors/wiki/Getting-started#environment) used by this | ||
instance of the module. | ||
Its value will be added to the `prefixes` list at the start of the [detector | ||
name](https://github.com/claranet/terraform-signalfx-detectors/wiki/Templating#example). | ||
In general, it will also be used in the `filtering` internal sub-module to [apply | ||
filters](https://github.com/claranet/terraform-signalfx-detectors/wiki/Guidance#filtering) based on our default | ||
[tagging convention](https://github.com/claranet/terraform-signalfx-detectors/wiki/Tagging-convention) by default. | ||
|
||
* `notifications`: Use this parameter to define where alerts should be sent depending on their severity. It consists | ||
of a Terraform [object](https://www.terraform.io/language/expressions/type-constraints#object) where each key represents an available | ||
[detector rule severity](https://docs.splunk.com/observability/alerts-detectors-notifications/create-detectors-for-alerts.html#severity) | ||
and its value is a list of recipients. Every recipients must respect the [detector notification | ||
format](https://registry.terraform.io/providers/splunk-terraform/signalfx/latest/docs/resources/detector#notification-format). | ||
Check the [notification binding](https://github.com/claranet/terraform-signalfx-detectors/wiki/Notifications-binding) | ||
documentation to understand the recommended role of each severity. | ||
|
||
These 3 parameters alongs 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-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. | ||
|
||
Most of them represent usual tips and rules detailled in the | ||
[guidance](https://github.com/claranet/terraform-signalfx-detectors/wiki/Guidance) documentation and listed in the | ||
common [variables](https://github.com/claranet/terraform-signalfx-detectors/wiki/Variables) dedicated documentation. | ||
|
||
Feel free to explore the [wiki](https://github.com/claranet/terraform-signalfx-detectors/wiki) for more information about | ||
general usage of this repository. | ||
|
||
## What are the available detectors in this module? | ||
|
||
This module creates the following SignalFx detectors which could contain one or multiple alerting rules: | ||
|
||
|Detector|Critical|Major|Minor|Warning|Info| | ||
|---|---|---|---|---|---| | ||
|Azure CDN latency|X|X|-|-|-| | ||
|
||
## How to collect required metrics? | ||
|
||
This module deploys detectors using metrics reported by the | ||
[Azure integration](https://docs.splunk.com/Observability/gdi/get-data-in/connect/azure/azure.html) configurable | ||
with [this Terraform module](https://github.com/claranet/terraform-signalfx-integrations/tree/master/cloud/azure). | ||
|
||
|
||
Check the [Related documentation](#related-documentation) section for more detailed and specific information about this module dependencies. | ||
|
||
|
||
|
||
### Metrics | ||
|
||
|
||
Here is the list of required metrics for detectors in this module. | ||
|
||
* `TotalLatency` | ||
|
||
|
||
|
||
|
||
## Related documentation | ||
|
||
* [Terraform SignalFx provider](https://registry.terraform.io/providers/splunk-terraform/signalfx/latest/docs) | ||
* [Terraform SignalFx detector](https://registry.terraform.io/providers/splunk-terraform/signalfx/latest/docs/resources/detector) | ||
* [Splunk Observability integrations](https://docs.splunk.com/Observability/gdi/get-data-in/integrations.html) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../common/module/filters-integration-azure.tf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../common/module/locals.tf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../common/module/modules.tf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../common/module/variables.tf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../common/module/versions.tf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module: Azure CDN | ||
name: latency | ||
filtering: "filter('resource_type', 'microsoft.cdn/profiles') and filter('primary_aggregation_type', 'true')" | ||
id: cdn_total_latency | ||
value_unit: ms | ||
|
||
transformation: true | ||
aggregation: true | ||
|
||
signals: | ||
signal: | ||
metric: "TotalLatency" | ||
|
||
rules: | ||
critical: | ||
threshold: 3000 | ||
comparator: ">" | ||
lasting_duration: 15m | ||
|
||
major: | ||
threshold: 1500 | ||
comparator: ">" | ||
dependency: critical | ||
lasting_duration: 15m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
documentations: | ||
|
||
source_doc: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
resource "signalfx_detector" "cdn_total_latency" { | ||
name = format("%s %s", local.detector_name_prefix, "Azure CDN latency") | ||
|
||
authorized_writer_teams = var.authorized_writer_teams | ||
teams = try(coalescelist(var.teams, var.authorized_writer_teams), null) | ||
tags = compact(concat(local.common_tags, local.tags, var.extra_tags)) | ||
|
||
viz_options { | ||
label = "signal" | ||
value_suffix = "ms" | ||
} | ||
|
||
program_text = <<-EOF | ||
base_filtering = filter('resource_type', 'microsoft.cdn/profiles') and filter('primary_aggregation_type', 'true') | ||
signal = data('TotalLatency', filter=base_filtering and ${module.filtering.signalflow})${var.cdn_total_latency_aggregation_function}${var.cdn_total_latency_transformation_function}.publish('signal') | ||
detect(when(signal > ${var.cdn_total_latency_threshold_critical}, lasting=%{if var.cdn_total_latency_lasting_duration_critical == null}None%{else}'${var.cdn_total_latency_lasting_duration_critical}'%{endif}, at_least=${var.cdn_total_latency_at_least_percentage_critical})).publish('CRIT') | ||
detect(when(signal > ${var.cdn_total_latency_threshold_major}, lasting=%{if var.cdn_total_latency_lasting_duration_major == null}None%{else}'${var.cdn_total_latency_lasting_duration_major}'%{endif}, at_least=${var.cdn_total_latency_at_least_percentage_major}) and (not when(signal > ${var.cdn_total_latency_threshold_critical}, lasting=%{if var.cdn_total_latency_lasting_duration_critical == null}None%{else}'${var.cdn_total_latency_lasting_duration_critical}'%{endif}, at_least=${var.cdn_total_latency_at_least_percentage_critical}))).publish('MAJOR') | ||
EOF | ||
|
||
rule { | ||
description = "is too high > ${var.cdn_total_latency_threshold_critical}ms" | ||
severity = "Critical" | ||
detect_label = "CRIT" | ||
disabled = coalesce(var.cdn_total_latency_disabled_critical, var.cdn_total_latency_disabled, var.detectors_disabled) | ||
notifications = try(coalescelist(lookup(var.cdn_total_latency_notifications, "critical", []), var.notifications.critical), null) | ||
runbook_url = try(coalesce(var.cdn_total_latency_runbook_url, var.runbook_url), "") | ||
tip = var.cdn_total_latency_tip | ||
parameterized_subject = var.message_subject == "" ? local.rule_subject : var.message_subject | ||
parameterized_body = var.message_body == "" ? local.rule_body : var.message_body | ||
} | ||
|
||
rule { | ||
description = "is too high > ${var.cdn_total_latency_threshold_major}ms" | ||
severity = "Major" | ||
detect_label = "MAJOR" | ||
disabled = coalesce(var.cdn_total_latency_disabled_major, var.cdn_total_latency_disabled, var.detectors_disabled) | ||
notifications = try(coalescelist(lookup(var.cdn_total_latency_notifications, "major", []), var.notifications.major), null) | ||
runbook_url = try(coalesce(var.cdn_total_latency_runbook_url, var.runbook_url), "") | ||
tip = var.cdn_total_latency_tip | ||
parameterized_subject = var.message_subject == "" ? local.rule_subject : var.message_subject | ||
parameterized_body = var.message_body == "" ? local.rule_body : var.message_body | ||
} | ||
|
||
max_delay = var.cdn_total_latency_max_delay | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
output "cdn_total_latency" { | ||
description = "Detector resource for cdn_total_latency" | ||
value = signalfx_detector.cdn_total_latency | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
locals { | ||
tags = ["integration", "azure-cdn"] | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
# cdn_total_latency detector | ||
|
||
variable "cdn_total_latency_notifications" { | ||
description = "Notification recipients list per severity overridden for cdn_total_latency detector" | ||
type = map(list(string)) | ||
default = {} | ||
} | ||
|
||
variable "cdn_total_latency_aggregation_function" { | ||
description = "Aggregation function and group by for cdn_total_latency detector (i.e. \".mean(by=['host'])\")" | ||
type = string | ||
default = "" | ||
} | ||
|
||
variable "cdn_total_latency_transformation_function" { | ||
description = "Transformation function for cdn_total_latency detector (i.e. \".mean(over='5m')\")" | ||
type = string | ||
default = "" | ||
} | ||
|
||
variable "cdn_total_latency_max_delay" { | ||
description = "Enforce max delay for cdn_total_latency detector (use \"0\" or \"null\" for \"Auto\")" | ||
type = number | ||
default = null | ||
} | ||
|
||
variable "cdn_total_latency_tip" { | ||
description = "Suggested first course of action or any note useful for incident handling" | ||
type = string | ||
default = "" | ||
} | ||
|
||
variable "cdn_total_latency_runbook_url" { | ||
description = "URL like SignalFx dashboard or wiki page which can help to troubleshoot the incident cause" | ||
type = string | ||
default = "" | ||
} | ||
|
||
variable "cdn_total_latency_disabled" { | ||
description = "Disable all alerting rules for cdn_total_latency detector" | ||
type = bool | ||
default = null | ||
} | ||
|
||
variable "cdn_total_latency_disabled_critical" { | ||
description = "Disable critical alerting rule for cdn_total_latency detector" | ||
type = bool | ||
default = null | ||
} | ||
|
||
variable "cdn_total_latency_disabled_major" { | ||
description = "Disable major alerting rule for cdn_total_latency detector" | ||
type = bool | ||
default = null | ||
} | ||
|
||
variable "cdn_total_latency_threshold_critical" { | ||
description = "Critical threshold for cdn_total_latency detector in ms" | ||
type = number | ||
default = 3000 | ||
} | ||
|
||
variable "cdn_total_latency_lasting_duration_critical" { | ||
description = "Minimum duration that conditions must be true before raising alert" | ||
type = string | ||
default = "15m" | ||
} | ||
|
||
variable "cdn_total_latency_at_least_percentage_critical" { | ||
description = "Percentage of lasting that conditions must be true before raising alert (>= 0.0 and <= 1.0)" | ||
type = number | ||
default = 1 | ||
} | ||
variable "cdn_total_latency_threshold_major" { | ||
description = "Major threshold for cdn_total_latency detector in ms" | ||
type = number | ||
default = 1500 | ||
} | ||
|
||
variable "cdn_total_latency_lasting_duration_major" { | ||
description = "Minimum duration that conditions must be true before raising alert" | ||
type = string | ||
default = "15m" | ||
} | ||
|
||
variable "cdn_total_latency_at_least_percentage_major" { | ||
description = "Percentage of lasting that conditions must be true before raising alert (>= 0.0 and <= 1.0)" | ||
type = number | ||
default = 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters