Skip to content

Commit f7151d7

Browse files
author
Andrew Steurer
committed
adding observability and otel
Signed-off-by: Andrew Steurer <[email protected]>
1 parent 2ececb0 commit f7151d7

File tree

2 files changed

+206
-0
lines changed

2 files changed

+206
-0
lines changed

content/en/docs/reference/spin-app-executor.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,5 +136,58 @@ will be created containing the certificates. If no secret name is
136136
defined in `CACertSecret` the secret name will be `spin-ca`.<br/>
137137
</td>
138138
<td>false</td>
139+
</tr><tr>
140+
<td><b>otel</b></td>
141+
<td>string</td>
142+
<td>
143+
Otel creates environment variables which configure where and how telemetry data is exported from the Spin app.
144+
</td>
145+
<td>false</td>
139146
</tr></tbody>
140147
</table>
148+
149+
### `SpinAppExecutor.spec.deploymentConfig.otel`
150+
151+
<small>[back to parent](#spinappexecutorspecdeploymentconfig)</small>
152+
153+
Otel creates environment variables which configure where and how telemetry data is exported from the Spin app.
154+
155+
<table>
156+
<thead>
157+
<tr>
158+
<th>Name</th>
159+
<th>Type</th>
160+
<th>Description</th>
161+
<th>Required</th>
162+
</tr>
163+
</thead>
164+
<tbody><tr>
165+
<td><b>exporter_otlp_endpoint</b></td>
166+
<td>string</td>
167+
<td>
168+
Defines an endpoint to where all metrics, log, and trace data are exported.
169+
</td>
170+
<td>false</td>
171+
</tr><tr>
172+
<td><b>exporter_otlp_traces_endpoint</b></td>
173+
<td>string</td>
174+
<td>
175+
Defines an endpoint to where all trace data are exported.
176+
</td>
177+
<td>false</td>
178+
</tr><tr>
179+
<td><b>exporter_otlp_metrics_endpoint</b></td>
180+
<td>string</td>
181+
<td>
182+
Defines an endpoint to where all metrics data are exported.
183+
</td>
184+
<td>false</td>
185+
</tr><tr>
186+
<td><b>exporter_otlp_logs_endpoint</b></td>
187+
<td>string</td>
188+
<td>
189+
Defines an endpoint to where all log data are exported.
190+
</td>
191+
<td>false</td>
192+
</tr>
193+
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
---
2+
title: Observing SpinKube
3+
description: How to view telemetry data from your Spin apps running in SpinKube.
4+
weight: 13
5+
---
6+
7+
This topic guide shows you how to configure SpinKube so your Spin apps export telemetry data to OpenTelemetry collector and Jaeger.
8+
9+
## Prerequisites
10+
11+
Please ensure you have the following tools installed before continuing:
12+
13+
- [kubectl](https://kubernetes.io/docs/tasks/tools/) - the Kubernetes CLI
14+
- [Helm](https://helm.sh) - the package manager for Kubernetes
15+
- [SpinKube](https://www.spinkube.dev/docs/spin-plugin-kube/installation) - the Kubernetes plugin for Spin
16+
17+
## About OpenTelemetry Collector
18+
19+
From the OpenTelemetry [documentation](https://opentelemetry.io/docs/collector/):
20+
>> The OpenTelemetry Collector offers a vendor-agnostic implementation of how to receive, process and export telemetry data. It removes the need to run, operate, and maintain multiple agents/collectors. This works with improved scalability and supports open source observability data formats (e.g. Jaeger, Prometheus, Fluent Bit, etc.) sending to one or more open source or commercial backends.
21+
22+
In our case, the OpenTelemetry collector serves as a single endpoint to receive and route telemetry data, letting us to monitor metrics, traces, and logs via our preferred UIs.
23+
24+
## About Jaeger
25+
26+
From the Jaeger [documentation](https://www.jaegertracing.io/docs/):
27+
>> Jaeger is a distributed tracing platform released as open source by Uber Technologies. With Jaeger you can: Monitor and troubleshoot distributed workflows, Identify performance bottlenecks, Track down root causes, Analyze service dependencies
28+
29+
Here, we have the OpenTelemetry collector send the trace data to Jaeger.
30+
31+
## Deploy OpenTelemetry Collector
32+
33+
First, add the OpenTelemetry collector Helm repository:
34+
35+
```sh
36+
helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts
37+
helm repo update
38+
```
39+
40+
Next, deploy the OpenTelemetry collector to your cluster:
41+
42+
```sh
43+
helm upgrade --install otel-collector open-telemetry/opentelemetry-collector \
44+
--set image.repository="otel/opentelemetry-collector-k8s" \
45+
--set nameOverride=otel-collector \
46+
--set mode=deployment \
47+
--set config.exporters.otlp.endpoint=http://jaeger-collector.default.svc.cluster.local:4317 \
48+
--set config.exporters.otlp.tls.insecure=true \
49+
--set config.service.pipelines.traces.exporters[0]=otlp \
50+
--set config.service.pipelines.traces.processors[0]=batch \
51+
--set config.service.pipelines.traces.receivers[0]=otlp \
52+
--set config.service.pipelines.traces.receivers[1]=jaeger
53+
```
54+
55+
## Deploy Jaeger
56+
57+
Next, add the Jaeger Helm repository:
58+
59+
```sh
60+
helm repo add jaegertracing https://jaegertracing.github.io/helm-charts
61+
helm repo update
62+
```
63+
64+
Then, deploy Jaeger to your cluster:
65+
66+
```sh
67+
helm upgrade --install jaeger jaegertracing/jaeger \
68+
--set provisionDataStore.cassandra=false \
69+
--set allInOne.enabled=true \
70+
--set agent.enabled=false \
71+
--set collector.enabled=false \
72+
--set query.enabled=false \
73+
--set storage.type=memory
74+
```
75+
76+
## Configure the SpinAppExecutor
77+
78+
The `SpinAppExecutor` resource determines how Spin applications are deployed in the cluster. The following configuration will ensure that any `SpinApp` resource using this executor will send telemetry data to the OpenTelemetry collector. To see a comprehensive list of OTel options for the `SpinAppExecutor`, see the [API reference](https://www.spinkube.dev/docs/reference/spin-app-executor/).
79+
80+
Create a file called `executor.yaml` with the following content:
81+
82+
```yaml
83+
apiVersion: core.spinoperator.dev/v1alpha1
84+
kind: SpinAppExecutor
85+
metadata:
86+
name: otel-shim-executor
87+
spec:
88+
createDeployment: true
89+
deploymentConfig:
90+
runtimeClassName: wasmtime-spin-v2
91+
installDefaultCACerts: true
92+
otel:
93+
exporter_otlp_endpoint: http://otel-collector.default.svc.cluster.local:4318
94+
```
95+
96+
To deploy the executor, run:
97+
98+
```sh
99+
kubectl apply -f executor.yaml
100+
```
101+
102+
## Deploy a Spin app to observe
103+
104+
With everything in place, we can now deploy a `SpinApp` resource that uses the executor `otel-shim-executor`.
105+
106+
Create a file called `app.yaml` with the following content:
107+
108+
```yaml
109+
apiVersion: core.spinoperator.dev/v1alpha1
110+
kind: SpinApp
111+
metadata:
112+
name: otel-spinapp
113+
spec:
114+
image: ghcr.io/spinkube/spin-operator/cpu-load-gen:20240311-163328-g1121986
115+
executor: otel-shim-executor
116+
replicas: 1
117+
```
118+
119+
Deploy the app by running:
120+
121+
```sh
122+
kubectl apply -f app.yaml
123+
```
124+
125+
Congratulations! You now have a Spin app exporting telemetry data.
126+
127+
Next, we need to generate telemetry data for the Spin app to export. Use the below command to port-forward the Spin app:
128+
129+
```sh
130+
kubectl port-forward svc/otel-spinapp 3000:80
131+
```
132+
133+
In a new terminal window, execute a `curl` request:
134+
135+
```sh
136+
curl localhost:3000
137+
```
138+
139+
The request will take a couple of moments to run, but once it's done, you should see an output similar to this:
140+
141+
```
142+
fib(43) = 433494437
143+
```
144+
145+
## Interact with Jaeger
146+
147+
To view the traces in Jaeger, use the following port-forward command:
148+
149+
```sh
150+
kubectl port-forward svc/jaeger-query 16686:16686
151+
```
152+
153+
Then, open your browser and navigate to `localhost:16686` to interact with Jaeger's UI.

0 commit comments

Comments
 (0)