|
| 1 | +--- |
| 2 | +title: Apache OTel Receiver |
| 3 | +linkTitle: 3. Apache OTel Receiver |
| 4 | +weight: 3 |
| 5 | +--- |
| 6 | + |
| 7 | +## 1. Review OTel receiver for PHP/Apache |
| 8 | + |
| 9 | +Inspect the YAML file `~/workshop/k3s/otel-apache.yaml` and validate the contents using the following command: |
| 10 | + |
| 11 | +``` bash |
| 12 | +cat ~/workshop/k3s/otel-apache.yaml |
| 13 | +``` |
| 14 | + |
| 15 | +This file contains the configuration for the OpenTelemetry agent to monitor the PHP/Apache deployment. |
| 16 | + |
| 17 | +```yaml |
| 18 | +agent: |
| 19 | + config: |
| 20 | + receivers: |
| 21 | + receiver_creator: |
| 22 | + receivers: |
| 23 | + apache: |
| 24 | + rule: type == "port" && pod.name matches "apache" && port == 80 |
| 25 | + config: |
| 26 | + endpoint: http://php-apache-svc.apache.svc.cluster.local/server-status?auto |
| 27 | +``` |
| 28 | +
|
| 29 | +## 2. Observation Rules in the OpenTelemetry config |
| 30 | +
|
| 31 | +The above file 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. |
| 32 | + |
| 33 | +The configured rules will be evaluated for each endpoint discovered. If the rule evaluates to true, then the receiver for that rule will be started as configured against the matched endpoint. |
| 34 | + |
| 35 | +In the file above we tell the OpenTelemetry agent to look for Pods that match the name `apache` and have port `80` open. Once found, the agent will configure an Apache receiver to read Apache metrics from the configured URL. Note, the K8s DNS-based URL in the above YAML for the service. |
| 36 | + |
| 37 | +To use the Apache configuration, you can upgrade the existing Splunk OpenTelemetry Collector Helm chart to use the `otel-apache.yaml` file with the following command: |
| 38 | + |
| 39 | +{{< tabs >}} |
| 40 | +{{% tab title="Helm Upgrade" %}} |
| 41 | + |
| 42 | +``` bash |
| 43 | +helm upgrade splunk-otel-collector \ |
| 44 | +--set="splunkObservability.realm=$REALM" \ |
| 45 | +--set="splunkObservability.accessToken=$ACCESS_TOKEN" \ |
| 46 | +--set="clusterName=$INSTANCE-k3s-cluster" \ |
| 47 | +--set="splunkPlatform.endpoint=$HEC_URL" \ |
| 48 | +--set="splunkPlatform.token=$HEC_TOKEN" \ |
| 49 | +--set="splunkPlatform.index=splunk4rookies-workshop" \ |
| 50 | +splunk-otel-collector-chart/splunk-otel-collector \ |
| 51 | +-f ~/workshop/k3s/otel-collector.yaml \ |
| 52 | +-f ~/workshop/k3s/otel-apache.yaml |
| 53 | +``` |
| 54 | + |
| 55 | +{{% /tab %}} |
| 56 | +{{< /tabs >}} |
| 57 | + |
| 58 | +{{% notice title="NOTE" style="info" %}} |
| 59 | +The **REVISION** number of the deployment has changed, which is a helpful way to keep track of your changes. |
| 60 | + |
| 61 | +``` text |
| 62 | +Release "splunk-otel-collector" has been upgraded. Happy Helming! |
| 63 | +NAME: splunk-otel-collector |
| 64 | +LAST DEPLOYED: Mon Nov 4 14:56:25 2024 |
| 65 | +NAMESPACE: default |
| 66 | +STATUS: deployed |
| 67 | +REVISION: 2 |
| 68 | +TEST SUITE: None |
| 69 | +NOTES: |
| 70 | +Splunk OpenTelemetry Collector is installed and configured to send data to Splunk Platform endpoint "https://http-inputs-workshop.splunkcloud.com:443/services/collector/event". |
| 71 | +
|
| 72 | +Splunk OpenTelemetry Collector is installed and configured to send data to Splunk Observability realm eu0. |
| 73 | +``` |
| 74 | + |
| 75 | +{{% /notice %}} |
| 76 | + |
| 77 | +## 3. Kubernetes ConfigMaps |
| 78 | + |
| 79 | +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. |
| 80 | + |
| 81 | +Using ConfigMap, you can prevent hardcoding configuration data. ConfigMaps are useful for storing and sharing non-sensitive, unencrypted configuration information. |
| 82 | + |
| 83 | +The OpenTelemetry collector/agent uses ConfigMaps to store the configuration of the agent and the K8s Cluster receiver. You can/will always verify the current configuration of an agent after a change by running the following commands: |
| 84 | + |
| 85 | +``` bash |
| 86 | +kubectl get cm |
| 87 | +``` |
| 88 | + |
| 89 | +{{% notice title="Workshop Question" style="tip" icon="question" %}} |
| 90 | +How many ConfigMaps are used by the collector? |
| 91 | +{{% /notice %}} |
| 92 | + |
| 93 | +When you have a list of ConfigMaps from the namespace, select the one for the `otel-agent` and view it with the following command: |
| 94 | + |
| 95 | +``` bash |
| 96 | +kubectl get cm splunk-otel-collector-otel-agent -o yaml |
| 97 | +``` |
| 98 | + |
| 99 | +{{% notice title="NOTE" style="info" %}} |
| 100 | +The option `-o yaml` will output the content of the ConfigMap in a readable YAML format. |
| 101 | +{{% /notice %}} |
| 102 | + |
| 103 | +{{% notice title="Workshop Question" style="tip" icon="question" %}} |
| 104 | +Is the configuration from `otel-apache.yaml` visible in the ConfigMap for the collector agent? |
| 105 | +{{% /notice %}} |
0 commit comments