Skip to content

Commit

Permalink
frr-k8s: use metricRelabelings for serviceMonitors
Browse files Browse the repository at this point in the history
We deploy the serviceMonitors of frr-k8s so that the scraped
metrics show as MetalLB's, making the integration cleaner.

Signed-off-by: Ori Braunshtein <[email protected]>
  • Loading branch information
oribon committed Dec 20, 2023
1 parent 4f151ff commit daa7b3d
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 5 deletions.
30 changes: 25 additions & 5 deletions pkg/helm/frrk8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,34 @@ func (c *frrK8SChartConfig) prometheusValues() map[string]interface{} {
tlsConfig, annotations, tlsSecret = ocpPromConfigFor("frr-k8s", c.namespace)
}

serviceMonitor := map[string]interface{}{
"enabled": false,
"annotations": annotations,
"tlsConfig": tlsConfig,
}

if c.enableServiceMonitor {
serviceMonitor["enabled"] = true
serviceMonitor["metricRelabelings"] = []map[string]interface{}{
{
"regex": "frrk8s_bgp_(.*)",
"replacement": "metallb_bgp_$1",
"sourceLabels": []string{"__name__"},
"targetLabel": "__name__",
},
{
"regex": "frrk8s_bfd_(.*)",
"replacement": "metallb_bfd_$1",
"sourceLabels": []string{"__name__"},
"targetLabel": "__name__",
},
}
}

return map[string]interface{}{
"metricsPort": c.metricsPort,
"secureMetricsPort": c.secureMetricsPort,
"serviceMonitor": map[string]interface{}{
"enabled": c.enableServiceMonitor,
"annotations": annotations,
"tlsConfig": tlsConfig,
},
"serviceMonitor": serviceMonitor,
"rbacProxy": map[string]interface{}{
"repository": c.kubeRbacProxyImage.repo,
"tag": c.kubeRbacProxyImage.tag,
Expand Down
36 changes: 36 additions & 0 deletions pkg/helm/testdata/ocp-metrics-frr-k8s-monitor.golden
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,24 @@
{
"bearerTokenFile": "/var/run/secrets/kubernetes.io/serviceaccount/token",
"honorLabels": true,
"metricRelabelings": [
{
"regex": "frrk8s_bgp_(.*)",
"replacement": "metallb_bgp_$1",
"sourceLabels": [
"__name__"
],
"targetLabel": "__name__"
},
{
"regex": "frrk8s_bfd_(.*)",
"replacement": "metallb_bfd_$1",
"sourceLabels": [
"__name__"
],
"targetLabel": "__name__"
}
],
"port": "metricshttps",
"scheme": "https",
"tlsConfig": {
Expand All @@ -33,6 +51,24 @@
{
"bearerTokenFile": "/var/run/secrets/kubernetes.io/serviceaccount/token",
"honorLabels": true,
"metricRelabelings": [
{
"regex": "frrk8s_bgp_(.*)",
"replacement": "metallb_bgp_$1",
"sourceLabels": [
"__name__"
],
"targetLabel": "__name__"
},
{
"regex": "frrk8s_bfd_(.*)",
"replacement": "metallb_bfd_$1",
"sourceLabels": [
"__name__"
],
"targetLabel": "__name__"
}
],
"port": "frrmetricshttps",
"scheme": "https",
"tlsConfig": {
Expand Down

0 comments on commit daa7b3d

Please sign in to comment.