This repository has been archived by the owner on Jun 12, 2020. It is now read-only.
-
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.
fix: refactoring and fix of dashboard
- Loading branch information
Showing
12 changed files
with
365 additions
and
307 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,18 @@ | ||
package ambassador | ||
|
||
import "github.com/caos/boom/internal/app/v1beta1/crd/prometheus/servicemonitor" | ||
|
||
func GetServicemonitor(monitorlabels map[string]string) *servicemonitor.Config { | ||
endpoint := &servicemonitor.ConfigEndpoint{ | ||
Port: "admin", | ||
Path: "/metrics", | ||
} | ||
labels := map[string]string{"app.kubernetes.io/name": "ambassador"} | ||
|
||
return &servicemonitor.Config{ | ||
Name: "ambassador-servicemonitor", | ||
Endpoints: []*servicemonitor.ConfigEndpoint{endpoint}, | ||
MonitorMatchingLabels: monitorlabels, | ||
ServiceMatchingLabels: labels, | ||
} | ||
} |
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,40 @@ | ||
package apiserver | ||
|
||
import "github.com/caos/boom/internal/app/v1beta1/crd/prometheus/servicemonitor" | ||
|
||
func GetServicemonitor(monitorlabels map[string]string) *servicemonitor.Config { | ||
metricsRelabelings := make([]*servicemonitor.ConfigMetricRelabeling, 0) | ||
relabeling := &servicemonitor.ConfigMetricRelabeling{ | ||
Action: "keep", | ||
Regex: "default;kubernetes;https", | ||
SourceLabels: []string{"__meta_kubernetes_namespace", "__meta_kubernetes_service_name", "__meta_kubernetes_endpoint_port_name"}, | ||
} | ||
metricsRelabelings = append(metricsRelabelings, relabeling) | ||
|
||
endpoints := make([]*servicemonitor.ConfigEndpoint, 0) | ||
endpoint := &servicemonitor.ConfigEndpoint{ | ||
Scheme: "https", | ||
BearerTokenFile: "/var/run/secrets/kubernetes.io/serviceaccount/token", | ||
Port: "https", | ||
Path: "/metrics", | ||
TLSConfig: &servicemonitor.ConfigTLSConfig{ | ||
CaFile: "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt", | ||
}, | ||
MetricsRelabelings: metricsRelabelings, | ||
} | ||
endpoints = append(endpoints, endpoint) | ||
|
||
labels := map[string]string{ | ||
"component": "apiserver", | ||
"provider": "kubernetes", | ||
} | ||
|
||
return &servicemonitor.Config{ | ||
Name: "kubernetes-apiservers-servicemonitor", | ||
Endpoints: endpoints, | ||
MonitorMatchingLabels: monitorlabels, | ||
ServiceMatchingLabels: labels, | ||
NamespaceSelector: []string{"default"}, | ||
JobName: "kubernetes-apiservers", | ||
} | ||
} |
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,66 @@ | ||
package argocd | ||
|
||
import "github.com/caos/boom/internal/app/v1beta1/crd/prometheus/servicemonitor" | ||
|
||
func GetServicemonitors(monitorlabels map[string]string) []*servicemonitor.Config { | ||
|
||
servicemonitors := make([]*servicemonitor.Config, 0) | ||
|
||
//argocd-application-controller | ||
endpoint := &servicemonitor.ConfigEndpoint{ | ||
Port: "metrics", | ||
Path: "/metrics", | ||
} | ||
|
||
labels := map[string]string{ | ||
"app.kubernetes.io/part-of": "argocd", | ||
"app.kubernetes.io/component": "application-controller", | ||
} | ||
|
||
smconfig := &servicemonitor.Config{ | ||
Name: "application-controller-servicemonitor", | ||
Endpoints: []*servicemonitor.ConfigEndpoint{endpoint}, | ||
MonitorMatchingLabels: monitorlabels, | ||
ServiceMatchingLabels: labels, | ||
JobName: "application-controller", | ||
} | ||
servicemonitors = append(servicemonitors, smconfig) | ||
// argocd-repo-server | ||
endpoint = &servicemonitor.ConfigEndpoint{ | ||
Port: "metrics", | ||
Path: "/metrics", | ||
} | ||
|
||
labels = map[string]string{ | ||
"app.kubernetes.io/part-of": "argocd", | ||
"app.kubernetes.io/component": "repo-server", | ||
} | ||
|
||
smconfig = &servicemonitor.Config{ | ||
Name: "argocd-repo-server-servicemonitor", | ||
Endpoints: []*servicemonitor.ConfigEndpoint{endpoint}, | ||
MonitorMatchingLabels: monitorlabels, | ||
ServiceMatchingLabels: labels, | ||
JobName: "argocd-repo-server", | ||
} | ||
servicemonitors = append(servicemonitors, smconfig) | ||
// argocd-server | ||
endpoint = &servicemonitor.ConfigEndpoint{ | ||
Port: "metrics", | ||
Path: "/metrics", | ||
} | ||
|
||
labels = map[string]string{ | ||
"app.kubernetes.io/part-of": "argocd", | ||
"app.kubernetes.io/component": "server", | ||
} | ||
|
||
smconfig = &servicemonitor.Config{ | ||
Name: "argocd-server-servicemonitor", | ||
Endpoints: []*servicemonitor.ConfigEndpoint{endpoint}, | ||
MonitorMatchingLabels: monitorlabels, | ||
ServiceMatchingLabels: labels, | ||
JobName: "argocd-server", | ||
} | ||
return servicemonitors | ||
} |
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,18 @@ | ||
package certmanager | ||
|
||
import "github.com/caos/boom/internal/app/v1beta1/crd/prometheus/servicemonitor" | ||
|
||
func GetServicemonitor(monitorlabels map[string]string) *servicemonitor.Config { | ||
endpoint := &servicemonitor.ConfigEndpoint{ | ||
TargetPort: "http", | ||
Path: "/metrics", | ||
} | ||
labels := map[string]string{"app": "cert-manager"} | ||
|
||
return &servicemonitor.Config{ | ||
Name: "cert-manager-servicemonitor", | ||
Endpoints: []*servicemonitor.ConfigEndpoint{endpoint}, | ||
MonitorMatchingLabels: monitorlabels, | ||
ServiceMatchingLabels: labels, | ||
} | ||
} |
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,85 @@ | ||
package kubelet | ||
|
||
import "github.com/caos/boom/internal/app/v1beta1/crd/prometheus" | ||
|
||
func GetScrapeConfigs() []*prometheus.AdditionalScrapeConfig { | ||
|
||
adconfigs := make([]*prometheus.AdditionalScrapeConfig, 0) | ||
|
||
adconfigs = append(adconfigs, getNodes()) | ||
adconfigs = append(adconfigs, getCadvisor()) | ||
|
||
return adconfigs | ||
} | ||
|
||
func getNodes() *prometheus.AdditionalScrapeConfig { | ||
relabelings := make([]*prometheus.RelabelConfig, 0) | ||
relabeling := &prometheus.RelabelConfig{ | ||
Action: "labelmap", | ||
Regex: "__meta_kubernetes_node_label_(.+)", | ||
} | ||
relabelings = append(relabelings, relabeling) | ||
relabeling = &prometheus.RelabelConfig{ | ||
TargetLabel: "__address__", | ||
Replacement: "kubernetes.default.svc:443", | ||
} | ||
relabelings = append(relabelings, relabeling) | ||
relabeling = &prometheus.RelabelConfig{ | ||
SourceLabels: []string{"__meta_kubernetes_node_name"}, | ||
Regex: "(.+)", | ||
TargetLabel: "__metrics_path__", | ||
Replacement: "/api/v1/nodes/${1}/proxy/metrics", | ||
} | ||
relabelings = append(relabelings, relabeling) | ||
|
||
sdconfig := &prometheus.KubernetesSdConfig{ | ||
Role: "node", | ||
} | ||
|
||
return &prometheus.AdditionalScrapeConfig{ | ||
JobName: "kubernetes-nodes", | ||
Scheme: "https", | ||
KubernetesSdConfigs: []*prometheus.KubernetesSdConfig{sdconfig}, | ||
BearerTokenFile: "/var/run/secrets/kubernetes.io/serviceaccount/token", | ||
TLSConfig: &prometheus.TLSConfig{ | ||
CaFile: "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt", | ||
}, | ||
RelabelConfigs: relabelings, | ||
} | ||
} | ||
|
||
func getCadvisor() *prometheus.AdditionalScrapeConfig { | ||
relabelings := make([]*prometheus.RelabelConfig, 0) | ||
relabeling := &prometheus.RelabelConfig{ | ||
Action: "labelmap", | ||
Regex: "__meta_kubernetes_node_label_(.+)", | ||
} | ||
relabelings = append(relabelings, relabeling) | ||
relabeling = &prometheus.RelabelConfig{ | ||
TargetLabel: "__address__", | ||
Replacement: "kubernetes.default.svc:443", | ||
} | ||
relabelings = append(relabelings, relabeling) | ||
relabeling = &prometheus.RelabelConfig{ | ||
SourceLabels: []string{"__meta_kubernetes_node_name"}, | ||
Regex: "(.+)", | ||
TargetLabel: "__metrics_path__", | ||
Replacement: "/api/v1/nodes/${1}/proxy/metrics/cadvisor", | ||
} | ||
relabelings = append(relabelings, relabeling) | ||
|
||
sdconfig := &prometheus.KubernetesSdConfig{ | ||
Role: "node", | ||
} | ||
|
||
return &prometheus.AdditionalScrapeConfig{ | ||
JobName: "kubelet", | ||
Scheme: "https", | ||
KubernetesSdConfigs: []*prometheus.KubernetesSdConfig{sdconfig}, | ||
BearerTokenFile: "/var/run/secrets/kubernetes.io/serviceaccount/token", | ||
TLSConfig: &prometheus.TLSConfig{ | ||
CaFile: "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt", | ||
}, | ||
RelabelConfigs: relabelings, | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
internal/app/v1beta1/crd/kubestatemetrics/servicemonitor.go
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,32 @@ | ||
package kubestatemetrics | ||
|
||
import "github.com/caos/boom/internal/app/v1beta1/crd/prometheus/servicemonitor" | ||
|
||
func GetServicemonitor(monitorlabels map[string]string) *servicemonitor.Config { | ||
|
||
relabelings := make([]*servicemonitor.ConfigRelabeling, 0) | ||
relabeling := &servicemonitor.ConfigRelabeling{ | ||
Action: "labeldrop", | ||
Regex: "(pod|service|endpoint|namespace)", | ||
} | ||
relabelings = append(relabelings, relabeling) | ||
|
||
endpoint := &servicemonitor.ConfigEndpoint{ | ||
Port: "http", | ||
Path: "/metrics", | ||
HonorLabels: true, | ||
Relabelings: relabelings, | ||
} | ||
|
||
labels := map[string]string{ | ||
"app.kubernetes.io/name": "kube-state-metrics", | ||
} | ||
|
||
return &servicemonitor.Config{ | ||
Name: "kube-state-metrics-servicemonitor", | ||
Endpoints: []*servicemonitor.ConfigEndpoint{endpoint}, | ||
MonitorMatchingLabels: monitorlabels, | ||
ServiceMatchingLabels: labels, | ||
JobName: "kube-state-metrics", | ||
} | ||
} |
Oops, something went wrong.