Skip to content

Commit

Permalink
Merge pull request #788 from solarwinds/feature/NH-93586-collect-conf…
Browse files Browse the repository at this point in the history
…ig-maps

collecting configmaps
  • Loading branch information
mpecenka authored Nov 13, 2024
2 parents e1e2d43 + 437cba2 commit 20a2614
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 1 deletion.
2 changes: 1 addition & 1 deletion deploy/helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: swo-k8s-collector
version: 4.2.1
version: 4.3.0-alpha.1
appVersion: 0.11.8
description: SolarWinds Kubernetes Integration
keywords:
Expand Down
22 changes: 22 additions & 0 deletions deploy/helm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,28 @@ otel:
IsMatch(body, "\\[[^\\]]*\\] \"\\S+ \\S+ HTTP/\\d(\\.\\d)*\" 200.*")
```

### Manifests

Starting with version 4.0.0, `swo-k8s-collector` observes changes in supported resources and collects their manifests.

By default, manifest collection is enabled, but it can be disabled by setting `otel.manifests.enabled` to `false`. Manifest collection runs in the event collector, so `otel.events.enabled` must be set to `true` (default).

Currently, the following resources are watched for changes: `pods`, `deployments`, `statefulsets`, `replicasets`, `daemonsets`, `jobs`, `cronjobs`, `nodes`, `services`, `persistentvolumes`, `persistentvolumeclaims`, `configmaps`, `ingresses` and Istio's `virtualservices`.

By default, `swo-k8s-collector` collects all manifests. You can use the `otel.manifests.filter` setting to filter out manifests that should not be collected.

An example of filter for collecting all manifests, but `configmaps` just for `kube-system` namespace.

```yaml
otel:
manifests:
enabled: true
filter:
log_record:
- attributes["k8s.object.kind"] == "ConfigMap" and resource.attributes["k8s.namespace.name"] != "kube-system"
```


## Receive 3rd party metrics

SWO K8s Collector has an OTEL service endpoint which is able to forward metrics and logs into SolarWinds Observability. All incoming data is properly associated with current cluster. Additionally, metrics are decorated with prefix `k8s.`.
Expand Down
7 changes: 7 additions & 0 deletions deploy/helm/events-collector-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ processors:
- set(attributes["k8s.persistentvolume.annotations"], body["metadata"]["annotations"]) where body["kind"] == "PersistentVolume"
- set(attributes["k8s.persistentvolumeclaim.annotations"], body["metadata"]["annotations"]) where body["kind"] == "PersistentVolumeClaim"
- set(attributes["k8s.ingress.annotations"], body["metadata"]["annotations"]) where body["kind"] == "Ingress"
- set(attributes["k8s.configmap.annotations"], body["metadata"]["annotations"]) where body["kind"] == "ConfigMap"

# set entity labels for the resource
- set(attributes["k8s.pod.labels"], body["metadata"]["labels"]) where body["kind"] == "Pod"
Expand All @@ -126,6 +127,7 @@ processors:
- set(attributes["k8s.persistentvolume.labels"], body["metadata"]["labels"]) where body["kind"] == "PersistentVolume"
- set(attributes["k8s.persistentvolumeclaim.labels"], body["metadata"]["labels"]) where body["kind"] == "PersistentVolumeClaim"
- set(attributes["k8s.ingress.labels"], body["metadata"]["labels"]) where body["kind"] == "Ingress"
- set(attributes["k8s.configmap.labels"], body["metadata"]["labels"]) where body["kind"] == "ConfigMap"
{{- end }}
{{- if .Values.otel.manifests.enabled }}
transform/manifest:
Expand Down Expand Up @@ -158,6 +160,7 @@ processors:
- set(attributes["k8s.namespace.name"], body["metadata"]["namespace"])
- set(attributes["k8s.ingress.name"], body["metadata"]["name"]) where body["kind"] == "Ingress" or body["kind"] == "VirtualService"
- set(attributes["sw.k8s.ingress.type"], body["kind"]) where body["kind"] == "Ingress" or body["kind"] == "VirtualService"
- set(attributes["k8s.configmap.name"], body["metadata"]["name"]) where body["kind"] == "ConfigMap"
- set(attributes["k8s.object.kind"], body["kind"]) where body["kind"] != nil

# There are some attributes added by k8sobjects receiver, SWO do not need them so removing it
Expand Down Expand Up @@ -185,6 +188,7 @@ processors:
- k8s.persistentvolumeclaim.name
- k8s.ingress.name
- sw.k8s.ingress.type
- k8s.configmap.name

- k8s.pod.labels
- k8s.deployment.labels
Expand All @@ -199,6 +203,7 @@ processors:
- k8s.persistentvolume.labels
- k8s.persistentvolumeclaim.labels
- k8s.ingress.labels
- k8s.configmap.labels

- k8s.pod.annotations
- k8s.deployment.annotations
Expand All @@ -213,6 +218,7 @@ processors:
- k8s.persistentvolume.annotations
- k8s.persistentvolumeclaim.annotations
- k8s.ingress.annotations
- k8s.configmap.annotations
{{- end }}

resource/events:
Expand Down Expand Up @@ -299,6 +305,7 @@ receivers:
"persistentvolumes"
"persistentvolumeclaims"
"ingresses"
"configmaps"
}}
{{- if or (.Capabilities.APIVersions.Has "networking.istio.io/v1alpha3") (.Capabilities.APIVersions.Has "networking.istio.io/v1beta1") (.Capabilities.APIVersions.Has "networking.istio.io/v1") -}}
{{- $arrayOfWatchedResources = append $arrayOfWatchedResources "virtualservices" }}
Expand Down
1 change: 1 addition & 0 deletions deploy/helm/templates/cluster-role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ rules:
- services
- persistentvolumes
- persistentvolumeclaims
- configmaps
verbs:
- get
- list
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Custom events filter with new syntax:
- k8s.persistentvolumeclaim.name
- k8s.ingress.name
- sw.k8s.ingress.type
- k8s.configmap.name
- k8s.pod.labels
- k8s.deployment.labels
- k8s.statefulset.labels
Expand All @@ -58,6 +59,7 @@ Custom events filter with new syntax:
- k8s.persistentvolume.labels
- k8s.persistentvolumeclaim.labels
- k8s.ingress.labels
- k8s.configmap.labels
- k8s.pod.annotations
- k8s.deployment.annotations
- k8s.statefulset.annotations
Expand All @@ -71,6 +73,7 @@ Custom events filter with new syntax:
- k8s.persistentvolume.annotations
- k8s.persistentvolumeclaim.annotations
- k8s.ingress.annotations
- k8s.configmap.annotations
memory_limiter:
check_interval: 1s
limit_mib: 512
Expand Down Expand Up @@ -339,6 +342,8 @@ Custom events filter with new syntax:
== "Ingress" or body["kind"] == "VirtualService"
- set(attributes["sw.k8s.ingress.type"], body["kind"]) where body["kind"] ==
"Ingress" or body["kind"] == "VirtualService"
- set(attributes["k8s.configmap.name"], body["metadata"]["name"]) where body["kind"]
== "ConfigMap"
- set(attributes["k8s.object.kind"], body["kind"]) where body["kind"] != nil
- delete_key(attributes, "k8s.resource.name")
- delete_key(attributes, "event.name")
Expand Down Expand Up @@ -378,6 +383,8 @@ Custom events filter with new syntax:
where body["kind"] == "PersistentVolumeClaim"
- set(attributes["k8s.ingress.annotations"], body["metadata"]["annotations"])
where body["kind"] == "Ingress"
- set(attributes["k8s.configmap.annotations"], body["metadata"]["annotations"])
where body["kind"] == "ConfigMap"
- set(attributes["k8s.pod.labels"], body["metadata"]["labels"]) where body["kind"]
== "Pod"
- set(attributes["k8s.deployment.labels"], body["metadata"]["labels"]) where
Expand All @@ -402,6 +409,8 @@ Custom events filter with new syntax:
where body["kind"] == "PersistentVolumeClaim"
- set(attributes["k8s.ingress.labels"], body["metadata"]["labels"]) where body["kind"]
== "Ingress"
- set(attributes["k8s.configmap.labels"], body["metadata"]["labels"]) where
body["kind"] == "ConfigMap"
transform/severity:
log_statements:
- context: log
Expand Down Expand Up @@ -513,6 +522,11 @@ Custom events filter with new syntax:
name: ingresses
- mode: watch
name: ingresses
- interval: 60m
mode: pull
name: configmaps
- mode: watch
name: configmaps
service:
extensions:
- health_check
Expand Down Expand Up @@ -601,6 +615,7 @@ Custom events filter with old syntax:
- k8s.persistentvolumeclaim.name
- k8s.ingress.name
- sw.k8s.ingress.type
- k8s.configmap.name
- k8s.pod.labels
- k8s.deployment.labels
- k8s.statefulset.labels
Expand All @@ -614,6 +629,7 @@ Custom events filter with old syntax:
- k8s.persistentvolume.labels
- k8s.persistentvolumeclaim.labels
- k8s.ingress.labels
- k8s.configmap.labels
- k8s.pod.annotations
- k8s.deployment.annotations
- k8s.statefulset.annotations
Expand All @@ -627,6 +643,7 @@ Custom events filter with old syntax:
- k8s.persistentvolume.annotations
- k8s.persistentvolumeclaim.annotations
- k8s.ingress.annotations
- k8s.configmap.annotations
memory_limiter:
check_interval: 1s
limit_mib: 512
Expand Down Expand Up @@ -895,6 +912,8 @@ Custom events filter with old syntax:
== "Ingress" or body["kind"] == "VirtualService"
- set(attributes["sw.k8s.ingress.type"], body["kind"]) where body["kind"] ==
"Ingress" or body["kind"] == "VirtualService"
- set(attributes["k8s.configmap.name"], body["metadata"]["name"]) where body["kind"]
== "ConfigMap"
- set(attributes["k8s.object.kind"], body["kind"]) where body["kind"] != nil
- delete_key(attributes, "k8s.resource.name")
- delete_key(attributes, "event.name")
Expand Down Expand Up @@ -934,6 +953,8 @@ Custom events filter with old syntax:
where body["kind"] == "PersistentVolumeClaim"
- set(attributes["k8s.ingress.annotations"], body["metadata"]["annotations"])
where body["kind"] == "Ingress"
- set(attributes["k8s.configmap.annotations"], body["metadata"]["annotations"])
where body["kind"] == "ConfigMap"
- set(attributes["k8s.pod.labels"], body["metadata"]["labels"]) where body["kind"]
== "Pod"
- set(attributes["k8s.deployment.labels"], body["metadata"]["labels"]) where
Expand All @@ -958,6 +979,8 @@ Custom events filter with old syntax:
where body["kind"] == "PersistentVolumeClaim"
- set(attributes["k8s.ingress.labels"], body["metadata"]["labels"]) where body["kind"]
== "Ingress"
- set(attributes["k8s.configmap.labels"], body["metadata"]["labels"]) where
body["kind"] == "ConfigMap"
transform/severity:
log_statements:
- context: log
Expand Down Expand Up @@ -1069,6 +1092,11 @@ Custom events filter with old syntax:
name: ingresses
- mode: watch
name: ingresses
- interval: 60m
mode: pull
name: configmaps
- mode: watch
name: configmaps
service:
extensions:
- health_check
Expand Down Expand Up @@ -1150,6 +1178,7 @@ Events config should match snapshot when using default values:
- k8s.persistentvolumeclaim.name
- k8s.ingress.name
- sw.k8s.ingress.type
- k8s.configmap.name
- k8s.pod.labels
- k8s.deployment.labels
- k8s.statefulset.labels
Expand All @@ -1163,6 +1192,7 @@ Events config should match snapshot when using default values:
- k8s.persistentvolume.labels
- k8s.persistentvolumeclaim.labels
- k8s.ingress.labels
- k8s.configmap.labels
- k8s.pod.annotations
- k8s.deployment.annotations
- k8s.statefulset.annotations
Expand All @@ -1176,6 +1206,7 @@ Events config should match snapshot when using default values:
- k8s.persistentvolume.annotations
- k8s.persistentvolumeclaim.annotations
- k8s.ingress.annotations
- k8s.configmap.annotations
memory_limiter:
check_interval: 1s
limit_mib: 512
Expand Down Expand Up @@ -1444,6 +1475,8 @@ Events config should match snapshot when using default values:
== "Ingress" or body["kind"] == "VirtualService"
- set(attributes["sw.k8s.ingress.type"], body["kind"]) where body["kind"] ==
"Ingress" or body["kind"] == "VirtualService"
- set(attributes["k8s.configmap.name"], body["metadata"]["name"]) where body["kind"]
== "ConfigMap"
- set(attributes["k8s.object.kind"], body["kind"]) where body["kind"] != nil
- delete_key(attributes, "k8s.resource.name")
- delete_key(attributes, "event.name")
Expand Down Expand Up @@ -1483,6 +1516,8 @@ Events config should match snapshot when using default values:
where body["kind"] == "PersistentVolumeClaim"
- set(attributes["k8s.ingress.annotations"], body["metadata"]["annotations"])
where body["kind"] == "Ingress"
- set(attributes["k8s.configmap.annotations"], body["metadata"]["annotations"])
where body["kind"] == "ConfigMap"
- set(attributes["k8s.pod.labels"], body["metadata"]["labels"]) where body["kind"]
== "Pod"
- set(attributes["k8s.deployment.labels"], body["metadata"]["labels"]) where
Expand All @@ -1507,6 +1542,8 @@ Events config should match snapshot when using default values:
where body["kind"] == "PersistentVolumeClaim"
- set(attributes["k8s.ingress.labels"], body["metadata"]["labels"]) where body["kind"]
== "Ingress"
- set(attributes["k8s.configmap.labels"], body["metadata"]["labels"]) where
body["kind"] == "ConfigMap"
transform/severity:
log_statements:
- context: log
Expand Down Expand Up @@ -1618,6 +1655,11 @@ Events config should match snapshot when using default values:
name: ingresses
- mode: watch
name: ingresses
- interval: 60m
mode: pull
name: configmaps
- mode: watch
name: configmaps
service:
extensions:
- health_check
Expand Down

0 comments on commit 20a2614

Please sign in to comment.