forked from joeholley/supergloo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlinkerd_prometheus_syncer.go
30 lines (23 loc) · 997 Bytes
/
linkerd_prometheus_syncer.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
package linkerd
import (
"github.com/solo-io/supergloo/pkg/stats/common"
"k8s.io/client-go/kubernetes"
"github.com/prometheus/prometheus/config"
"github.com/solo-io/go-utils/errors"
prometheusv1 "github.com/solo-io/supergloo/pkg/api/external/prometheus/v1"
v1 "github.com/solo-io/supergloo/pkg/api/v1"
)
// registration-level syncer
func NewLinkerdPrometheusSyncer(client prometheusv1.PrometheusConfigClient, kube kubernetes.Interface, skipBouncingPrometheusPods bool) v1.RegistrationSyncer {
return common.NewPrometheusSyncer("linkerd", client, kube, chooseMesh, getScrapeConfigs, skipBouncingPrometheusPods)
}
func chooseMesh(mesh *v1.Mesh) bool {
return mesh.GetLinkerd() != nil
}
func getScrapeConfigs(mesh *v1.Mesh) ([]*config.ScrapeConfig, error) {
linkerd := mesh.GetLinkerd()
if linkerd == nil {
return nil, errors.Errorf("internal error: mesh %v was expected to be type linkerd", mesh.Metadata.Ref())
}
return PrometheusScrapeConfigs(linkerd.InstallationNamespace)
}