-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from dasmeta/DMVP-5017-grafana-multi-chanel-al…
…erts feat(DMVP-5017): refactor alerts related config and sub-module structure
- Loading branch information
Showing
85 changed files
with
1,247 additions
and
1,031 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,23 +1,22 @@ | ||
module "alerts" { | ||
source = "./modules/alerts" | ||
|
||
alert_interval_seconds = var.alert_interval_seconds | ||
alert_rules = var.alert_rules | ||
} | ||
module "application_dashboard" { | ||
source = "./modules/dashboard/" | ||
|
||
module "contact_points" { | ||
source = "./modules/contact-points" | ||
count = length(var.application_dashboard) > 0 ? 1 : 0 | ||
|
||
count = length(var.alert_rules) != 0 ? 1 : 0 | ||
|
||
slack_endpoints = var.slack_endpoints | ||
opsgenie_endpoints = var.opsgenie_endpoints | ||
name = var.name | ||
rows = var.application_dashboard.rows | ||
data_source = var.application_dashboard.data_source | ||
variables = var.application_dashboard.variables | ||
} | ||
|
||
module "notifications" { | ||
source = "./modules/notifications" | ||
module "alerts" { | ||
source = "./modules/alerts" | ||
|
||
count = length(var.alert_rules) != 0 ? 1 : 0 | ||
count = var.alerts != null ? 1 : 0 | ||
|
||
notifications = var.notifications | ||
alert_interval_seconds = var.alerts.alert_interval_seconds | ||
disable_provenance = var.alerts.disable_provenance | ||
rules = var.alerts.rules | ||
contact_points = var.alerts.contact_points | ||
notifications = var.alerts.notifications | ||
} |
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,43 @@ | ||
## Usage | ||
This Terraform module enables the creation of Grafana contact points for various integrations such as Slack and OpsGenie. Contact points allow you to configure alert notifications to different services based on your requirements. | ||
|
||
There are numerous integrations available for Grafana, but currently, this module supports only Slack and OpsGenie. We are continuously working to add more integrations in the future. If you have any questions or need assistance, feel free to open an issue or contact our team. | ||
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> | ||
## Requirements | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0 | | ||
| <a name="requirement_grafana"></a> [grafana](#requirement\_grafana) | >= 1.40.0 | | ||
|
||
## Providers | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="provider_grafana"></a> [grafana](#provider\_grafana) | >= 1.40.0 | | ||
|
||
## Modules | ||
|
||
No modules. | ||
|
||
## Resources | ||
|
||
| Name | Type | | ||
|------|------| | ||
| [grafana_contact_point.opsgenie_contact_point](https://registry.terraform.io/providers/grafana/grafana/latest/docs/resources/contact_point) | resource | | ||
| [grafana_contact_point.slack_contact_point](https://registry.terraform.io/providers/grafana/grafana/latest/docs/resources/contact_point) | resource | | ||
| [grafana_contact_point.webhook_contact_point](https://registry.terraform.io/providers/grafana/grafana/latest/docs/resources/contact_point) | resource | | ||
|
||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|------|---------|:--------:| | ||
| <a name="input_disable_provenance"></a> [disable\_provenance](#input\_disable\_provenance) | Allow modifying the contact point from other sources than Terraform or the Grafana API. | `bool` | `true` | no | | ||
| <a name="input_opsgenie_endpoints"></a> [opsgenie\_endpoints](#input\_opsgenie\_endpoints) | OpsGenie contact points list. | <pre>list(object({<br> name = string # The name of the contact point<br> api_key = string # The OpsGenie API key to use<br> auto_close = optional(bool, false) # Whether to auto-close alerts in OpsGenie when they resolve in the Alert manager<br> message = optional(string, "") # The templated content of the message<br> api_url = optional(string, "https://api.opsgenie.com/v2/alerts") # Allows customization of the OpsGenie API URL<br> disable_resolve_message = optional(bool, false) # Whether to disable sending resolve messages<br> }))</pre> | `[]` | no | | ||
| <a name="input_slack_endpoints"></a> [slack\_endpoints](#input\_slack\_endpoints) | Slack contact points list. | <pre>list(object({<br> name = string # The name of the contact point<br> endpoint_url = optional(string, "https://slack.com/api/chat.postMessage") # Use this to override the Slack API endpoint URL to send requests to<br> icon_emoji = optional(string, "") # The name of a Slack workspace emoji to use as the bot icon<br> icon_url = optional(string, "") # A URL of an image to use as the bot icon<br> recipient = optional(string, null) # Channel, private group, or IM channel (can be an encoded ID or a name) to send messages to<br> text = optional(string, "") # Templated content of the message<br> title = optional(string, "") # Templated title of the message<br> token = optional(string, "") # A Slack API token,for sending messages directly without the webhook method<br> webhook_url = optional(string, "") # A Slack webhook URL,for sending messages via the webhook method<br> username = optional(string, "") # Username for the bot to use<br> disable_resolve_message = optional(bool, false) # Whether to disable sending resolve messages<br> }))</pre> | `[]` | no | | ||
| <a name="input_webhook_endpoints"></a> [webhook\_endpoints](#input\_webhook\_endpoints) | Contact points that send notifications to an arbitrary webhook, using the Prometheus webhook format. | <pre>list(object({<br> name = string # The name of the contact point<br> url = string # The URL to send webhook requests to<br> authorization_credentials = optional(string, null) # Allows a custom authorization scheme - attaches an auth header with this value. Do not use in conjunction with basic auth parameters<br> authorization_scheme = optional(string, null) # Allows a custom authorization scheme - attaches an auth header with this name. Do not use in conjunction with basic auth parameters<br> basic_auth_password = optional(string, null) # The password component of the basic auth credentials to use<br> basic_auth_user = optional(string, null) # The username component of the basic auth credentials to use<br> disable_resolve_message = optional(bool, false) # Whether to disable sending resolve messages. Defaults to<br> settings = any # Additional custom properties to attach to the notifier<br> }))</pre> | `[]` | no | | ||
|
||
## Outputs | ||
|
||
No outputs. | ||
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
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
16 changes: 16 additions & 0 deletions
16
modules/alert-contact-points/tests/mixed-contact-points/0-setup.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,16 @@ | ||
terraform { | ||
required_version = ">= 1.3.0" | ||
|
||
required_providers { | ||
grafana = { | ||
source = "grafana/grafana" | ||
version = ">= 3.7.0" | ||
} | ||
} | ||
} | ||
|
||
# you can start dev grafana server locally using `docker compose up -d` from `/tests` folder before running the test locally | ||
provider "grafana" { | ||
url = "http://localhost:3000" | ||
auth = "admin:admin" | ||
} |
File renamed without changes.
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,16 @@ | ||
terraform { | ||
required_version = ">= 1.3.0" | ||
|
||
required_providers { | ||
grafana = { | ||
source = "grafana/grafana" | ||
version = ">= 3.7.0" | ||
} | ||
} | ||
} | ||
|
||
# you can start dev grafana server locally using `docker compose up -d` from `/tests` folder before running the test locally | ||
provider "grafana" { | ||
url = "http://localhost:3000" | ||
auth = "admin:admin" | ||
} |
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,11 @@ | ||
module "this" { | ||
source = "../../" | ||
|
||
opsgenie_endpoints = [ | ||
{ | ||
name = "opsgenie" | ||
api_key = "xxxxxxxx" | ||
auto_close = true | ||
} | ||
] | ||
} |
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,16 @@ | ||
terraform { | ||
required_version = ">= 1.3.0" | ||
|
||
required_providers { | ||
grafana = { | ||
source = "grafana/grafana" | ||
version = ">= 3.7.0" | ||
} | ||
} | ||
} | ||
|
||
# you can start dev grafana server locally using `docker compose up -d` from `/tests` folder before running the test locally | ||
provider "grafana" { | ||
url = "http://localhost:3000" | ||
auth = "admin:admin" | ||
} |
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,10 @@ | ||
module "this" { | ||
source = "../../" | ||
|
||
slack_endpoints = [ | ||
{ | ||
name = "slack" | ||
webhook_url = "https://hooks.slack.com/services/xxxxxxxxx" | ||
} | ||
] | ||
} |
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,51 @@ | ||
variable "disable_provenance" { | ||
type = bool | ||
default = true | ||
description = "Allow modifying the contact point from other sources than Terraform or the Grafana API." | ||
} | ||
|
||
variable "slack_endpoints" { | ||
type = list(object({ | ||
name = string # The name of the contact point | ||
endpoint_url = optional(string, "https://slack.com/api/chat.postMessage") # Use this to override the Slack API endpoint URL to send requests to | ||
icon_emoji = optional(string, "") # The name of a Slack workspace emoji to use as the bot icon | ||
icon_url = optional(string, "") # A URL of an image to use as the bot icon | ||
recipient = optional(string, null) # Channel, private group, or IM channel (can be an encoded ID or a name) to send messages to | ||
text = optional(string, "") # Templated content of the message | ||
title = optional(string, "") # Templated title of the message | ||
token = optional(string, "") # A Slack API token,for sending messages directly without the webhook method | ||
webhook_url = optional(string, "") # A Slack webhook URL,for sending messages via the webhook method | ||
username = optional(string, "") # Username for the bot to use | ||
disable_resolve_message = optional(bool, false) # Whether to disable sending resolve messages | ||
})) | ||
default = [] | ||
description = "Slack contact points list." | ||
} | ||
|
||
variable "opsgenie_endpoints" { | ||
type = list(object({ | ||
name = string # The name of the contact point | ||
api_key = string # The OpsGenie API key to use | ||
auto_close = optional(bool, false) # Whether to auto-close alerts in OpsGenie when they resolve in the Alert manager | ||
message = optional(string, "") # The templated content of the message | ||
api_url = optional(string, "https://api.opsgenie.com/v2/alerts") # Allows customization of the OpsGenie API URL | ||
disable_resolve_message = optional(bool, false) # Whether to disable sending resolve messages | ||
})) | ||
default = [] | ||
description = "OpsGenie contact points list." | ||
} | ||
|
||
variable "webhook_endpoints" { | ||
type = list(object({ | ||
name = string # The name of the contact point | ||
url = string # The URL to send webhook requests to | ||
authorization_credentials = optional(string, null) # Allows a custom authorization scheme - attaches an auth header with this value. Do not use in conjunction with basic auth parameters | ||
authorization_scheme = optional(string, null) # Allows a custom authorization scheme - attaches an auth header with this name. Do not use in conjunction with basic auth parameters | ||
basic_auth_password = optional(string, null) # The password component of the basic auth credentials to use | ||
basic_auth_user = optional(string, null) # The username component of the basic auth credentials to use | ||
disable_resolve_message = optional(bool, false) # Whether to disable sending resolve messages. Defaults to | ||
settings = any # Additional custom properties to attach to the notifier | ||
})) | ||
default = [] | ||
description = "Contact points that send notifications to an arbitrary webhook, using the Prometheus webhook format." | ||
} |
File renamed without changes.
Oops, something went wrong.