Skip to content

Commit a7fa430

Browse files
committed
secon excersise
1 parent 8f872f8 commit a7fa430

File tree

2 files changed

+175
-28
lines changed

2 files changed

+175
-28
lines changed
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
---
2+
title: Initial setup our agent config
3+
linkTitle: 1 - Agent Setup
4+
time: 10 minutes
5+
weight: 10
6+
---
7+
8+
Pick a location where you are going to run the workshop on your machine, (we will use [WORKSHOP] for this location), create a sub directory called **1-agent** and move into it.
9+
10+
In *[WORKSHOP]/1-agent* create a file called **agent.yaml** and copy the following starting config in it.
11+
12+
``` text
13+
receivers:
14+
15+
exporters:
16+
17+
processors:
18+
memory_limiter:
19+
check_interval: 2s
20+
limit_mib: 512
21+
22+
service:
23+
pipelines:
24+
traces:
25+
metrics:
26+
logs:
27+
```
28+
29+
Let's start with our first exercise:
30+
31+
{{% notice title="Exercise" style="green" icon="running" %}}
32+
33+
* Add an **otlp** receiver, under the *protocols* section, add a *HTTP* entry, with an endpoint of *"0.0.0.0:4318"* and add it to all the pipelines
34+
* Add a **debug** exporter with *verbosity* entry set to *detailed* and also add it to all the pipelines
35+
36+
{{% /notice %}}
37+
38+
{{% notice title="Tip" style="primary" icon="lightbulb" %}}
39+
Note that in the exercise above all key elements are highlighted, you just need to add them yourself.
40+
Pay attention to the format as the configuration of the agent is using yaml based.
41+
42+
{{% /notice %}}
43+
44+
if you use [https://www.otelbin.io/](https://www.otelbin.io/) to validate your agent.yaml your configuration should look like this:
45+
46+
![otelbin1](../images/agent-1-1.png)
47+
48+
---
49+
Run the following command to test your config (make sure you use the right otel collector you downloaded):
50+
51+
```text
52+
[LOCATION_OF_OTELCOLLECTOR]/otelcol_darwin_arm64 --config=agent.yaml
53+
```
54+
55+
If you have done everything correctly the last line of the out put should be :
56+
57+
```text
58+
2025-01-13T12:43:51.747+0100 info [email protected]/service.go:261 Everything is ready. Begin running and processing data.
59+
```
60+
61+
Now start a new shell and create a file called **trace.json* and copy the following content:
62+
63+
```text
64+
{
65+
"resourceSpans": [
66+
{
67+
"resource": {
68+
"attributes": [
69+
{
70+
"key": "service.name",
71+
"value": {
72+
"stringValue": "my.service"
73+
}
74+
},
75+
{
76+
"key": "deployment.environment",
77+
"value": {
78+
"stringValue": "my.environment"
79+
}
80+
}
81+
]
82+
},
83+
"scopeSpans": [
84+
{
85+
"scope": {
86+
"name": "my.library",
87+
"version": "1.0.0",
88+
"attributes": [
89+
{
90+
"key": "my.scope.attribute",
91+
"value": {
92+
"stringValue": "some scope attribute"
93+
}
94+
}
95+
]
96+
},
97+
"spans": [
98+
{
99+
"traceId": "5B8EFFF798038103D269B633813FC60C",
100+
"spanId": "EEE19B7EC3C1B174",
101+
"parentSpanId": "EEE19B7EC3C1B173",
102+
"name": "I'm a server span",
103+
"startTimeUnixNano": "1544712660000000000",
104+
"endTimeUnixNano": "1544712661000000000",
105+
"kind": 2,
106+
"attributes": [
107+
{
108+
"keytest": "my.span.attr",
109+
"value": {
110+
"stringValue": "some value"
111+
}
112+
}
113+
]
114+
}
115+
]
116+
}
117+
]
118+
}
119+
]
120+
}
121+
122+
```
123+
124+
In the second Shell, run the following command to test your setup:
125+
126+
```text
127+
curl -X POST -i http://localhost:4318/v1/traces \
128+
-H "Content-Type: application/json" \
129+
-d @trace.json
130+
```
131+
132+
Your collector should show the following output:
133+
134+
```text
135+
2025-01-13T13:26:13.502+0100 info Traces {"kind": "exporter", "data_type": "traces", "name": "debug", "resource spans": 1, "spans": 1}
136+
2025-01-13T13:26:13.502+0100 info ResourceSpans #0
137+
Resource SchemaURL:
138+
Resource attributes:
139+
-> service.name: Str(my.service)
140+
-> deployment.environment: Str(my.environment)
141+
ScopeSpans #0
142+
ScopeSpans SchemaURL:
143+
InstrumentationScope my.library 1.0.0
144+
InstrumentationScope attributes:
145+
-> my.scope.attribute: Str(some scope attribute)
146+
Span #0
147+
Trace ID : 5b8efff798038103d269b633813fc60c
148+
Parent ID : eee19b7ec3c1b173
149+
ID : eee19b7ec3c1b174
150+
Name : I'm a server span
151+
Kind : Server
152+
Start time : 2018-12-13 14:51:00 +0000 UTC
153+
End time : 2018-12-13 14:51:01 +0000 UTC
154+
Status code : Unset
155+
Status message :
156+
Attributes:
157+
-> : Str(some value)
158+
{"kind": "exporter", "data_type": "traces", "name": "debug"}
159+
```
160+
161+
Let's move on to adding a file exporter to use that to mimic a backend

content/en/ninja-workshops/10-advanced-otel/1-setup-agent/_index.md renamed to content/en/ninja-workshops/10-advanced-otel/10-agent-setup/fileexporter.md

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,23 @@
11
---
2-
title: Agent Setup
3-
linkTitle: 1. Agent Setup
4-
time: 10 minutes
2+
title: Add a File exporter and Meta Data.
3+
linkTitle: File exporter & Meta data
4+
weight: 15
55
---
6+
As we want to be able to see the output generated for the pipeline we are going to write the otlp data to files, so we can compare.
67

7-
In the location you are going to run the workshop on you machine, (we will use [WORKSHOP] for this location), create a sub directory called **1-agent** and move into it.
8-
9-
In *[WORKSHOP]/1-agent* create a file called **agent.yaml** and copy the folowing starting config in there
10-
11-
```yaml
12-
receivers:
13-
14-
exporters:
15-
16-
processors:
17-
memory_limiter:
18-
check_interval: 2s
19-
limit_mib: 512
20-
21-
service:
22-
pipelines:
23-
traces:
24-
metrics:
25-
logs:
26-
```
8+
Let's run our second exercise:
9+
10+
{{% notice title="Exercise" style="green" icon="running" %}}
2711

28-
Add an **otlp** receiver, under the `protocols` section, add a HTTP entry, with an endpoint of `0.0.0.0:4318` and add it to all the pipelines
29-
Add a **debug** exporter with `verbosity` set to `detailed` and also add it to all the pipelines
12+
* Add an **file** exporter, add a *path* entry, with a value of *"agent.out"* and add the exporter as the first exporter entry to all the pipelines (leaving debug in place)
3013

31-
Validate your `agent.yaml` with [https://otelbin.io](https://otelbin.io), your pipelines should look like this:
14+
{{% /notice %}}
15+
16+
Validate your new `agent.yaml` with [https://otelbin.io](https://otelbin.io), your pipelines should look like this:
3217

3318
![otelbin1](../images/agent-1-1.png)
3419

20+
---
3521
Run the following command to test your config (make sure you use the right otel collector you downloaded):
3622

3723
```text
@@ -44,7 +30,7 @@ If you have done everything correctly the last line of the out put should be:
4430
2025-01-13T12:43:51.747+0100 info [email protected]/service.go:261 Everything is ready. Begin running and processing data.
4531
```
4632

47-
Now start a new shell and create a file called **trace.json* and copy the following content:
33+
Now start a new shell and create a file called **trace.json* and copy the following content:
4834

4935
```json
5036
{
@@ -106,7 +92,7 @@ Now start a new shell and create a file called **trace.json* and copy the foll
10692
}
10793
```
10894

109-
then run the following command to test you setup:
95+
In the second Shell, run the following command to test your setup:
11096

11197
```shell
11298
curl -X POST -i http://localhost:4318/v1/traces \

0 commit comments

Comments
 (0)