This repository has been archived by the owner on Apr 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
servicemonitor.go
91 lines (73 loc) · 2.83 KB
/
servicemonitor.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package metrics
import (
"github.com/caos/orbos/internal/operator/boom/application/applications/argocd/info"
"github.com/caos/orbos/internal/operator/boom/application/applications/prometheus/servicemonitor"
"github.com/caos/orbos/internal/operator/boom/labels"
)
func GetServicemonitors(instanceName string) []*servicemonitor.Config {
servicemonitors := make([]*servicemonitor.Config, 0)
servicemonitors = append(servicemonitors, getSMApplicationController(instanceName))
servicemonitors = append(servicemonitors, getSMRepoServer(instanceName))
servicemonitors = append(servicemonitors, getSMServer(instanceName))
return servicemonitors
}
func getSMServer(instanceName string) *servicemonitor.Config {
appName := info.GetName()
monitorlabels := labels.GetMonitorLabels(instanceName, appName)
ls := labels.GetApplicationLabels(appName)
// argocd-server
endpoint := &servicemonitor.ConfigEndpoint{
Port: "metrics",
Path: "/metrics",
}
ls["app.kubernetes.io/instance"] = "argocd"
ls["app.kubernetes.io/part-of"] = "argocd"
ls["app.kubernetes.io/component"] = "server"
return &servicemonitor.Config{
Name: "argocd-server-servicemonitor",
Endpoints: []*servicemonitor.ConfigEndpoint{endpoint},
MonitorMatchingLabels: monitorlabels,
ServiceMatchingLabels: ls,
JobName: "argocd-server",
}
}
func getSMRepoServer(instanceName string) *servicemonitor.Config {
appName := info.GetName()
monitorlabels := labels.GetMonitorLabels(instanceName, appName)
ls := labels.GetApplicationLabels(appName)
// argocd-repo-server
endpoint := &servicemonitor.ConfigEndpoint{
Port: "metrics",
Path: "/metrics",
}
ls["app.kubernetes.io/instance"] = "argocd"
ls["app.kubernetes.io/part-of"] = "argocd"
ls["app.kubernetes.io/component"] = "repo-server"
return &servicemonitor.Config{
Name: "argocd-repo-server-servicemonitor",
Endpoints: []*servicemonitor.ConfigEndpoint{endpoint},
MonitorMatchingLabels: monitorlabels,
ServiceMatchingLabels: ls,
JobName: "argocd-repo-server",
}
}
func getSMApplicationController(instanceName string) *servicemonitor.Config {
appName := info.GetName()
monitorlabels := labels.GetMonitorLabels(instanceName, appName)
ls := labels.GetApplicationLabels(appName)
//argocd-application-controller
endpoint := &servicemonitor.ConfigEndpoint{
Port: "metrics",
Path: "/metrics",
}
ls["app.kubernetes.io/instance"] = "argocd"
ls["app.kubernetes.io/part-of"] = "argocd"
ls["app.kubernetes.io/component"] = "application-controller"
return &servicemonitor.Config{
Name: "argocd-application-controller-servicemonitor",
Endpoints: []*servicemonitor.ConfigEndpoint{endpoint},
MonitorMatchingLabels: monitorlabels,
ServiceMatchingLabels: ls,
JobName: "application-controller",
}
}