-
Notifications
You must be signed in to change notification settings - Fork 1
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 #5 from oracle-quickstart/feature/monitoring
add monitoring stack
- Loading branch information
Showing
20 changed files
with
1,529 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
## Copyright © 2023, Oracle and/or its affiliates. | ||
## All rights reserved. The Universal Permissive License (UPL), Version 1.0 as shown at http://oss.oracle.com/licenses/upl | ||
|
||
# defines trigger to enable specific components based on selection | ||
locals { | ||
enable_flink = var.enable_flink | ||
enable_cert_manager = local.enable_flink || var.enable_cert_manager | ||
enable_cluster_autoscaler = var.np1_enable_autoscaler || var.np2_enable_autoscaler || var.np3_enable_autoscaler | ||
enable_monitoring_stack = var.enable_monitoring_stack | ||
enable_metrics_server = local.enable_cluster_autoscaler || var.enable_metrics_server || local.enable_monitoring_stack | ||
enable_grafana_flink_dashboards = local.enable_monitoring_stack && local.enable_flink | ||
} |
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
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
# Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. | ||
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl. | ||
|
||
locals { | ||
deployment_name = "kps" | ||
vars = { "region" = var.region, "tenancy_ocid" = var.tenancy_ocid } | ||
scrape_configs = flatten([for i in fileset("${path.module}/templates", "*.scrapeConfigs.yaml") : file("${path.module}/templates/${i}")]) | ||
grafana_datasources = flatten([for i in fileset("${path.module}/templates", "grafana.*.datasource.yaml") : yamldecode(templatefile("${path.module}/templates/${i}", local.vars))]) | ||
grafana_dashboards = flatten([for i in fileset("${path.module}/templates", "grafana.*.dashboard.json") : { "name" = i, "label" = split(".", i)[1] }]) | ||
grafana_plugins = file("${path.module}/templates/grafana.plugins.yaml") | ||
} | ||
|
||
output dash { | ||
value = local.grafana_dashboards | ||
} | ||
|
||
resource "random_password" "grafana_password" { | ||
count = local.enable_monitoring_stack ? 1 : 0 | ||
length = 20 | ||
special = true | ||
override_special = "#$%&@!_+=./;:][{}]" | ||
} | ||
|
||
output "grafana_password" { | ||
value = local.enable_monitoring_stack ? random_password.grafana_password[0].result : "" | ||
sensitive = true | ||
} | ||
|
||
resource "helm_release" "kube_prometheus_stack" { | ||
count = local.enable_monitoring_stack ? 1 : 0 | ||
name = local.deployment_name | ||
repository = "https://prometheus-community.github.io/helm-charts" | ||
chart = "kube-prometheus-stack" | ||
namespace = "monitoring" | ||
version = "45.8.0" | ||
wait = false | ||
create_namespace = true | ||
|
||
set { | ||
name = "prometheus.prometheusSpec.additionalScrapeConfigs" | ||
value = join("\n", local.scrape_configs) | ||
} | ||
|
||
# set { | ||
# name = "grafana.sidecar.datasources.defaultDatasourceEnabled" | ||
# value = false | ||
# } | ||
|
||
set { | ||
name = "grafana.adminPassword" | ||
value = random_password.grafana_password[0].result | ||
} | ||
|
||
values = [ | ||
yamlencode({ "grafana" = { | ||
"additionalDataSources" = local.grafana_datasources, | ||
"plugins" = yamldecode(local.grafana_plugins) | ||
} }) | ||
] | ||
|
||
depends_on = [ | ||
oci_containerengine_node_pool.oci_oke_node_pool | ||
] | ||
} | ||
|
||
resource "kubernetes_config_map_v1" "grafana_dashboards" { | ||
count = local.enable_monitoring_stack ? length(local.grafana_dashboards) : 0 | ||
|
||
metadata { | ||
name = "${local.deployment_name}-grafana-${local.grafana_dashboards[count.index].label}" | ||
namespace = "monitoring" | ||
labels = { | ||
"grafana_dashboard" = "1" | ||
} | ||
} | ||
|
||
data = { | ||
"${local.grafana_dashboards[count.index].name}" = "${file("${path.module}/templates/${local.grafana_dashboards[count.index].name}")}" | ||
} | ||
depends_on = [ | ||
helm_release.kube_prometheus_stack | ||
] | ||
} | ||
|
||
resource "kubernetes_config_map_v1" "grafana_plugins" { | ||
count = local.enable_monitoring_stack ? 1 : 0 | ||
|
||
metadata { | ||
name = "${local.deployment_name}-grafana-plugins" | ||
namespace = "monitoring" | ||
labels = { | ||
"grafana_plugin" = "1" | ||
} | ||
} | ||
|
||
data = { | ||
"plugins" = local.grafana_plugins | ||
} | ||
|
||
depends_on = [ | ||
helm_release.kube_prometheus_stack | ||
] | ||
} |
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
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
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
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,44 @@ | ||
k8s-cluster: | ||
gnetId: 7249 | ||
revision: 1 | ||
datasource: Prometheus | ||
k8s-cluster-metrics: | ||
gnetId: 11663 | ||
revision: 1 | ||
datasource: Prometheus | ||
k8s-cluster-metrics-simple: | ||
gnetId: 6417 | ||
revision: 1 | ||
datasource: Prometheus | ||
k8s-pods-monitoring: | ||
gnetId: 13498 | ||
revision: 1 | ||
datasource: Prometheus | ||
k8s-memory: | ||
gnetId: 13421 | ||
revision: 1 | ||
datasource: Prometheus | ||
k8s-networking: | ||
gnetId: 12658 | ||
revision: 1 | ||
datasource: Prometheus | ||
k8s-cluster-autoscaler: | ||
gnetId: 3831 | ||
revision: 1 | ||
datasource: Prometheus | ||
k8s-hpa: | ||
gnetId: 10257 | ||
revision: 1 | ||
datasource: Prometheus | ||
k8s-pods: | ||
gnetId: 6336 | ||
revision: 1 | ||
datasource: Prometheus | ||
oci-compute: | ||
gnetId: 13596 | ||
revision: 1 | ||
datasource: Oracle Cloud Infrastructure Metrics | ||
oci-oke: | ||
gnetId: 13594 | ||
revision: 1 | ||
datasource: Oracle Cloud Infrastructure Metrics |
Oops, something went wrong.