You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/en/other/wip/pet-clinic/10-preparation.md
+76-24Lines changed: 76 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,29 +1,25 @@
1
1
---
2
-
title: Zero Configuration Auto Instrumentation for Java
3
-
linkTitle: 2. Zero Configuration
4
-
weight: 2
2
+
title: Preparation of the Pet Clinic application.
3
+
linkTitle: 1. Preparation
4
+
weight: 10
5
5
---
6
6
7
-
## 1. Spring PetClinic Application
7
+
## 1. Spring PetClinic Application build
8
8
9
-
The first thing we need to set up APM is... well, an application. For this exercise, we will use the Spring PetClinic Microservices Application. This is a very popular sample Java application built with Spring framework (Springboot), using a Microservices Architecture.
9
+
The first thing we need to set up is... well, an application. For this exercise, we will use the Spring PetClinic application. This is a very popular sample Java application built with the Spring framework (Springboot). We are using the Micro services version of it.
10
10
11
-
First, clone the PetClinic GitHub repository, and then we will compile, build, package and test the application:
11
+
First, clone the PetClinic GitHub repository, and then we will compile, build, package and containerize the application:
Next, we will start a Docker container running Locust that will generate some simple traffic to the PetClinic application. Locust is a simple load-testing tool that can be used to generate traffic to a web application.
Next, run the `maven` command to compile/build/package PetClinic:
34
+
-->
35
+
Next, run the script that will use the `maven` command to compile/build/package the PetClinic Micro services into Docker containers:
40
36
41
37
```bash
42
-
./mvnw package -Dmaven.test.skip=true
38
+
. ./scripts/build.sh
43
39
```
44
40
45
41
{{% notice style="info" %}}
46
-
This will take a few minutes the first time you run, `maven` will download a lot of dependencies before it compiles the application. Future executions will be a lot quicker.
42
+
This will take a few minutes the first time you run, `maven` will download a lot of dependencies before it compiles the application. Future builds will be a lot quicker.
47
43
{{% /notice %}}
48
44
49
-
Once the compilation is complete, you can run the application with the following command. Notice that we are passing the `mysql` profile to the application, this will tell the application to use the MySQL database we started earlier. We are also setting the `otel.service.name` to a logical service name that will also be used in the UI for filtering:
45
+
## 2. Check Docker Images
46
+
47
+
Once the build completes, you need to verify if the containers are indeed build:
quay.io/phagen/spring-petclinic-api-gateway latest f954254824ed 7 seconds ago 510MB
64
+
<none> <none> 5dbbb7d1fbb2 9 seconds ago 563MB
65
+
quay.io/phagen/spring-petclinic-discovery-server latest 0761e73d679d 26 seconds ago 500MB
66
+
<none> <none> d71dc0ff96f4 28 seconds ago 544MB
67
+
quay.io/phagen/spring-petclinic-config-server latest 81a0ab6495c2 39 seconds ago 488MB
68
+
<none> <none> 69d60a035bb9 40 seconds ago 519MB
69
+
quay.io/phagen/spring-petclinic-visits-service latest ca306495bf11 50 seconds ago 526MB
70
+
<none> <none> b60155eb8ab4 52 seconds ago 596MB
71
+
quay.io/phagen/spring-petclinic-vets-service latest 29f1b1909b8b About a minute ago 527MB
72
+
<none> <none> b07e8de54c99 About a minute ago 598MB
73
+
quay.io/phagen/spring-petclinic-customers-service latest 5b21e448c91e About a minute ago 526MB
74
+
<none> <none> 722fa001614c About a minute ago 596MB
75
+
quay.io/phagen/spring-petclinic-admin-server latest 4a1906a91210 About a minute ago 498MB
76
+
<none> <none> 96f61c7bb66a About a minute ago 540MB
77
+
eclipse-temurin 17 807dd649ff14 13 days ago 407MB
78
+
79
+
```
80
+
81
+
{{% /tab %}}
82
+
{{< /tabs >}}
83
+
84
+
To test the application you need to obtain the public IP address of the instance you are running on. You can do this by running the following command:
85
+
86
+
```bash
87
+
curl ifconfig.me
88
+
89
+
```
90
+
91
+
You will see an IP address returned, make a note of this as we will need it to validate that the application is running.
92
+
93
+
We also need to obtain the `INSTANCE` environment variable value, as this is what is being used as the `otel.service.name` attribute. You can do this by running the following command:
94
+
95
+
```bash
96
+
echo$INSTANCE
97
+
```
98
+
99
+
Also, make a note of this value as we will need it to filter the data in the UI.
100
+
101
+
You can now run the application with the following command. Notice that we are passing the `mysql` profile to the application, this will tell the application to use the MySQL database we started earlier. We are also setting the `otel.service.name` to a logical service name that will also be used in the UI for filtering:
You can validate if the application is running by visiting `http://<VM_IP_ADDRESS>:8083`.
110
+
You can validate if the application is running by visiting `http://<IP_ADDRESS>:8083` (replace `<IP_ADDRESS>` with the IP address you obtained earlier). You should see the PetClinic application running.
59
111
60
112
## 2. AlwaysOn Profiling and Metrics
61
113
62
-
When we installed the collector we configured it to enable AlwaysOn Profiling and Metrics. This means that the collector will automatically generate CPU and Memory profiles for the application and send them to Splunk Observability Cloud.
114
+
When we installed the collector we configured it to enable **AlwaysOn Profiling** and **Metrics**. This means that the collector will automatically generate CPU and Memory profiles for the application and send them to Splunk Observability Cloud.
63
115
64
116
When you start the PetClinic application you will see the collector automatically detect the application and instrument it for traces and profiling.
65
117
@@ -92,7 +144,7 @@ OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader clas
92
144
93
145
## 3. Review Profiling Data Collection
94
146
95
-
You can now visit the Splunk APM UI and examine the application components, traces, profiling, DB Query performance and metrics. From the left-hand menu **APM** → Explore**, click the environment dropdown and select your environment (which is prefixed with the hostname of your instance).
147
+
You can now visit the Splunk APM UI and examine the application components, traces, profiling, DB Query performance and metrics. From the left-hand menu **APM** → **Explore**, click the environment dropdown and select your environment e.g. `<INSTANCE>-petclinic` (where`<INSTANCE>` is replaced with the value you noted down earlier).
96
148
97
149

98
150
@@ -102,13 +154,13 @@ Once your validation is complete you can stop the application by pressing `Ctrl-
102
154
103
155
Resource attributes can be added to every reported span. For example `version=0.314`. A comma-separated list of resource attributes can also be defined e.g. `key1=val1,key2=val2`.
104
156
105
-
Let's launch the PetClinic again using a new resource attribute. Note, that adding resource attributes to the run command will override what was defined when we installed the collector. Let's add a new resource attribute `version=0.314`:
157
+
Let's launch the PetClinic again using new resource attributes. Note, that adding resource attributes to the run command will override what was defined when we installed the collector. Let's add two new resource attributes `deployment.environment=$INSTANCE-petclinic-env,version=0.314`:
Copy file name to clipboardExpand all lines: content/en/other/wip/pet-clinic/20-otel-collector.md
+14-10Lines changed: 14 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,22 +1,22 @@
1
1
---
2
2
title: Installing the OpenTelemetry Collector
3
-
linkTitle: 1. OpenTelemetry Collector
4
-
weight: 1
3
+
linkTitle: 2. OpenTelemetry Collector
4
+
weight: 20
5
5
---
6
6
7
7
## 1. Introduction
8
8
9
-
The OpenTelemetry Collector is the core component of instrumenting infrastructure and applications. Its role is to collect and send:
9
+
The Splunk OpenTelemetry Collector is the core component of instrumenting infrastructure and applications. Its role is to collect and send:
10
10
11
-
* Infrastructure metrics (disk, cpu, memory, etc)
11
+
* Infrastructure metrics (disk, CPU, memory, etc)
12
12
* Application Performance Monitoring (APM) traces
13
13
* Profiling data
14
14
* Host and application logs
15
15
16
16
Splunk Observability Cloud offers a wizard to walk you through the setup of the Collector on both your infrastructure and applications.
17
17
18
18
{{% notice title="Delete any existing OpenTelemetry Collectors" style="warning" %}}
19
-
If you have completed the Splunk IM workshop, please ensure you have deleted the collector running in Kubernetes before continuing. This can be done by running the following command:
19
+
If you have completed a Splunk Observability workshop using this EC2 instance, please ensure you have deleted the collector running in Kubernetes before continuing. This can be done by running the following command:
20
20
21
21
```bash
22
22
helm delete splunk-otel-collector
@@ -38,6 +38,8 @@ In the output check the following environment variables are present and have val
38
38
ACCESS_TOKEN
39
39
REALM
40
40
RUM_TOKEN
41
+
HEC_TOKEN
42
+
HEC_URL
41
43
```
42
44
43
45
For this workshop, **all** of the above are required. If any are missing, please contact your instructor.
@@ -51,14 +53,17 @@ We can then go ahead and install the Collector. Some additional parameters are p
51
53
*`--enable-profiler` - Enables the profiler for the Java application. This will generate CPU profiles for the application.
52
54
*`--enable-profiler-memory` - Enables the profiler for the Java application. This will generate memory profiles for the application.
53
55
*`--enable-metrics` - Enables the exporting of Micrometer metrics
56
+
*`--hec-token` - Sets the HEC token for the collector to use
57
+
*`--hec-url` - Sets the HEC URL for the collector to use
If you are attempting this workshop on an AWS/EC2 instance you will have to patch the collector to expose the hostname of the instance:
64
+
When prompted to restart services, select 'OK' and press enter.
65
+
66
+
Next, we will patch the collector to expose the hostname of the instance and not the AWS instance ID. This will make it easier to filter data in the UI. Run the following command to patch the collector:
@@ -70,7 +75,6 @@ Once the `agent_config.yaml` has been patched, you will need to restart the coll
70
75
sudo systemctl restart splunk-otel-collector
71
76
```
72
77
73
-
{{% /notice %}}
74
78
Once the installation is completed, you can navigate to the **Hosts with agent installed** dashboard to see the data from your host, **Dashboards → Hosts with agent installed**.
75
79
76
-
Use the dashboard filter and select `host.name` and type or select the hostname of your virtual machine. Once you see data flowing for your host, we are then ready to get started with the APM component.
80
+
Use the dashboard filter and select `host.name` and type or select the hostname of your workshop instance (you can get this from the command prompt in your terminal session). Once you see data flowing for your host, we are then ready to get started with the APM component.
For the Real User Monitoring (RUM) instrumentation, we will add the Open Telemetry Javascript [**https://github.com/signalfx/splunk-otel-js-web**](https://github.com/signalfx/splunk-otel-js-web) snippet in the pages, we will use the wizard again **Data Management → Add Integration → RUM Instrumentation → Browser Instrumentation**.
10
+
11
+
Your instructor will inform you which token to use from the dropdown, click **Next**. Enter **App name** and **Environment** using the following syntax:
12
+
13
+
-`<INSTANCE>-petclinic-service` - replacing `<INSTANCE>` with the value you noted down earlier.
14
+
-`<INSTANCE>-petclinic-env` - replacing `<INSTANCE>` with the value you noted down earlier.
15
+
16
+
The wizard will then show a snippet of HTML code that needs to be placed at the top of the pages in the `<head>` section. The following is an example of the (do not use this snippet, use the one generated by the wizard):
17
+
18
+
```html
19
+
/*
20
+
21
+
IMPORTANT: Replace the <version> placeholder in the src URL with a
22
+
version from https://github.com/signalfx/splunk-otel-js-web/releases
The Spring PetClinic application uses a single HTML page as the "layout" page, that is reused across all pages of the application. This is the perfect location to insert the Splunk RUM Instrumentation Library as it will be loaded in all pages automatically.
37
+
38
+
Let's then edit the layout page:
39
+
40
+
```bash
41
+
vi src/main/resources/templates/fragments/layout.html
42
+
```
43
+
44
+
Next, insert the snippet we generated above in the `<head>` section of the page. Make sure you don't include the comment and replace `<version>` in the source URL to `latest` e.g.
Then let's visit the application using a browser to generate real-user traffic `http://<IP_ADDRESS>:8083`.
80
+
81
+
In RUM, filter down into the environment as defined in the RUM snippet above and click through to the dashboard.
82
+
83
+
When you drill down into a RUM trace you will see a link to APM in the spans. Clicking on the trace ID will take you to the corresponding APM trace for the current RUM trace.
0 commit comments