Skip to content

Commit e1add1a

Browse files
committed
flow and working on logs
1 parent af6c4c9 commit e1add1a

File tree

8 files changed

+65
-20
lines changed

8 files changed

+65
-20
lines changed

content/en/other/1-imt/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The workshops also introduce you to dashboards, editing and creating charts, cre
1515

1616
By the end of these technical workshops, you will have a good understanding of some of the key features and capabilities of the Splunk Observability Cloud.
1717

18-
Here are the instructions on how to access your pre-configured [AWS](./initial-setup/)/EC2 instance](./initial-setup/)
18+
Here are the instructions on how to access your pre-configured [AWS](./initial-setup/)/[EC2 instance](./initial-setup/)
1919

2020
![Splunk Architecture](images/architecture.png)
2121

content/en/other/3-auto-instrumentation/3-java-microservices-pet-clinic/10-preparation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ configmap/scriptfile created
4545
{{% /tab %}}
4646
{{< /tabs >}}
4747

48-
{{% notice title="In case of error Unable to read /etc/rancher/k3s/k3s.yaml" style="warning" %}}
48+
<!-- {{% notice title="In case of error Unable to read /etc/rancher/k3s/k3s.yaml" style="warning" %}}
4949
In rare occasions, you may encounter the above error at this point, this is due to incorrect file permission on the Kubernetes config file. This can easily be resolved by running the following command:
5050
5151
``` bash
5252
sudo chmod 777 /etc/rancher/k3s/k3s.yaml
5353
```
5454
55-
{{% /notice %}}
55+
{{% /notice %}} -->
5656
At this point we can verify the deployment by checking if the Pods are running:
5757
{{< tabs >}}
5858
{{% tab title="kubectl get pods" %}}

content/en/other/3-auto-instrumentation/3-java-microservices-pet-clinic/20-otel-collector.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,9 @@ helm delete splunk-otel-collector
195195
## 4. Verify the installation by checking Metrics and Logs
196196

197197
Once the installation is completed, you can login into the **Splunk Observability Cloud** with the URL provided by the Instructor.
198-
First, Navigate to **Kubernetes Navigator** in the **Infrastructure** section to see the metrics from your cluster inthe **K8s nodes** pane an change the *Time* filter to the last 15 Minutes (-15m).
198+
First, Navigate to **Kubernetes Navigator** in the **Infrastructure**![infra](../images/infra-icon.png?classes=inline&height=25px) section to see the metrics from your cluster in the **K8s nodes** pane. Change the *Time* filter to the last 15 Minutes (-15m) to focus on the lates data.
199199

200-
Use the regular filter option and select `k8s.cluster.name`**(1)**and type or select the cluster name of your workshop instance (you can get the unique part from your cluster name by using the `INSTANCE` from the output from the shell script you run earlier). (You can also select you cluster by clicking on on its image in the cluster pane.)
200+
Use the regular filter option at the top of the Navigator and select `k8s.cluster.name` **(1)** and type or select the cluster name of your workshop instance (you can get the unique part from your cluster name by using the `INSTANCE` from the output from the shell script you run earlier). (You can also select you cluster by clicking on on its image in the cluster pane.)
201201

202202
You should see metrics **(3)** & log events **(4)** related to your cluster. Also a `Mysql` pane **(5)** should appear,when you click on that pane, you can see the MySQL related metrics from you database.
203203

content/en/other/3-auto-instrumentation/3-java-microservices-pet-clinic/30-auto-instrumentation.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ linkTitle: 30. Auto-instrumentation & APM
44
weight: 30
55
---
66

7-
In the previous chapter, we enabled the OpenTelemetry Collector for Kubernetes and configured it to send metrics to the **Splunk Observability Cloud**. The next step is to enable auto-instrumentation for our Java apps running in the pods in our cluster.
7+
In the previous chapter, we enabled the OpenTelemetry Collector for Kubernetes on our cluster and configured it to send metrics both Kubernetes and Mysql metrics to the **Splunk Observability Cloud**. The next step is to enable auto-instrumentation for our Java apps running in the pods in our cluster.
8+
9+
{{% notice title="Zero Config Auto Instrumentation" style="info" %}}
10+
It is important to understand that Zero Config Auto instrumentation is designed to get Trace/Span & Profiling data out of your existing application, without requiring you to change your code or requiring to rebuild.
11+
{{% /notice %}}
12+
813

914
For this workshop we will be using the Zero config option of the Opentelemetry Collector in Kubernetes.
1015
This means that the Collector monitors you pods running in Kubernetes, and if they match certain criteria, they will en able auto instrumentation on the pod.
@@ -62,7 +67,7 @@ Image: quay.io/phagen/spring-petclinic-api-gateway:0.0.2
6267

6368
Once the container is patched it will be restarted, let's go back to the **Splunk Observability Cloud** with the URL provided by the Instructor to check our service.
6469

65-
First, Navigate to the **APM** section to see the traces from your service in the **Explore** Pane. Use the filter option and change the *environment* filter **(1)** and search for the name of your workshop instance in the drop down box, it should be the [INSTANCE]-workshop. (where `INSTANCE` is the value from the shell script you run earlier). Make sure it is the only one selected.
70+
First, Navigate to the **APM** ![APM](../images/apm-icon.png?classes=inline&height=25px) section to see the traces from your service in the **Explore** Pane. Use the filter option and change the *environment* filter **(1)** and search for the name of your workshop instance in the drop down box, it should be the [INSTANCE]-workshop. (where `INSTANCE` is the value from the shell script you run earlier). Make sure it is the only one selected.
6671
![apm](../images/apm-api-gateway-overview.png)
6772
You should see the name **(2)** of the service and metrics in the Latency and Request & Errors charts. (You can ignore the Critical Alert, Its caused by the sudden request increase generated by the load generator, It will become the norm in a bit and go away).
6873

content/en/other/3-auto-instrumentation/3-java-microservices-pet-clinic/60-log-observer-connect.md

Lines changed: 53 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,35 @@ weight: 60
66

77
## 1. Introduction
88

9-
For the Splunk Log Observer component, we will configure the Spring PetClinic application to use an Otel Based format to write logs, This will allow the (Auto)-instrumentation to add Otel relevant information to the logs that can be used to correlate Metric, traces and logs.
9+
Until this point, we have not touched or changed our code, yet we did receive Trace & Profiling/DB Query performance information.
10+
If we want to get more out of our Java application, we can introduce a small change to our application log setup.
11+
12+
This change will configure the Spring PetClinic application to use an Otel Based format to write logs, This will allow the (Auto)-instrumentation to add Otel relevant information into the logs.
13+
14+
The Splunk Log Observer component is used to view the logs and with this information can automatically relate logs information with APM Services and Traces. This feature called **Related Content** will also work with Infra structure.
1015

1116
## 2. Update Logback config for the services
1217

13-
The Spring PetClinic application can be configured to use several different Java logging libraries. In this scenario, the application is using `logback`. to make sure we get the otel information in the logs we just need to update a file named `logback.xml` for each of the services in the petclinc microservices folders.
18+
The Spring PetClinic application can be configured to use several different Java logging libraries. In this scenario, the application is using `logback`. To make sure we get the otel information in the logs we need to update a file named `logback.xml` with the log structure, and add an Otel dependency to the `pom.xml` of each of the services in the petclinic microservices folders.
19+
20+
First lets set the Log Structure/Format:
21+
22+
Spring boot will allow you to set a global template, but for ease of use, we will replace the existing content of the `logback-spring.xml` files of each service with the following XML content using a prepared script:
23+
Note the following entries that will be added:
1424

15-
Spring boot will allow you to set a global template, but for ease of use, we will replace the existing content of the `logback-spring.xml` files of each service with the following XML content using a prepared script:
25+
- trace_id
26+
- span_id
27+
- trace_flags
28+
- service.name
29+
- deployment.environment
30+
31+
These fields allows the **Splunk Observability Cloud Suite** to display **Related Content**:
1632

1733
```xml
1834
<?xml version="1.0" encoding="UTF-8"?>
1935
<configuration>
2036
<include resource="org/springframework/boot/logging/logback/base.xml"/>
21-
<!-- Required for Loglevel managment into the Spring Petclinic Admin Server-->
37+
<!-- Required for Loglevel management into the Spring Petclinic Admin Server-->
2238
<jmxConfigurator/>
2339
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
2440
<encoder>
@@ -40,6 +56,8 @@ Spring boot will allow you to set a global template, but for ease of use, we wi
4056
</configuration>
4157
```
4258

59+
So lets run the script that will update our log structure with the format above:
60+
4361
{{< tabs >}}
4462
{{% tab title="Update Logback files" %}}
4563

@@ -70,9 +88,15 @@ We can verify if the replacement has been successful by examining the spring-log
7088
cat /home/ubuntu/spring-petclinic-microservices/spring-petclinic-customers-service/src/main/resources/logback-spring.xml
7189
```
7290

73-
## 3. Recompile and store the services locally
91+
## 3. Reconfigure and build the services locally
92+
93+
Before we can build the new services with the updated log format we need to add the dependency to the `Pom.xml`:
7494

75-
Next, run the script that will use the `maven` command to compile/build/package the PetClinic microservices:
95+
```bash
96+
. ~/workshop/petclinic/scripts/add_otel.sh
97+
```
98+
99+
The Services are now ready to be build, so run the script that will use the `maven` command to compile/build/package the PetClinic microservices (Note the -P buildDocker, this will build the new containers):
76100
{{< tabs >}}
77101
{{% tab title="Running maven" %}}
78102

@@ -109,7 +133,7 @@ Successfully tagged quay.io/phagen/spring-petclinic-api-gateway:latest
109133
{{% /tab %}}
110134
{{< /tabs >}}
111135

112-
Next, run the script that will push the newly build containers into our local repository:
136+
Given that Kubernetes needs to pull these freshly build images from somewhere, we are going to store them in the repository we set up earlier. To do this, run the script that will push the newly build containers into our local repository:
113137

114138
{{< tabs >}}
115139
{{% tab title="pushing Containers" %}}
@@ -171,12 +195,31 @@ The result should be :
171195

172196
## 5. Deploy new services to kubernetes
173197

174-
To see the changes in effect, we need to redeploy the services, by applying the local version of the deployment yaml.
198+
To see the changes in effect, we need to redeploy the services, First let change the location of the images from the exterenal repo to the local one by running the following script:
199+
200+
```bash
201+
. ~/workshop/petclinic/scripts/set_local.sh
202+
```
203+
204+
The result is a new file on disk called **petclinic-local.yaml**
205+
Let switch to the local version by applying the local version of the deployment yaml.
175206

176207
```bash
177208
kubectl apply -f ~/workshop/petclinic/petclinic-local.yaml
178209
```
179-
this will cause the containers to be replaced with the local version, you can verify this by chcking the continers
210+
211+
This will cause the containers to be replaced with the local version, you can verify this by checking the containers:
212+
213+
```bash
214+
kubectl describe pods api-gateway |grep Image:
215+
```
216+
217+
The resulting output should say:
218+
219+
```text
220+
Image: ghcr.io/signalfx/splunk-otel-java/splunk-otel-java:v1.30.0
221+
Image: localhost:5000/spring-petclinic-api-gateway:local
222+
```
180223

181224
## 6. View Logs
182225

@@ -192,11 +235,8 @@ This is the end of the workshop and we have certainly covered a lot of ground. A
192235

193236
**Congratulations!**
194237

195-
196-
197238
docker system prune -a --volumes
198239

199-
200240
81 . ~/workshop/petclinic/scripts/add_otel.sh
201241
82 . ~/workshop/petclinic/scripts/update_logback.sh
202242
83 ./mvnw clean install -DskipTests -P buildDocker
@@ -210,4 +250,4 @@ docker system prune -a --volumes
210250
91 kubectl delete -f ~/workshop/petclinic/petclinic-local.yaml
211251
92 kubectl apply -f ~/workshop/petclinic/petclinic-local.yaml
212252
93 k9s
213-
94 kubectl get deployments -l app.kubernetes.io/part-of=spring-petclinic -o name | xargs -I % kubectl patch % -p "{\"spec\": {\"template\":{\"metadata\":{\"annotations\":{\"instrumentation.opentelemetry.io/inject-java\":\"true\"}}}}}"
253+
94 kubectl get deployments -l app.kubernetes.io/part-of=spring-petclinic -o name | xargs -I % kubectl patch % -p "{\"spec\": {\"template\":{\"metadata\":{\"annotations\":{\"instrumentation.opentelemetry.io/inject-java\":\"true\"}}}}}"
474 Bytes
Loading
382 Bytes
Loading
590 Bytes
Loading

0 commit comments

Comments
 (0)