Skip to content
This repository has been archived by the owner on Jun 29, 2022. It is now read-only.

Commit

Permalink
linkerd metrics: Add ServiceMonitor for control plane
Browse files Browse the repository at this point in the history
- Adds ServiceMonitors to monitor linkerd control plane pods.

- Adds entry in the components prometheus metrics list to test if the
linkerd metrics are being scraped.

Signed-off-by: Suraj Deshmukh <suraj@kinvolk.io>
  • Loading branch information
surajssd committed Aug 26, 2020
1 parent 43eb0de commit 383cef7
Show file tree
Hide file tree
Showing 7 changed files with 144 additions and 597 deletions.
123 changes: 123 additions & 0 deletions assets/charts/components/linkerd2/templates/service-monitors.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
{{ if .Values.enableMonitoring }}
---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
labels:
app: linkerd
release: prometheus-operator
name: linkerd-web
namespace: {{.Values.global.namespace}}
spec:
selector:
matchLabels:
linkerd.io/control-plane-component: web
endpoints:
- targetPort: 9994
---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
labels:
app: linkerd
release: prometheus-operator
name: linkerd-sp-validator
namespace: {{.Values.global.namespace}}
spec:
selector:
matchLabels:
linkerd.io/control-plane-component: sp-validator
endpoints:
- targetPort: 9997
---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
labels:
app: linkerd
release: prometheus-operator
name: linkerd-controller-api
namespace: {{.Values.global.namespace}}
spec:
selector:
matchLabels:
linkerd.io/control-plane-component: controller
endpoints:
- targetPort: 9995
---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
labels:
app: linkerd
release: prometheus-operator
name: linkerd-identity
namespace: {{.Values.global.namespace}}
spec:
selector:
matchLabels:
linkerd.io/control-plane-component: identity
endpoints:
- targetPort: 9990
---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
labels:
app: linkerd
release: prometheus-operator
name: linkerd-proxy-injector
namespace: {{.Values.global.namespace}}
spec:
selector:
matchLabels:
linkerd.io/control-plane-component: proxy-injector
endpoints:
- targetPort: 9995
---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
labels:
app: linkerd
release: prometheus-operator
name: linkerd-tap
namespace: {{.Values.global.namespace}}
spec:
selector:
matchLabels:
linkerd.io/control-plane-component: tap
endpoints:
- targetPort: 9998
---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
labels:
app: linkerd
release: prometheus-operator
name: linkerd-dst
namespace: {{.Values.global.namespace}}
spec:
selector:
matchLabels:
linkerd.io/control-plane-component: destination
endpoints:
- targetPort: 9996
---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
labels:
app: linkerd
release: prometheus-operator
name: linkerd-proxies
namespace: {{.Values.global.namespace}}
spec:
selector:
matchLabels:
linkerd.io/control-plane-ns: linkerd
endpoints:
- targetPort: 4191
---
{{end}}
4 changes: 3 additions & 1 deletion ci/aws/aws-cluster.lokocfg.envsubst
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ component "prometheus-operator" {
}
}

component "experimental-linkerd" {}
component "experimental-linkerd" {
enable_monitoring = true
}

component "contour" {
enable_monitoring = true
Expand Down
1 change: 1 addition & 0 deletions ci/packet/packet-cluster.lokocfg.envsubst
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ component "prometheus-operator" {

component "experimental-linkerd" {
controller_replicas = 2
enable_monitoring = true
}

component "contour" {
Expand Down
603 changes: 8 additions & 595 deletions pkg/assets/generated_assets.go

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion pkg/components/linkerd/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ func init() {
}

type component struct {
ControllerReplicas int `hcl:"controller_replicas,optional"`
ControllerReplicas int `hcl:"controller_replicas,optional"`
EnableMonitoring bool `hcl:"enable_monitoring,optional"`

Cert cert
}
Expand All @@ -55,6 +56,7 @@ type cert struct {
func newComponent() *component {
return &component{
ControllerReplicas: 1,
EnableMonitoring: false,
}
}

Expand Down
1 change: 1 addition & 0 deletions pkg/components/linkerd/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package linkerd

const chartValuesTmpl = `
enableMonitoring: {{.EnableMonitoring}}
global:
identityTrustAnchorsPEM: |
{{ .Cert.CA }}
Expand Down
5 changes: 5 additions & 0 deletions test/monitoring/components_metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ func testComponentsPrometheusMetrics(t *testing.T, v1api v1.API) {
query: "certmanager_controller_sync_call_count",
platforms: []testutil.Platform{testutil.PlatformPacket, testutil.PlatformAWS, testutil.PlatformAKS},
},
{
componentName: "linkerd",
query: "tcp_read_bytes_total",
platforms: []testutil.Platform{testutil.PlatformPacket, testutil.PlatformAWS},
},
}

for _, tc := range testCases {
Expand Down

0 comments on commit 383cef7

Please sign in to comment.