Compare commits
No commits in common. "8626b91b16fcfa97e85d80b79a04ddf9a3e19e60" and "ab2473bdf4c4a7c90fafbaada97eeb31eaf6739e" have entirely different histories.
8626b91b16
...
ab2473bdf4
5 changed files with 43 additions and 13 deletions
|
@ -4,7 +4,7 @@
|
|||
:license {:name "Apache License, Version 2.0"
|
||||
:url "https://www.apache.org/licenses/LICENSE-2.0.html"}
|
||||
:dependencies [[org.clojure/clojure "1.11.1" :scope "provided"]
|
||||
[org.clojure/tools.reader "1.4.0"]
|
||||
[org.clojure/tools.reader "1.3.7"]
|
||||
[aero "1.1.6"]
|
||||
[orchestra "2021.01.01-1"]
|
||||
[expound "0.9.0"]
|
||||
|
@ -25,8 +25,8 @@
|
|||
:uberjar {:aot :all
|
||||
:main dda.c4k-common.uberjar
|
||||
:uberjar-name "c4k-common-standalone.jar"
|
||||
:dependencies [[org.clojure/tools.cli "1.1.230"]
|
||||
[ch.qos.logback/logback-classic "1.5.0"
|
||||
:dependencies [[org.clojure/tools.cli "1.0.219"]
|
||||
[ch.qos.logback/logback-classic "1.4.14"
|
||||
:exclusions [com.sun.mail/javax.mail]]
|
||||
[org.slf4j/jcl-over-slf4j "2.0.12"]]}}
|
||||
:release-tasks [["test"]
|
||||
|
|
|
@ -3,22 +3,46 @@
|
|||
[clojure.spec.alpha :as s]
|
||||
#?(:clj [orchestra.core :refer [defn-spec]]
|
||||
:cljs [orchestra.core :refer-macros [defn-spec]])
|
||||
[clojure.string :as str]
|
||||
[dda.c4k-common.yaml :as yaml]
|
||||
[dda.c4k-common.predicate :as cp]
|
||||
[dda.c4k-common.monitoring.monitoring-internal :as int]))
|
||||
|
||||
(s/def ::grafana-cloud-user ::int/grafana-cloud-user)
|
||||
(s/def ::grafana-cloud-password ::int/grafana-cloud-password)
|
||||
(s/def ::grafana-cloud-url ::int/grafana-cloud-url)
|
||||
(s/def ::cluster-name ::int/cluster-name)
|
||||
(s/def ::cluster-stage ::int/cluster-stage)
|
||||
(s/def ::grafana-cloud-user cp/bash-env-string?)
|
||||
(s/def ::grafana-cloud-password cp/bash-env-string?)
|
||||
(s/def ::grafana-cloud-url string?)
|
||||
(s/def ::cluster-name string?)
|
||||
(s/def ::cluster-stage cp/stage?)
|
||||
(s/def ::node-regex string?)
|
||||
(s/def ::traefik-regex string?)
|
||||
(s/def ::kube-state-regex string?)
|
||||
(s/def ::mon-cfg (s/keys :req-un [::grafana-cloud-url
|
||||
::cluster-name
|
||||
::cluster-stage]))
|
||||
(s/def ::mon-auth (s/keys :req-un [::grafana-cloud-user
|
||||
::grafana-cloud-password]))
|
||||
(s/def ::filter-regex (s/keys :req-un [::node-regex
|
||||
::traefik-regex
|
||||
::kube-state-regex]))
|
||||
|
||||
|
||||
(def filter-regex-string int/filter-regex-string)
|
||||
(def metric-regex {:node-regex
|
||||
(str "node_cpu_sec.+|node_load[0-9]+|node_memory_Buf.*|node_memory_Mem.*|"
|
||||
"node_memory_Cached.*|node_disk_[r,w,i].*|node_filesystem_[s,a].*|"
|
||||
"node_network_receive_bytes_total|node_network_transmit_bytes_total")
|
||||
:traefik-regex (str "traefik_entrypoint_.*_total|"
|
||||
"traefik_entrypoint_.*_seconds_count|"
|
||||
"traefik_router_.*_total|"
|
||||
"traefik_router_.*_seconds_count|"
|
||||
"traefik_service_.*_total|"
|
||||
"traefik_service_.*_seconds_count|"
|
||||
"traefik_tls_certs_not_after")
|
||||
:kube-state-regex (str "kube_pod_container_status_restarts_total|"
|
||||
"kube_pod_status_reason|kube_node_status_capacity|kube_node_status_allocatable|"
|
||||
"kube_cronjob_status_active|kube_job_status_failed")})
|
||||
|
||||
(def filter-regex-string
|
||||
(str/join "|" (vals metric-regex)))
|
||||
|
||||
|
||||
(defn-spec generate seq?
|
||||
|
|
|
@ -14,11 +14,17 @@
|
|||
(s/def ::grafana-cloud-url string?)
|
||||
(s/def ::cluster-name string?)
|
||||
(s/def ::cluster-stage cp/stage?)
|
||||
(s/def ::node-regex string?)
|
||||
(s/def ::traefik-regex string?)
|
||||
(s/def ::kube-state-regex string?)
|
||||
(s/def ::mon-cfg (s/keys :req-un [::grafana-cloud-url
|
||||
::cluster-name
|
||||
::cluster-stage]))
|
||||
(s/def ::mon-auth (s/keys :req-un [::grafana-cloud-user
|
||||
::grafana-cloud-password]))
|
||||
(s/def ::filter-regex (s/keys :req-un [::node-regex
|
||||
::traefik-regex
|
||||
::kube-state-regex]))
|
||||
|
||||
(def metric-regex {:node-regex
|
||||
(str "node_cpu_sec.+|node_load[0-9]+|node_memory_Buf.*|node_memory_Mem.*|"
|
||||
|
@ -38,7 +44,7 @@
|
|||
(def filter-regex-string
|
||||
(str/join "|" (vals metric-regex)))
|
||||
|
||||
(defn-spec generate-prometheus-config map?
|
||||
(defn-spec generate-prometheus-config cp/map-or-seq?
|
||||
[config ::mon-cfg
|
||||
auth ::mon-auth]
|
||||
(let [{:keys [grafana-cloud-url cluster-name cluster-stage]} config
|
||||
|
@ -57,7 +63,7 @@
|
|||
grafana-cloud-password)
|
||||
(cm/replace-all-matching-values-by-new-value "FILTER_REGEX" filter-regex-string))))
|
||||
|
||||
(defn-spec generate-config map?
|
||||
(defn-spec generate-config cp/map-or-seq?
|
||||
[config ::mon-cfg
|
||||
auth ::mon-auth]
|
||||
(->
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
(ns dda.c4k-common.monitoring.monitoring-regex-test
|
||||
(ns dda.c4k-common.monitoring-regex-test
|
||||
(:require
|
||||
[clojure.test :refer [deftest is are testing run-tests]]
|
||||
[data-test :refer :all]
|
||||
[dda.c4k-common.monitoring.monitoring-internal :as cut]))
|
||||
[dda.c4k-common.monitoring :as cut]))
|
||||
|
||||
(defn filter-by-regex
|
||||
[regex-str collection]
|
Loading…
Reference in a new issue