custom monitoring with cluster level

Signed-off-by: junotx <junotx@126.com>
This commit is contained in:
junotx
2020-12-10 15:06:06 +08:00
parent 8330e9eb7a
commit 933d0b5571
3 changed files with 69 additions and 24 deletions

View File

@@ -147,9 +147,12 @@ func (p prometheus) GetNamedMetricsOverTime(metrics []string, start, end time.Ti
func (p prometheus) GetMetadata(namespace string) []monitoring.Metadata {
var meta []monitoring.Metadata
var matchTarget string
// Filter metrics available to members of this namespace
matchTarget := fmt.Sprintf("{namespace=\"%s\"}", namespace)
if namespace != "" {
// Filter metrics available to members of this namespace
matchTarget = fmt.Sprintf("{namespace=\"%s\"}", namespace)
}
items, err := p.client.TargetsMetadata(context.Background(), matchTarget, "", "")
if err != nil {
klog.Error(err)