This repository has been archived by the owner on May 25, 2022. It is now read-only.
/
utils.go
55 lines (47 loc) · 2.36 KB
/
utils.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
// Copyright (c) 2020, Oracle and/or its affiliates.
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
package monitoring
import (
"github.com/verrazzano/verrazzano-operator/pkg/constants"
)
// GetMonitoringComponentLabels returns labels for a given monitoring component.
func GetMonitoringComponentLabels(managedClusterName string, componentName string) map[string]string {
if componentName == constants.FilebeatName {
return GetFilebeatLabels(managedClusterName)
} else if componentName == constants.JournalbeatName {
return GetJournalbeatLabels(managedClusterName)
} else if componentName == constants.NodeExporterName {
return GetNodeExporterLabels(managedClusterName)
}
return nil
}
// GetMonitoringNamespace return namespace for a given monitoring component.
func GetMonitoringNamespace(componentName string) string {
if componentName == constants.FilebeatName {
return constants.LoggingNamespace
} else if componentName == constants.JournalbeatName {
return constants.LoggingNamespace
} else if componentName == constants.NodeExporterName {
return constants.MonitoringNamespace
} else {
return ""
}
}
// GetMonitoringComponents returns list of monitoring components.
func GetMonitoringComponents() []string {
var components []string
components = append(components, constants.FilebeatName, constants.JournalbeatName, constants.NodeExporterName)
return components
}
// GetFilebeatLabels returns labels for Filebeats.
func GetFilebeatLabels(managedClusterName string) map[string]string {
return map[string]string{constants.K8SAppLabel: constants.FilebeatName, constants.VerrazzanoBinding: constants.VmiSystemBindingName, constants.VerrazzanoCluster: managedClusterName}
}
// GetJournalbeatLabels returns labels for Journalbeats.
func GetJournalbeatLabels(managedClusterName string) map[string]string {
return map[string]string{constants.K8SAppLabel: constants.JournalbeatName, constants.VerrazzanoBinding: constants.VmiSystemBindingName, constants.VerrazzanoCluster: managedClusterName}
}
// GetNodeExporterLabels returns labels for Node Exporter.
func GetNodeExporterLabels(managedClusterName string) map[string]string {
return map[string]string{constants.ServiceAppLabel: constants.NodeExporterName, constants.VerrazzanoBinding: constants.VmiSystemBindingName, constants.VerrazzanoCluster: managedClusterName}
}