Skip to content

Commit a04bafc

Browse files
committed
Fixed logging service.name
1 parent 705c4ca commit a04bafc

File tree

1 file changed

+24
-19
lines changed

1 file changed

+24
-19
lines changed

content/en/other/pet-clinic/logobserver.md

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ We need to configure the Splunk OpenTelemetry Collector to tail the Spring PetCl
1313

1414
The Splunk OpenTelemetry Collector uses FluentD to consume/report logs and to configure the proper setting to report Spring PetClinic logs, we just need to add a FluentD configuration file in the default directory (`/etc/otel/collector/fluentd/conf.d/`).
1515

16-
Here's the sample FluentD configuration file (`petclinic.conf`, reading the file `/tmp/spring-petclinic.log`)
16+
So we need to create the a new FluentD configuration file:
17+
18+
```bash
19+
sudo vi /etc/otel/collector/fluentd/conf.d/petclinic.conf
20+
```
21+
22+
Copy and paste in the following configuration, this will read the file `/tmp/spring-petclinic.log` that will be configured in the next section.
1723

1824
```ini
1925
<source>
@@ -29,28 +35,28 @@ Here's the sample FluentD configuration file (`petclinic.conf`, reading the file
2935
</source>
3036
```
3137

32-
So we need to create the file
33-
34-
```bash
35-
sudo vi /etc/otel/collector/fluentd/conf.d/petclinic.conf
36-
```
37-
38-
We also need to change permission and ownership of the petclinic.conf file
38+
We now need to change permission and ownership of the petclinic.conf file so the agent can read it:
3939

4040
```bash
4141
sudo chown td-agent:td-agent /etc/otel/collector/fluentd/conf.d/petclinic.conf
4242
sudo chmod 755 /etc/otel/collector/fluentd/conf.d/petclinic.conf
4343
```
4444

45-
And paste the contents from the snippet above. Once the file is created, we need to restart the FluentD process
45+
Now that we have created the new configuration and changed the permissions we need to restart the FluentD process:
4646

4747
```bash
4848
sudo systemctl restart td-agent
4949
```
5050

5151
## 3. Logback Settings
5252

53-
The Spring PetClinic application can be configure to use a number of different java logging libraries. In this scenario, we are using logback. Here's a sample logback configuration file:
53+
The Spring PetClinic application can be configured to use a number of different java logging libraries. In this scenario, we are using logback. We just need to create a file named `logback.xml` in the configuration folder:
54+
55+
```bash
56+
vi src/main/resources/logback.xml
57+
```
58+
59+
Copy and paste the following XML content:
5460

5561
```xml
5662
<?xml version="1.0" encoding="UTF-8"?>
@@ -69,7 +75,9 @@ The Spring PetClinic application can be configure to use a number of different j
6975
</rollingPolicy>
7076
<encoder>
7177
<pattern>
72-
%d{yyyy-MM-dd HH:mm:ss} - %logger{36} - %msg trace_id=%X{trace_id} span_id=%X{span_id} trace_flags=%X{trace_flags} %n service: %property{otel.resource.service.name}, env: %property{otel.resource.deployment.environment}: %m%n
78+
%d{yyyy-MM-dd HH:mm:ss} - %logger{36} - %msg trace_id=%X{trace_id} span_id=%X{span_id} trace_flags=%X{trace_flags}
79+
%n service.name=%property{otel.resource.service.name}, deployment.environment=%property{otel.resource.deployment.environmen
80+
t}: %m%n
7381
</pattern>
7482
</encoder>
7583
</appender>
@@ -79,18 +87,14 @@ The Spring PetClinic application can be configure to use a number of different j
7987
</configuration>
8088
```
8189

82-
We just need to create a file named logback.xml in the configuration folder.
83-
84-
```bash
85-
vi src/main/resources/logback.xml
86-
```
87-
88-
and paste the XML content from the snippet above. After that, we need to rebuild the application and run it again:
90+
Now we need to rebuild the application and run it again:
8991

9092
```bash
9193
./mvnw package -Dmaven.test.skip=true
9294
```
9395

96+
And then run the application again:
97+
9498
```bash
9599
java \
96100
-Dotel.service.name=$(hostname)-petclinic.service \
@@ -107,8 +111,9 @@ Hamburger Menu > Log Observer
107111

108112
And you can add a filter to select only log messages from your host and the Spring PetClinic Application:
109113

114+
- Add Filter → Fields → `host.name``<your host name>`
110115
- Add Filter → Fields → `service.name``<your host name>-petclinic.service`
111116

112117
## 4. Summary
113118

114-
This the end of the exercise and we have certainly covered a lot of ground. At this point you should have metrics, traces, logs, database query performance and code profiling being reported into Splunk Observability Cloud. **Congratulations**!
119+
This the end of the exercise and we have certainly covered a lot of ground. At this point you should have metrics, traces (APM & RUM), logs, database query performance and code profiling being reported into Splunk Observability Cloud. **Congratulations**!

0 commit comments

Comments
 (0)