Skip to content

Commit 5b3cf93

Browse files
committed
updated the docker-k8s-otel workshop
1 parent 144aa02 commit 5b3cf93

19 files changed

+383
-127
lines changed
File renamed without changes.
Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,13 @@ sudo sh /tmp/splunk-otel-collector.sh \
3434
{{% tab title="Example Output" %}}
3535

3636
``` bash
37-
TBD
37+
Splunk OpenTelemetry Collector Version: latest
38+
Memory Size in MIB: 512
39+
Realm: us1
40+
Ingest Endpoint: https://ingest.us1.signalfx.com
41+
API Endpoint: https://api.us1.signalfx.com
42+
HEC Endpoint: https://ingest.us1.signalfx.com/v1/log
43+
etc.
3844
```
3945

4046
{{% /tab %}}
@@ -58,7 +64,18 @@ sudo systemctl status splunk-otel-collector
5864
{{% tab title="Example Output" %}}
5965

6066
``` bash
61-
TBD
67+
● splunk-otel-collector.service - Splunk OpenTelemetry Collector
68+
Loaded: loaded (/lib/systemd/system/splunk-otel-collector.service; enabled; vendor preset: enabled)
69+
Drop-In: /etc/systemd/system/splunk-otel-collector.service.d
70+
└─service-owner.conf
71+
Active: active (running) since Fri 2024-12-20 00:13:14 UTC; 45s ago
72+
Main PID: 14465 (otelcol)
73+
Tasks: 9 (limit: 19170)
74+
Memory: 117.4M
75+
CPU: 681ms
76+
CGroup: /system.slice/splunk-otel-collector.service
77+
└─14465 /usr/bin/otelcol
78+
6279
```
6380

6481
{{% /tab %}}
@@ -79,7 +96,13 @@ sudo journalctl -u splunk-otel-collector
7996
{{% tab title="Example Output" %}}
8097

8198
``` bash
82-
TBD
99+
Dec 20 00:13:14 derek-1 systemd[1]: Started Splunk OpenTelemetry Collector.
100+
Dec 20 00:13:14 derek-1 otelcol[14465]: 2024/12/20 00:13:14 settings.go:483: Set config to /etc/otel/collector/agent_config.yaml
101+
Dec 20 00:13:14 derek-1 otelcol[14465]: 2024/12/20 00:13:14 settings.go:539: Set memory limit to 460 MiB
102+
Dec 20 00:13:14 derek-1 otelcol[14465]: 2024/12/20 00:13:14 settings.go:524: Set soft memory limit set to 460 MiB
103+
Dec 20 00:13:14 derek-1 otelcol[14465]: 2024/12/20 00:13:14 settings.go:373: Set garbage collection target percentage (GOGC) to 400
104+
Dec 20 00:13:14 derek-1 otelcol[14465]: 2024/12/20 00:13:14 settings.go:414: set "SPLUNK_LISTEN_INTERFACE" to "127.0.0.1"
105+
etc.
83106
```
84107

85108
{{% /tab %}}
Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
---
2+
title: Deploy a .NET Application
3+
linkTitle: 3. Deploy a .NET Application
4+
weight: 3
5+
time: 10 minutes
6+
---
7+
8+
## Prerequisites
9+
10+
Before deploying the application, we'll need to install the .NET 8 SDK on our instance.
11+
12+
{{< tabs >}}
13+
{{% tab title="Script" %}}
14+
15+
``` bash
16+
sudo apt-get update && \
17+
sudo apt-get install -y dotnet-sdk-8.0
18+
```
19+
20+
{{% /tab %}}
21+
{{% tab title="Example Output" %}}
22+
23+
``` bash
24+
Hit:1 http://us-west-1.ec2.archive.ubuntu.com/ubuntu jammy InRelease
25+
Hit:2 http://us-west-1.ec2.archive.ubuntu.com/ubuntu jammy-updates InRelease
26+
Hit:3 http://us-west-1.ec2.archive.ubuntu.com/ubuntu jammy-backports InRelease
27+
Hit:4 http://security.ubuntu.com/ubuntu jammy-security InRelease
28+
Ign:5 https://splunk.jfrog.io/splunk/otel-collector-deb release InRelease
29+
Hit:6 https://splunk.jfrog.io/splunk/otel-collector-deb release Release
30+
Reading package lists... Done
31+
Reading package lists... Done
32+
Building dependency tree... Done
33+
Reading state information... Done
34+
The following additional packages will be installed:
35+
aspnetcore-runtime-8.0 aspnetcore-targeting-pack-8.0 dotnet-apphost-pack-8.0 dotnet-host-8.0 dotnet-hostfxr-8.0 dotnet-runtime-8.0 dotnet-targeting-pack-8.0 dotnet-templates-8.0 liblttng-ust-common1
36+
liblttng-ust-ctl5 liblttng-ust1 netstandard-targeting-pack-2.1-8.0
37+
The following NEW packages will be installed:
38+
aspnetcore-runtime-8.0 aspnetcore-targeting-pack-8.0 dotnet-apphost-pack-8.0 dotnet-host-8.0 dotnet-hostfxr-8.0 dotnet-runtime-8.0 dotnet-sdk-8.0 dotnet-targeting-pack-8.0 dotnet-templates-8.0
39+
liblttng-ust-common1 liblttng-ust-ctl5 liblttng-ust1 netstandard-targeting-pack-2.1-8.0
40+
0 upgraded, 13 newly installed, 0 to remove and 0 not upgraded.
41+
Need to get 138 MB of archives.
42+
After this operation, 495 MB of additional disk space will be used.
43+
etc.
44+
```
45+
46+
{{% /tab %}}
47+
{{< /tabs >}}
48+
49+
Refer to [Install .NET SDK or .NET Runtime on Ubuntu](https://learn.microsoft.com/en-us/dotnet/core/install/linux-ubuntu-install?tabs=dotnet8&pivots=os-linux-ubuntu-2404)
50+
for further details.
51+
52+
## Review the .NET Application
53+
54+
In the terminal, navigate to the application directory:
55+
56+
``` bash
57+
cd ~/workshop/docker-k8s-otel/helloworld
58+
```
59+
60+
We'll use a simple "Hello World" .NET application for this workshop. The main logic is found
61+
in the Program.cs file:
62+
63+
``` cs
64+
using System.Globalization;
65+
66+
using Microsoft.AspNetCore.Mvc;
67+
68+
var builder = WebApplication.CreateBuilder(args);
69+
var app = builder.Build();
70+
71+
string Hello([FromServices]ILogger<Program> logger, string? name)
72+
{
73+
if (string.IsNullOrEmpty(name))
74+
{
75+
logger.LogInformation("Hello, World!);
76+
}
77+
else
78+
{
79+
logger.LogInformation("Hello, {result}!", name);
80+
}
81+
82+
return result.ToString(CultureInfo.InvariantCulture);
83+
}
84+
85+
app.MapGet("/hello/{name?}", Hello);
86+
87+
app.Run();
88+
```
89+
90+
## Build and Run the .NET Application
91+
92+
We can build the application using the following command:
93+
94+
{{< tabs >}}
95+
{{% tab title="Script" %}}
96+
97+
``` bash
98+
dotnet build
99+
```
100+
101+
{{% /tab %}}
102+
{{% tab title="Example Output" %}}
103+
104+
``` bash
105+
MSBuild version 17.8.5+b5265ef37 for .NET
106+
Determining projects to restore...
107+
All projects are up-to-date for restore.
108+
helloworld -> /home/splunk/workshop/docker-k8s-otel/helloworld/bin/Debug/net8.0/helloworld.dll
109+
110+
Build succeeded.
111+
0 Warning(s)
112+
0 Error(s)
113+
114+
Time Elapsed 00:00:02.04
115+
```
116+
117+
{{% /tab %}}
118+
{{< /tabs >}}
119+
120+
If that's successful, we can run it as follows:
121+
122+
{{< tabs >}}
123+
{{% tab title="Script" %}}
124+
125+
``` bash
126+
dotnet run
127+
```
128+
129+
{{% /tab %}}
130+
{{% tab title="Example Output" %}}
131+
132+
``` bash
133+
Building...
134+
info: Microsoft.Hosting.Lifetime[14]
135+
Now listening on: http://localhost:8080
136+
info: Microsoft.Hosting.Lifetime[0]
137+
Application started. Press Ctrl+C to shut down.
138+
info: Microsoft.Hosting.Lifetime[0]
139+
Hosting environment: Development
140+
info: Microsoft.Hosting.Lifetime[0]
141+
Content root path: /home/splunk/workshop/docker-k8s-otel/helloworld
142+
```
143+
144+
{{% /tab %}}
145+
{{< /tabs >}}
146+
147+
Once it's running, open a second SSH terminal and access the application using curl:
148+
149+
{{< tabs >}}
150+
{{% tab title="Script" %}}
151+
152+
``` bash
153+
curl http://localhost:8080/hello
154+
```
155+
156+
{{% /tab %}}
157+
{{% tab title="Example Output" %}}
158+
159+
``` bash
160+
Hello, World!
161+
```
162+
163+
{{% /tab %}}
164+
{{< /tabs >}}
165+
166+
You can also pass in your name:
167+
168+
{{< tabs >}}
169+
{{% tab title="Script" %}}
170+
171+
``` bash
172+
curl http://localhost:8080/hello/Tom
173+
```
174+
175+
{{% /tab %}}
176+
{{% tab title="Example Output" %}}
177+
178+
``` bash
179+
Hello, Tom!
180+
```
181+
182+
{{% /tab %}}
183+
{{< /tabs >}}
184+
185+
## Next Steps
186+
187+
What are the two methods that we can use to instrument our application with OpenTelemetry?
188+
189+
Hint: see [Instrument your .NET application for Splunk Observability Cloud](https://docs.splunk.com/observability/en/gdi/get-data-in/application/otel-dotnet/instrumentation/instrument-dotnet-application.html)
190+
for a discussion of the options.
Lines changed: 64 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ which we'll use to instrument our .NET application:
1717
{{% tab title="Script" %}}
1818

1919
``` bash
20+
cd ~/workshop/docker-k8s-otel/helloworld
21+
2022
curl -sSfL https://github.com/signalfx/splunk-otel-dotnet/releases/latest/download/splunk-otel-dotnet-install.sh -O
2123
```
2224

@@ -50,17 +52,30 @@ sh ./splunk-otel-dotnet-install.sh
5052
5153
Next, we can activate the OpenTelemetry instrumentation:
5254
55+
{{< tabs >}}
56+
{{% tab title="Script" %}}
57+
5358
``` bash
5459
. $HOME/.splunk-otel-dotnet/instrument.sh
5560
```
5661
62+
{{% /tab %}}
63+
{{% tab title="Example Output" %}}
64+
65+
``` bash
66+
Downloading v1.8.0 for linux-glibc (/tmp/tmp.m3tSdtbmge/splunk-opentelemetry-dotnet-linux-glibc-x64.zip)...
67+
```
68+
69+
{{% /tab %}}
70+
{{< /tabs >}}
71+
5772
## Set the Deployment Environment
5873

5974
Let's set the deployment environment, to ensure our data flows into its own
6075
environment within Splunk Observability Cloud:
6176

6277
``` bash
63-
export OTEL_RESOURCE_ATTRIBUTES='deployment.environment='otel-$INSTANCE'
78+
export OTEL_RESOURCE_ATTRIBUTES=deployment.environment=otel-$INSTANCE
6479
```
6580

6681
## A Challenge For You
@@ -117,23 +132,68 @@ As before, it should return `Hello, World!`.
117132
If you enabled trace logging, you should see a trace written the console or collector logs such as the following:
118133

119134
````
120-
TODO
135+
info: Program[0]
136+
/hello endpoint invoked anonymously
137+
Activity.TraceId: c7bbf57314e4856447508cd8addd49b0
138+
Activity.SpanId: 1c92ac653c3ece27
139+
Activity.TraceFlags: Recorded
140+
Activity.ActivitySourceName: Microsoft.AspNetCore
141+
Activity.DisplayName: GET /hello/{name?}
142+
Activity.Kind: Server
143+
Activity.StartTime: 2024-12-20T00:45:25.6551267Z
144+
Activity.Duration: 00:00:00.0006464
145+
Activity.Tags:
146+
server.address: localhost
147+
server.port: 8080
148+
http.request.method: GET
149+
url.scheme: http
150+
url.path: /hello
151+
network.protocol.version: 1.1
152+
user_agent.original: curl/7.81.0
153+
http.route: /hello/{name?}
154+
http.response.status_code: 200
155+
Resource associated with Activity:
156+
splunk.distro.version: 1.8.0
157+
telemetry.distro.name: splunk-otel-dotnet
158+
telemetry.distro.version: 1.8.0
159+
service.name: helloworld
160+
os.type: linux
161+
os.description: Ubuntu 22.04.5 LTS
162+
os.build_id: 6.8.0-1021-aws
163+
os.name: Ubuntu
164+
os.version: 22.04
165+
host.name: derek-1
166+
host.id: 20cf15fcc7054b468647b73b8f87c556
167+
process.owner: splunk
168+
process.pid: 16997
169+
process.runtime.description: .NET 8.0.11
170+
process.runtime.name: .NET
171+
process.runtime.version: 8.0.11
172+
container.id: 2
173+
telemetry.sdk.name: opentelemetry
174+
telemetry.sdk.language: dotnet
175+
telemetry.sdk.version: 1.9.0
176+
deployment.environment: otel-derek-1
121177
````
122178

123179
## View your application in Splunk Observability Cloud
124180

125-
Now that the setup is complete, let's confirm that it's sending data to **Splunk Observability Cloud**. Note that when the application is deployed for the first time, it may take a few minutes for the data to appear.
181+
Now that the setup is complete, let's confirm that traces are sent to **Splunk Observability Cloud**. Note that when the application is deployed for the first time, it may take a few minutes for the data to appear.
126182

127183
Navigate to APM, then use the Environment dropdown to select your environment (i.e. `otel-instancename`).
128184

129185
If everything was deployed correctly, you should see `helloworld` displayed in the list of services:
130186

131187
![APM Overview](../images/apm_overview.png)
132188

133-
Click on **Explore** on the right-hand side to view the service map.
189+
Click on **Service Map** on the right-hand side to view the service map.
134190

135191
![Service Map](../images/service_map.png)
136192

137193
Next, click on **Traces** on the right-hand side to see the traces captured for this application.
138194

139195
![Traces](../images/traces.png)
196+
197+
An individual trace should look like the following:
198+
199+
![Traces](../images/trace.png)

0 commit comments

Comments
 (0)