|
|
@ -1,24 +1,49 @@
|
|
|
|
(ns dda.c4k-common.monitoring.monitoring-internal
|
|
|
|
(ns dda.c4k-common.monitoring.monitoring-internal
|
|
|
|
(:require
|
|
|
|
(:require
|
|
|
|
[clojure.spec.alpha :as s]
|
|
|
|
[clojure.spec.alpha :as s]
|
|
|
|
|
|
|
|
#?(:cljs [shadow.resource :as rc])
|
|
|
|
#?(:clj [orchestra.core :refer [defn-spec]]
|
|
|
|
#?(:clj [orchestra.core :refer [defn-spec]]
|
|
|
|
:cljs [orchestra.core :refer-macros [defn-spec]])
|
|
|
|
:cljs [orchestra.core :refer-macros [defn-spec]])
|
|
|
|
#?(:cljs [dda.c4k-common.macros :refer-macros [inline-resources]])
|
|
|
|
|
|
|
|
[dda.c4k-common.yaml :as yaml]
|
|
|
|
[dda.c4k-common.yaml :as yaml]
|
|
|
|
[dda.c4k-common.predicate :as cp]
|
|
|
|
[dda.c4k-common.predicate :as cp]
|
|
|
|
[dda.c4k-common.common :as cm]
|
|
|
|
[dda.c4k-common.common :as cm]
|
|
|
|
[clojure.string :as str]))
|
|
|
|
[clojure.string :as str]))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#?(:cljs
|
|
|
|
|
|
|
|
(defmethod yaml/load-resource :monitoring [resource-name]
|
|
|
|
|
|
|
|
(case resource-name
|
|
|
|
|
|
|
|
"monitoring/kube-state-metrics-cluster-role-binding.yaml" (rc/inline "monitoring/kube-state-metrics-cluster-role-binding.yaml")
|
|
|
|
|
|
|
|
"monitoring/kube-state-metrics-cluster-role.yaml" (rc/inline "monitoring/kube-state-metrics-cluster-role.yaml")
|
|
|
|
|
|
|
|
"monitoring/kube-state-metrics-deployment.yaml" (rc/inline "monitoring/kube-state-metrics-deployment.yaml")
|
|
|
|
|
|
|
|
"monitoring/kube-state-metrics-service-account.yaml" (rc/inline "monitoring/kube-state-metrics-service-account.yaml")
|
|
|
|
|
|
|
|
"monitoring/kube-state-metrics-service.yaml" (rc/inline "monitoring/kube-state-metrics-service.yaml")
|
|
|
|
|
|
|
|
"monitoring/namespace.yaml" (rc/inline "monitoring/namespace.yaml")
|
|
|
|
|
|
|
|
"monitoring/node-exporter-cluster-role-binding.yaml" (rc/inline "monitoring/node-exporter-cluster-role-binding.yaml")
|
|
|
|
|
|
|
|
"monitoring/node-exporter-cluster-role.yaml" (rc/inline "monitoring/node-exporter-cluster-role.yaml")
|
|
|
|
|
|
|
|
"monitoring/node-exporter-daemon-set.yaml" (rc/inline "monitoring/node-exporter-daemon-set.yaml")
|
|
|
|
|
|
|
|
"monitoring/node-exporter-service-account.yaml" (rc/inline "monitoring/node-exporter-service-account.yaml")
|
|
|
|
|
|
|
|
"monitoring/node-exporter-service.yaml" (rc/inline "monitoring/node-exporter-service.yaml")
|
|
|
|
|
|
|
|
"monitoring/prometheus-cluster-role-binding.yaml" (rc/inline "monitoring/prometheus-cluster-role-binding.yaml")
|
|
|
|
|
|
|
|
"monitoring/prometheus-cluster-role.yaml" (rc/inline "monitoring/prometheus-cluster-role.yaml")
|
|
|
|
|
|
|
|
"monitoring/prometheus-config.yaml" (rc/inline "monitoring/prometheus-config.yaml")
|
|
|
|
|
|
|
|
"monitoring/prometheus-deployment.yaml" (rc/inline "monitoring/prometheus-deployment.yaml")
|
|
|
|
|
|
|
|
"monitoring/prometheus-prometheus.yaml" (rc/inline "monitoring/prometheus-prometheus.yaml")
|
|
|
|
|
|
|
|
"monitoring/prometheus-service-account.yaml" (rc/inline "monitoring/prometheus-service-account.yaml")
|
|
|
|
|
|
|
|
"monitoring/prometheus-service.yaml" (rc/inline "monitoring/prometheus-service.yaml")
|
|
|
|
|
|
|
|
(throw (js/Error. (str "Undefined Resource: " resource-name))))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(s/def ::grafana-cloud-user cp/bash-env-string?)
|
|
|
|
(s/def ::grafana-cloud-user cp/bash-env-string?)
|
|
|
|
(s/def ::grafana-cloud-password cp/bash-env-string?)
|
|
|
|
(s/def ::grafana-cloud-password cp/bash-env-string?)
|
|
|
|
(s/def ::grafana-cloud-url string?)
|
|
|
|
(s/def ::grafana-cloud-url string?)
|
|
|
|
(s/def ::cluster-name string?)
|
|
|
|
(s/def ::cluster-name string?)
|
|
|
|
(s/def ::cluster-stage cp/stage?)
|
|
|
|
(s/def ::cluster-stage cp/stage?)
|
|
|
|
(s/def ::mon-cfg (s/keys :req-un [::grafana-cloud-url
|
|
|
|
(s/def ::mon-cfg (s/keys :req-un [::grafana-cloud-url
|
|
|
|
::cluster-name
|
|
|
|
::cluster-name
|
|
|
|
::cluster-stage]))
|
|
|
|
::cluster-stage]))
|
|
|
|
(s/def ::mon-auth (s/keys :req-un [::grafana-cloud-user
|
|
|
|
(s/def ::mon-auth (s/keys :req-un [::grafana-cloud-user
|
|
|
|
::grafana-cloud-password]))
|
|
|
|
::grafana-cloud-password]))
|
|
|
|
|
|
|
|
|
|
|
|
(def metric-regex {:node-regex
|
|
|
|
(def metric-regex {:node-regex
|
|
|
|
(str "node_cpu_sec.+|node_load[0-9]+|node_memory_Buf.*|node_memory_Mem.*|"
|
|
|
|
(str "node_cpu_sec.+|node_load[0-9]+|node_memory_Buf.*|node_memory_Mem.*|"
|
|
|
@ -65,7 +90,3 @@
|
|
|
|
(assoc-in [:stringData :prometheus.yaml]
|
|
|
|
(assoc-in [:stringData :prometheus.yaml]
|
|
|
|
(yaml/to-string
|
|
|
|
(yaml/to-string
|
|
|
|
(generate-prometheus-config config auth)))))
|
|
|
|
(generate-prometheus-config config auth)))))
|
|
|
|
|
|
|
|
|
|
|
|
#?(:cljs
|
|
|
|
|
|
|
|
(defmethod yaml/load-resource :monitoring [resource-name]
|
|
|
|
|
|
|
|
(get (inline-resources "monitoring") resource-name)))
|
|
|
|
|
|
|
|