diff --git a/example/main.tf b/example/main.tf index 02a6d3d..d1afd90 100644 --- a/example/main.tf +++ b/example/main.tf @@ -1,17 +1,17 @@ module "monitoring" { source = "./" - nfs_endpoint = "10.10.10.10" - domain = "example.com" - tls = "secret-tls" + nfs_endpoint = "10.10.10.10" + domain = "example.com" + tls = "secret-tls" grafana_admin_password = "password" - grafana_ldap_enable = true - grafana_ldap_host = "domain.com" - grafana_ldap_bind_dn = "cn=reader,ou=users,ou=company,dc=example,dc=com" - grafana_ldap_bind_password = "password" - grafana_ldap_search_base_dn = "ou=company,dc=example,dc=com" - grafana_ldap_search_filter = "(&(sAMAccountName=%s)(memberOf=cn=grafana_users,ou=groups,ou=company,dc=example,dc=com))" - grafana_ldap_admin_group_dn = "cn=grafana_admin,ou=groups,ou=company,dc=example,dc=com" + grafana_ldap_enable = true + grafana_ldap_host = "domain.com" + grafana_ldap_bind_dn = "cn=reader,ou=users,ou=company,dc=example,dc=com" + grafana_ldap_bind_password = "password" + grafana_ldap_search_base_dn = "ou=company,dc=example,dc=com" + grafana_ldap_search_filter = "(&(sAMAccountName=%s)(memberOf=cn=grafana_users,ou=groups,ou=company,dc=example,dc=com))" + grafana_ldap_admin_group_dn = "cn=grafana_admin,ou=groups,ou=company,dc=example,dc=com" grafana_ldap_editor_group_dn = "cn=grafana_editor,ou=groups,ou=company,dc=example,dc=com" } \ No newline at end of file diff --git a/main.tf b/main.tf index ad1d3bc..d0d2616 100644 --- a/main.tf +++ b/main.tf @@ -17,9 +17,28 @@ resource "kubernetes_config_map" "grafana_additional_dashboards" { } } data = { - "grafana-dashboard-node-exporter.json" = file("${path.module}/templates/grafana_dashboard_node_exporter.json") - "grafana-dashboard-node-exporter_en.json" = file("${path.module}/templates/grafana_dashboard_node_exporter_en.json") - "grafana-dashboard-nginx-controller.json" = file("${path.module}/templates/grafana_dashboard_nginx_controller.json") + "grafana-dashboard-node-exporter.json" = file("${path.module}/templates/grafana-dashboard-node-exporter.json") + "grafana-dashboard-node-exporter_en.json" = file("${path.module}/templates/grafana-dashboard-node-exporter_en.json") + "grafana-dashboard-nginx-controller.json" = file("${path.module}/templates/grafana-dashboard-nginx-controller.json") + } +} + +resource "kubernetes_config_map" "grafana_additional_datasource" { + count = var.loki_url != null ? 1 : 0 + + metadata { + name = "grafana-additional-datasource" + namespace = var.create_namespace ? kubernetes_namespace.namespace[0].id : var.namespace + labels = { + "grafana_datasource" = "1" + } + } + data = { + "grafana-loki-stack-datasource.yaml" = templatefile("${path.module}/templates/grafana-loki-datasource.yaml", + { + LOKI_URL = var.loki_url + } + ) } } diff --git a/templates/grafana_dashboard_nginx_controller.json b/templates/grafana-dashboard-nginx-controller.json similarity index 100% rename from templates/grafana_dashboard_nginx_controller.json rename to templates/grafana-dashboard-nginx-controller.json diff --git a/templates/grafana_dashboard_node_exporter_en.json b/templates/grafana-dashboard-node-exporter-en.json similarity index 100% rename from templates/grafana_dashboard_node_exporter_en.json rename to templates/grafana-dashboard-node-exporter-en.json diff --git a/templates/grafana_dashboard_node_exporter.json b/templates/grafana-dashboard-node-exporter.json similarity index 100% rename from templates/grafana_dashboard_node_exporter.json rename to templates/grafana-dashboard-node-exporter.json diff --git a/templates/grafana-loki-datasource.yaml b/templates/grafana-loki-datasource.yaml new file mode 100644 index 0000000..304b5b8 --- /dev/null +++ b/templates/grafana-loki-datasource.yaml @@ -0,0 +1,9 @@ +apiVersion: 1 +datasources: + - name: Loki + type: loki + url: ${LOKI_URL}/ + access: proxy + editable: false + jsonData: + timeInterval: 30s \ No newline at end of file diff --git a/variables.tf b/variables.tf index 744ee60..16a4c7e 100644 --- a/variables.tf +++ b/variables.tf @@ -233,4 +233,11 @@ variable "grafana_ldap_editor_group_dn" { description = "DN group for editor access" type = string default = "cn=grafana_editor,ou=groups,ou=company,dc=ldap,dc=com" -} \ No newline at end of file +} + +# Loki Datasource +variable "loki_url" { + description = "URL for access to loki-stack" + type = string + default = null +}