swo-k8s-collector
by SolarWinds
SolarWinds Kubernetes Integration
About this chart
swo-k8s-collector
Table of contents
- Architecture
- Installation
- Requirements
- Configuration
- Features
- Metrics Collection
- Logs Collection
- Events Collection
- Manifests Collection
- APM auto Instrumentation (disabled by default)
- AWS Fargate (disabled by default)
- OBI (OpenTelemetry eBPF Instrumentation)
- OpenShift Support (disabled by default)
- Auto Update (disabled by default)
- Image vulnerability scanning (disabled by default)
- Receive 3rd party metrics
- Uninstallation
Architecture
flowchart LR
%% Kubernetes Control Plane
subgraph Kubernetes
KubeAPI:::k8s
CoreDNS:::k8s
ETCD:::k8s
PrometheusWorkloads["Kubernetes Workloads"]:::deployment
subgraph "SWO K8s Collector Chart"
subgraph "Otel Operator Chart"
OtelOperator["OtelOperator"]:::deployment
TargetAllocator["TargetAllocator"]:::deployment
end
subgraph "Cert Manager Chart"
CertManager["CertManager"]:::deployment
end
subgraph "KubeStateMetrics Chart"
KubeStateMetrics["kube-state-metrics"]:::deployment
end
MetricsCollector["Metrics Collector"]:::deployment
DiscoveryCollector["Discovery Collector"]:::statefulset
EventCollector["Event Collector"]:::deployment
OBI["OpenTelemetry eBPF Instrumentation"]:::daemonset
Gateway["OTLP Gateway"]:::deployment
NodeCollector["Node Collector"]:::daemonset
OtelCollectorCrd["OpenTelemetryCollector CRD"]:::crd
OtelCollectorCrd---DiscoveryCollector
DiscoveryCollector--> |"get targets"| TargetAllocator
end
subgraph "Nodes"
WorkloadLogs["Container Logs"]
end
end
%% SWO with explicit interface node
subgraph "SolarWinds Observability (SWO)"
SWO_Interface["SWO OTLP"]:::swo
end
%% Connections explicitly via SWO Interface
NodeCollector --> |"scrape"| PrometheusWorkloads
DiscoveryCollector --> |"scrape"| PrometheusWorkloads
OtelOperator---> |"autoinstruments"| PrometheusWorkloads
NodeCollector --> WorkloadLogs
NodeCollector --> |"ingest"| SWO_Interface
K8sCollector --> |"watch"| KubeAPI
TargetAllocator --> |"discover"| KubeAPI
KubeStateMetrics --> KubeAPI
%% Gateway connections
OBI --> |"ingest"| Gateway
Gateway --> |"ingest"| SWO_Interface
MetricsCollector --> |"scrape"| KubeStateMetrics
MetricsCollector --> |"scrape"| CoreDNS
MetricsCollector --> |"scrape"| ETCD
%% Trick to move SWO more to the right
MetricsCollector --> |"ingest"| SWO_Interface
EventCollector --> |"watch events"| KubeAPI
EventCollector -->|"watch/poll manifests"| KubeAPI
NodeCollector --> |"watch"| KubeAPI
MetricsCollector --> |"watch"| KubeAPI
EventCollector --> |"ingest"| SWO_Interface
%% Class definitions for colors
classDef swo fill:#ffcc00,color:#000000,stroke:#ffa500,stroke-width:2px;
classDef daemonset fill:#e0f2f1,color:#004d40,stroke:#26a69a,stroke-width:2px;
classDef deployment fill:#e8f5e9,color:#1b5e20,stroke:#66bb6a,stroke-width:2px;
classDef statefulset fill:#ffffcc,color:#4d4d00,stroke:#e6e600,stroke-width:2px;
classDef crd fill:#ff9999,color:#4d0000,stroke:#cc0000,stroke-width:2px;
classDef k8s fill:#e3f2fd,color:#0d47a1,stroke:#42a5f5,stroke-width:2px;
classDef invisible display:none;
Installation
Walk through Add a Kubernetes cluster in SolarWinds Observability
Requirements
- Each Kubernetes version is supported for 15 months after its initial release. For example, version 1.27 released on April 11, 2023 is supported until July 11, 2024. For release dates for individual Kubernetes versions, see Patch Releases in Kubernetes documentation.
- Local Kubernetes deployments (e.q. Minikube, Docker Desktop) are not supported (although most of the functionality may be working).
- Note: since Kubernetes v1.24 Docker container runtime will not be reporting pod level network metrics (
kubenetand other network plumbing was removed from upstream as part of the dockershim removal/deprecation)
- Supported architectures: Linux x86-64 (
amd64), Linux ARM (arm64), Windows x86-64 (amd64). - Helm 3.9.0 or newer.
Configuration
The Helm chart that you are about to deploy to your cluster has various configuration options. The full list, including the default settings, is available in values.yaml.
Internally, it contains OpenTelemetry Collector configuration, which defines the metrics and logs to be monitored as well as their preprocessing.
WARNING: Custom modifications to OpenTelemetry Collector configurations can lead to unexpected swo-k8s-collector behavior, data loss, and subsequent entity ingestion failures on the Solarwinds Observability platform side.
Mandatory configuration
In order to deploy the Helm chart, you need to prepare:
-
A secret called
solarwinds-api-tokenwith API token for sending data to SolarWinds Observability -
A Helm chart configuration:
otel: endpoint: <solarwinds-observability-otel-endpoint> cluster: name: <cluster-display-name>
Version prior to 4.1.0
Before version 4.1.0 setting cluster.uid was requried. Starting with version 4.1.0, it became optional. If not provided, it defaults to the value of cluster.name.
How to limit instrumentation of collector
Starting from version 4.4.0, it is possible to specify global namespace filter. You can use include_namespaces and include_namespaces_regex or exclude_namespaces and exclude_namespaces_regex conditions, but not include_ and exclude_ at the same time. Filter is applied to metrics, events and logs.
otel:
endpoint: <solarwinds-observability-otel-endpoint>
cluster:
name: <cluster-display-name>
filter:
exclude_namespaces:
- some-namespace
exclude_namespaces_regex:
- "^(dev|stage)-.*"
Note: Global namespace filter is applied before individual filters mentioned below.
Version prior to 4.4.0
There are 5 filters that can to be set to limit the instrumentation of the collector in values.yaml. To fully limit the collector to not create entities, you need to set all filters.
otel.metrics.filterotel.metrics.autodiscovery.prometheusEndpoints.filterotel.events.filterotel.logs.filterotel.manifests.filter
The filter is applied after metric processing, it is the place where metrics could be filtered out. For configuration reference see Filter Processor documentation.
Note: Filtering by labels and annotations is not possible.
Here is example of configuration with all filters. The following example excludes all data from namespaces other than 'foo' and 'bar', but we need to add a condition that allows data without namespace attribute to be collected.
otel:
metrics:
autodiscovery:
prometheusEndpoints:
filter:
metric:
- not(IsMatch(resource.attributes["k8s.namespace.name"], "foo|bar") or resource.attributes["k8s.namespace.name"] == nil)
filter:
metric:
- not(IsMatch(resource.attributes["k8s.namespace.name"], "foo|bar") or resource.attributes["k8s.namespace.name"] == nil)
events:
filter:
log_record:
- not(IsMatch(resource.attributes["k8s.namespace.name"], "foo|bar") or resource.attributes["k8s.namespace.name"] == nil)
logs:
filter:
log_record:
- not(IsMatch(resource.attributes["k8s.namespace.name"], "foo|bar") or resource.attributes["k8s.namespace.name"] == nil)
manifests:
filter:
log_record:
- not(IsMatch(resource.attributes["k8s.namespace.name"], "foo|bar") or resource.attributes["k8s.namespace.name"] == nil)
Here is an example of a filter that allows all data except data from the namespaces 'foo' and 'bar' to be collected:
- IsMatch(resource.attributes["k8s.namespace.name"], "foo|bar")
Another example of filter that allows all data except data related to deployment 'foo' and its related entities (pods, containers)
- resource.attributes["k8s.deployment.name"] == "foo"
Features
Metrics Collection
Enabled by default. To disable, set otel.metrics.enabled: false.
See Kubernetes metrics for the list of all metrics exported by the SWO K8s Collector.
Metrics from core Kubernetes resources and workloads
The SWO K8s Collector collects metrics from these core Kubernetes resources and workloads using their Prometheus endpoints:
kube-state-metrics- these metrics have prefixk8s.kube_cAdvisor- these metrics have prefixk8s.container_apiserver- these metrics have prefixk8s.apiserver_coredns- enabled throughotel.metrics.control_plane.coredns.enabledetcd- enabled throughotel.metrics.control_plane.etcd.enabledcontroller_manager- enabled throughotel.metrics.control_plane.controller_manager.enabledcertmanager
The SWO K8s Collector also creates some additional metrics using the metrics above. These metrics have prefixes:
k8s.cluster.k8s.node.k8s.deployment.k8s.kube.jobk8s.persistentvolume.k8s.persistentvolumeclaim.k8s.pod.k8s.container.k8s.apiserver.
Application metrics from their Prometheus metrics endpoints
Annotation based discovery
Enabled by default. To disable, set otel.metrics.autodiscovery.prometheusEndpoints.enabled: false.
SWO K8s Collector performs discovery of application Prometheus endpoints, based on the following annotations on the workloads:
prometheus.io/scrape- enable/disable collectionprometheus.io/scheme- one ofhttp/https(defaulthttp)prometheus.io/path- path of Prometheus endpoint (default/metrics)prometheus.io/port- port of Prometheus endpoint (default9090)
Additional discovery rules can be configured using otel.metrics.autodiscovery.prometheusEndpoints.additionalRules (see settings in the otel.metrics.autodiscovery.prometheusEndpoints section of the values.yaml).
Discovery based on Pod/Service monitors
SWO K8s Collector can discover Prometheus Operator CRDs (ServiceMonitors, PodMonitors, ScrapeConfigs, and Probes) and scrape Prometheus endpoints based on them.
Internally, it leverages the TargetAllocator feature of the OpenTelemetry Operator.
Keep in mind that there can be duplicate scrapes of the same targets if the Annotation based discovery is enabled (which is the default). To avoid duplicate scrapes, it is recommended to disable the default discovery and also set the sw.ignore=true label on all CRDs that are already monitored by default by the SWO K8s Collector (kubelet metrics, kube-state-metrics, apiserver).
Configuration:
-
Enable deployment of the operator
The same as in APM auto Instrumentation (disabled by default).
-
Ensure proper TLS Certificate management
The same as in APM auto Instrumentation (disabled by default).
-
Deploy Prometheus Operator CRDs
Set
prometheusCRDs.install=trueinvalues.yaml. -
Enable Discovery Collector
Set
otel.metrics.autodiscovery.discovery_collector.enabled=trueinvalues.yaml.Note for GitOps users: If you are using GitOps tools like FluxCD or ArgoCD, it is recommended to install the OpenTelemetry Operator separately from this chart. In that case, you should also set
otel.metrics.autodiscovery.discovery_collector.installWithHelmHooks=falseinvalues.yaml. GitOps tools may not correctly reconcile resources that are installed as Helm hooks. -
Configure the right selectors for Prometheus CRDs
By default, all CRDs that do not have the
sw.ignore=truelabel are discovered. This can be overridden by the following configuration invalues.yaml:otel: metrics: autodiscovery: discovery_collector: targetAllocator: # see https://github.com/open-telemetry/opentelemetry-operator/blob/main/docs/api/opentelemetrycollectors.md#opentelemetrycollectorspectargetallocatorprometheuscrservicemonitorselector serviceMonitorSelector: {} # see https://github.com/open-telemetry/opentelemetry-operator/blob/main/docs/api/opentelemetrycollectors.md#opentelemetrycollectorspectargetallocatorprometheuscrpodmonitorselector podMonitorSelector: {} # see https://github.com/open-telemetry/opentelemetry-operator/blob/main/docs/api/opentelemetrycollectors.md#opentelemetrycollectorspectargetallocatorprometheuscrprobeselector probeSelector: {} # see https://github.com/open-telemetry/opentelemetry-operator/blob/main/docs/api/opentelemetrycollector
Deploy swo-k8s-collector with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has swo-k8s-collector on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartswo-k8s-collector is pinned at v5.4.0-alpha.12 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below opentenant validate opentenant.yaml terraform init && terraform apply