Skip to content

Commit

Permalink
Merge pull request #2 from terraform-iaac/develop
Browse files Browse the repository at this point in the history
Rename files. Add loki-stack datasource to grafana.
  • Loading branch information
bohdantverdyi authored Aug 17, 2021
2 parents c326ef5 + d08c835 commit beaad76
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 14 deletions.
20 changes: 10 additions & 10 deletions example/main.tf
Original file line number Diff line number Diff line change
@@ -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"
}
25 changes: 22 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
)
}
}

Expand Down
9 changes: 9 additions & 0 deletions templates/grafana-loki-datasource.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: 1
datasources:
- name: Loki
type: loki
url: ${LOKI_URL}/
access: proxy
editable: false
jsonData:
timeInterval: 30s
9 changes: 8 additions & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}

# Loki Datasource
variable "loki_url" {
description = "URL for access to loki-stack"
type = string
default = null
}

0 comments on commit beaad76

Please sign in to comment.