Monitoring Horizontal Pod Autoscaling in Kubernetes
Apache OTel Receiver
1. Review OTel receiver for Apache #
Inspect the YAML file ~/workshop/k3s/otel-apache.yaml and validate the contents using the following command:
cat ~/workshop/k3s/otel-apache.yamlThis file contains the configuration for the OpenTelemetry agent to monitor the Apache deployment:
agent:
config:
receivers:
receiver_creator:
receivers:
apache:
rule: type == "port" && pod.name matches "apache" && port == 80
config:
endpoint: http://apache-hpa-svc.apache.svc.cluster.local/server-status?auto2. Observation Rules in the OpenTelemetry config #
The file above contains an observation rule for Apache using the OTel receiver_creator. This receiver can instantiate other receivers at runtime based on whether observed endpoints match a configured rule.
The configured rules are evaluated for each endpoint discovered. If the rule evaluates to true, then the receiver for that rule is started as configured against the matched endpoint.
In this configuration, we tell the OpenTelemetry agent to look for Pods whose name matches apache and that expose port 80. Once found, the agent starts an Apache receiver to scrape metrics from the configured Kubernetes DNS URL (/server-status?auto).
Upgrade the existing Splunk OpenTelemetry Collector Helm release to include otel-apache.yaml:
helm upgrade splunk-otel-collector --version 0.165.0 \
--set="splunkObservability.realm=$REALM" \
--set="splunkObservability.accessToken=$ACCESS_TOKEN" \
--set="clusterName=$INSTANCE-k3s-cluster" \
--set="splunkPlatform.endpoint=$HEC_URL" \
--set="splunkPlatform.token=$HEC_TOKEN" \
--set="splunkPlatform.index=splunk4rookies-workshop" \
splunk-otel-collector-chart/splunk-otel-collector \
-f ~/workshop/k3s/otel-collector.yaml \
-f ~/workshop/k3s/otel-apache.yamlNOTE
The REVISION number of the deployment has changed, which is a helpful way to keep track of your changes.
Release "splunk-otel-collector" has been upgraded. Happy Helming!
NAME: splunk-otel-collector
LAST DEPLOYED: Mon Nov 4 14:56:25 2024
NAMESPACE: default
STATUS: deployed
REVISION: 2
TEST SUITE: None
NOTES:
Splunk OpenTelemetry Collector is installed and configured to send data to Splunk Platform endpoint "https://http-inputs-workshop.splunkcloud.com:443/services/collector/event".
Splunk OpenTelemetry Collector is installed and configured to send data to Splunk Observability realm eu0.3. Kubernetes ConfigMaps #
A ConfigMap is an object in Kubernetes consisting of key-value pairs that can be injected into your application. With a ConfigMap, you can separate configuration from your Pods and avoid hardcoding non-sensitive configuration data.
The OpenTelemetry collector uses ConfigMaps to store the configuration of the agent and the K8s Cluster receiver.
List the ConfigMaps in the default namespace:
kubectl get cmQuick check
How many ConfigMaps are created by the Splunk OpenTelemetry Collector chart?
splunk-otel-collector-otel-agent for the DaemonSet agent pods and splunk-otel-collector-otel-k8s-cluster-receiver for the cluster receiver pod.Inspect the otel-agent ConfigMap in YAML format:
kubectl get cm splunk-otel-collector-otel-agent -o yamlNOTE
-o yaml outputs the content of the ConfigMap in a readable YAML format.Quick check
Where does the configuration from otel-apache.yaml appear inside the otel-agent ConfigMap?
otel-apache.yaml into the agent ConfigMap under receivers.receiver_creator.receivers.apache, so the agent automatically starts scraping /server-status?auto as soon as a matching Apache pod appears.
