-
Notifications
You must be signed in to change notification settings - Fork 125
/
monitor.go
44 lines (37 loc) · 1.04 KB
/
monitor.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
// Copyright 2024 PingCAP, Inc. Licensed under Apache-2.0.
package pdtopo
import (
"context"
"go.etcd.io/etcd/clientv3"
"github.com/pingcap/tidb-dashboard/util/topo"
)
func GetAlertManagerInstance(ctx context.Context, etcdClient *clientv3.Client) (*topo.AlertManagerInfo, error) {
i, err := fetchStandardComponentTopology(ctx, "alertmanager", etcdClient)
if err != nil {
return nil, err
}
if i == nil {
return nil, nil
}
return (*topo.AlertManagerInfo)(i), nil
}
func GetGrafanaInstance(ctx context.Context, etcdClient *clientv3.Client) (*topo.GrafanaInfo, error) {
i, err := fetchStandardComponentTopology(ctx, "grafana", etcdClient)
if err != nil {
return nil, err
}
if i == nil {
return nil, nil
}
return (*topo.GrafanaInfo)(i), nil
}
func GetPrometheusInstance(ctx context.Context, etcdClient *clientv3.Client) (*topo.PrometheusInfo, error) {
i, err := fetchStandardComponentTopology(ctx, "prometheus", etcdClient)
if err != nil {
return nil, err
}
if i == nil {
return nil, nil
}
return (*topo.PrometheusInfo)(i), nil
}