Make creation of Grafana Data Source and Folder configurable (#145)

* Made the cluster variable visible in dashboards

* Made the repo reusable with multiple EKS clusters

* Relabled the input variable from create_grafana_data_source to create_prometheus_data_source
This commit is contained in:
Vijay Chintalapati
2023-04-06 02:04:29 -07:00
committed by GitHub
parent cd28d9975a
commit caeebe0e1a
16 changed files with 58 additions and 14 deletions
@@ -42,6 +42,8 @@ No modules.
|------|-------------|------|---------|:--------:|
| <a name="input_dashboards_folder_id"></a> [dashboards\_folder\_id](#input\_dashboards\_folder\_id) | Grafana folder ID for automatic dashboards | `string` | n/a | yes |
| <a name="input_enable_alerting_rules"></a> [enable\_alerting\_rules](#input\_enable\_alerting\_rules) | Enables or disables Managed Prometheus alerting rules | `bool` | `true` | no |
| <a name="input_enable_dashboards"></a> [enable\_dashboards](#input\_enable\_dashboards) | Enables or disables curated dashboards | `bool` | `true` | no |
| <a name="input_enable_recording_rules"></a> [enable\_recording\_rules](#input\_enable\_recording\_rules) | Enables or disables Managed Prometheus recording rules | `bool` | `true` | no |
| <a name="input_managed_prometheus_workspace_id"></a> [managed\_prometheus\_workspace\_id](#input\_managed\_prometheus\_workspace\_id) | Amazon Managed Prometheus Workspace ID | `string` | `null` | no |
## Outputs
@@ -1,4 +1,5 @@
resource "aws_prometheus_rule_group_namespace" "recording_rules" {
count = var.enable_recording_rules ? 1 : 0
name = "accelerator-java-rules"
workspace_id = var.managed_prometheus_workspace_id
data = <<EOF
@@ -31,6 +32,7 @@ EOF
}
resource "grafana_dashboard" "this" {
count = var.enable_dashboards ? 1 : 0
folder = var.dashboards_folder_id
config_json = file("${path.module}/dashboards/default.json")
}
@@ -4,6 +4,12 @@ variable "enable_alerting_rules" {
default = true
}
variable "enable_recording_rules" {
description = "Enables or disables Managed Prometheus recording rules"
type = bool
default = true
}
variable "managed_prometheus_workspace_id" {
description = "Amazon Managed Prometheus Workspace ID"
type = string
@@ -14,3 +20,9 @@ variable "dashboards_folder_id" {
description = "Grafana folder ID for automatic dashboards"
type = string
}
variable "enable_dashboards" {
description = "Enables or disables curated dashboards"
type = bool
default = true
}