Skip to content

Commit fa5ee35

Browse files
committed
added lokiUrl
1 parent 4bc64ba commit fa5ee35

File tree

13 files changed

+350
-10
lines changed

13 files changed

+350
-10
lines changed

api-gateway/src/main/resources/application.properties

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,8 @@ resilience4j.retry.configs.default.wait-duration=2s
4141
management.metrics.distribution.percentiles-histogram.http.server.requests=true
4242
management.observations.key-values.application=product-service
4343

44-
management.tracing.sampling.probability=1.0
44+
management.tracing.sampling.probability=1.0
45+
46+
47+
48+
loki.url=http://localhost:3100/loki/api/v1/push

api-gateway/src/main/resources/logback-spring.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
<configuration>
33
<include resource="org/springframework/boot/logging/logback/base.xml"/>
44
<springProperty scope="context" name="appName" source="spring.application.name"/>
5+
<springProperty scope="context" name="lokiUrl" source="loki.url"/>
56

67
<appender name="LOKI" class="com.github.loki4j.logback.Loki4jAppender">
78
<http>
8-
<url>http://localhost:3100/loki/api/v1/push</url>
9+
<url>${lokiUrl}</url>
910
</http>
1011
<format>
1112
<label>

inventory-service/src/main/resources/application.properties

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,7 @@ management.endpoints.web.exposure.include=health, info, metrics, prometheus
1616
management.metrics.distribution.percentiles-histogram.http.server.requests=true
1717
management.observations.key-values.application=inventory-service
1818

19-
management.tracing.sampling.probability=1.0
19+
management.tracing.sampling.probability=1.0
20+
21+
22+
loki.url=http://localhost:3100/loki/api/v1/push

inventory-service/src/main/resources/logback-spring.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
<configuration>
33
<include resource="org/springframework/boot/logging/logback/base.xml"/>
44
<springProperty scope="context" name="appName" source="spring.application.name"/>
5+
<springProperty scope="context" name="lokiUrl" source="loki.url"/>
56

67
<appender name="LOKI" class="com.github.loki4j.logback.Loki4jAppender">
78
<http>
8-
<url>http://localhost:3100/loki/api/v1/push</url>
9+
<url>${lokiUrl}</url>
910
</http>
1011
<format>
1112
<label>
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
labels:
5+
app: grafana
6+
name: grafana
7+
spec:
8+
replicas: 1
9+
selector:
10+
matchLabels:
11+
app: grafana
12+
template:
13+
metadata:
14+
labels:
15+
app: grafana
16+
spec:
17+
containers:
18+
- image: grafana/grafana:10.1.0
19+
name: grafana
20+
ports:
21+
- containerPort: 3000
22+
env:
23+
- name: GF_AUTH_ANONYMOUS_ENABLED
24+
valueFrom:
25+
configMapKeyRef:
26+
key: GF_AUTH_ANONYMOUS_ENABLED
27+
name: grafana-configmap
28+
- name: GF_AUTH_ANONYMOUS_ORG_ROLE
29+
valueFrom:
30+
configMapKeyRef:
31+
key: GF_AUTH_ANONYMOUS_ORG_ROLE
32+
name: grafana-configmap
33+
- name: GF_AUTH_DISABLE_LOGIN_FORM
34+
valueFrom:
35+
configMapKeyRef:
36+
key: GF_AUTH_DISABLE_LOGIN_FORM
37+
name: grafana-configmap
38+
volumeMounts:
39+
- name: grafana-config
40+
mountPath: /etc/grafana/provisioning/datasources
41+
volumes:
42+
- name: grafana-config
43+
configMap:
44+
name: grafana-configmap
45+
46+
---
47+
48+
apiVersion: v1
49+
kind: Service
50+
metadata:
51+
labels:
52+
app: grafana
53+
name: grafana
54+
spec:
55+
ports:
56+
- port: 3000
57+
protocol: TCP
58+
targetPort: 3000
59+
selector:
60+
app: grafana
61+
type: ClusterIP
62+
63+
---
64+
65+
apiVersion: v1
66+
kind: ConfigMap
67+
metadata:
68+
name: grafana-configmap
69+
data:
70+
GF_AUTH_ANONYMOUS_ENABLED: "true"
71+
GF_AUTH_ANONYMOUS_ORG_ROLE: "Admin"
72+
GF_AUTH_DISABLE_LOGIN_FORM: "true"
73+
datasource.yml: |
74+
apiVersion: 1
75+
76+
datasources:
77+
- name: Prometheus
78+
type: prometheus
79+
access: proxy
80+
url: http://prometheus:9090
81+
editable: false
82+
jsonData:
83+
httpMethod: POST
84+
exemplarTraceIdDestinations:
85+
- name: trace_id
86+
datasourceUid: tempo
87+
- name: Tempo
88+
type: tempo
89+
access: proxy
90+
orgId: 1
91+
url: http://tempo:3200
92+
basicAuth: false
93+
isDefault: true
94+
version: 1
95+
editable: false
96+
apiVersion: 1
97+
uid: tempo
98+
jsonData:
99+
httpMethod: GET
100+
tracesToLogs:
101+
datasourceUid: 'loki'
102+
nodeGraph:
103+
enabled: true
104+
- name: Loki
105+
type: loki
106+
uid: loki
107+
access: proxy
108+
orgId: 1
109+
url: http://loki:3100
110+
basicAuth: false
111+
isDefault: false
112+
version: 1
113+
editable: false
114+
apiVersion: 1
115+
jsonData:
116+
derivedFields:
117+
- datasourceUid: tempo
118+
matcherRegex: \[.+,(.+?),
119+
name: TraceID
120+
url: $${__value.raw}
121+
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
labels:
5+
app: prometheus
6+
name: prometheus
7+
spec:
8+
replicas: 1
9+
selector:
10+
matchLabels:
11+
app: prometheus
12+
template:
13+
metadata:
14+
labels:
15+
app: prometheus
16+
spec:
17+
containers:
18+
- image: prom/prometheus:v2.46.0
19+
name: prometheus
20+
ports:
21+
- containerPort: 9090
22+
args:
23+
- --enable-feature=exemplar-storage
24+
- --config.file=/etc/prometheus/prometheus.yml
25+
volumeMounts:
26+
- name: prometheus-config
27+
mountPath: /etc/prometheus
28+
volumes:
29+
- name: prometheus-config
30+
configMap:
31+
name: prometheus-configmap
32+
33+
---
34+
apiVersion: v1
35+
kind: Service
36+
metadata:
37+
labels:
38+
app: prometheus
39+
name: prometheus
40+
spec:
41+
ports:
42+
- port: 9090
43+
protocol: TCP
44+
targetPort: 9090
45+
selector:
46+
app: prometheus
47+
type: ClusterIP
48+
49+
---
50+
apiVersion: v1
51+
kind: ConfigMap
52+
metadata:
53+
name: prometheus-configmap
54+
data:
55+
prometheus.yml: |
56+
global:
57+
scrape_interval: 2s
58+
evaluation_interval: 2s
59+
60+
scrape_configs:
61+
- job_name: 'api-gateway'
62+
metrics_path: '/actuator/prometheus'
63+
static_configs:
64+
- targets: [ 'host.docker.internal:9000' ] ## only for demo purposes don't use host.docker.internal in production
65+
66+
- job_name: 'product-service'
67+
metrics_path: '/actuator/prometheus'
68+
static_configs:
69+
- targets: ['host.docker.internal:8080'] ## only for demo purposes don't use host.docker.internal in production
70+
labels:
71+
application: 'Product Service'
72+
73+
- job_name: 'order-service'
74+
metrics_path: '/actuator/prometheus'
75+
static_configs:
76+
- targets: ['host.docker.internal:8081'] ## only for demo purposes don't use host.docker.internal in production
77+
labels:
78+
application: 'Order Service'
79+
80+
- job_name: 'inventory-service'
81+
metrics_path: '/actuator/prometheus'
82+
static_configs:
83+
- targets: [ 'host.docker.internal:8082' ] ## only for demo purposes don't use host.docker.internal in production
84+
labels:
85+
application: 'Inventory Service'
86+
87+
- job_name: 'notification-service'
88+
metrics_path: '/actuator/prometheus'
89+
static_configs:
90+
- targets: [ 'host.docker.internal:8087' ] ## only for demo purposes don't use host.docker.internal in production
91+
labels:
92+
application: 'Notification Service'
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
labels:
5+
app: tempo
6+
name: tempo
7+
spec:
8+
replicas: 1
9+
selector:
10+
matchLabels:
11+
app: tempo
12+
template:
13+
metadata:
14+
labels:
15+
app: tempo
16+
spec:
17+
containers:
18+
- image: grafana/tempo:2.2.2
19+
args: ["-config.file=/etc/tempo.yaml"]
20+
name: tempo
21+
ports:
22+
- containerPort: 3200
23+
name: tempo
24+
- containerPort: 9411
25+
name: zipkin
26+
volumeMounts:
27+
- name: tempo-config
28+
mountPath: /etc/tempo.yaml
29+
subPath: tempo.yaml
30+
- name: tempo-data
31+
mountPath: /tmp/tempo
32+
volumes:
33+
- name: tempo-config
34+
configMap:
35+
name: tempo-config
36+
- name: tempo-data
37+
persistentVolumeClaim:
38+
claimName: tempo-pvc
39+
40+
---
41+
apiVersion: v1
42+
kind: Service
43+
metadata:
44+
labels:
45+
app: tempo
46+
name: tempo
47+
spec:
48+
ports:
49+
- protocol: TCP
50+
port: 3200
51+
targetPort: 3200
52+
name: tempo
53+
- protocol: TCP
54+
port: 9411
55+
targetPort: 9411
56+
name: zipkin
57+
selector:
58+
app: tempo
59+
type: ClusterIP
60+
61+
---
62+
63+
apiVersion: v1
64+
kind: ConfigMap
65+
metadata:
66+
name: tempo-config
67+
data:
68+
tempo.yaml: |
69+
server:
70+
http_listen_port: 3200
71+
72+
distributor:
73+
receivers:
74+
zipkin:
75+
76+
storage:
77+
trace:
78+
backend: local
79+
local:
80+
path: /tmp/tempo/blocks
81+
---
82+
apiVersion: v1
83+
kind: PersistentVolume
84+
metadata:
85+
name: tempo-pv
86+
spec:
87+
storageClassName: 'standard'
88+
accessModes:
89+
- ReadWriteOnce
90+
capacity:
91+
storage: 1Gi
92+
hostPath:
93+
path: /tmp/tempo
94+
---
95+
apiVersion: v1
96+
kind: PersistentVolumeClaim
97+
metadata:
98+
name: tempo-pvc
99+
spec:
100+
accessModes:
101+
- ReadWriteOnce
102+
resources:
103+
requests:
104+
storage: 1Gi

notification-service/src/main/resources/application.properties

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,9 @@ spring.mail.host=sandbox.smtp.mailtrap.io
3131
spring.mail.port=2525
3232
spring.mail.username=1ee0dd5771d659
3333
spring.mail.password=4f9eb34bacafd3
34-
#spring.mail.protocol=smtp
34+
#spring.mail.protocol=smtp
35+
36+
37+
38+
39+
loki.url=http://localhost:3100/loki/api/v1/push

notification-service/src/main/resources/logback-spring.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
<configuration>
33
<include resource="org/springframework/boot/logging/logback/base.xml"/>
44
<springProperty scope="context" name="appName" source="spring.application.name"/>
5+
<springProperty scope="context" name="lokiUrl" source="loki.url"/>
56

67
<appender name="LOKI" class="com.github.loki4j.logback.Loki4jAppender">
78
<http>
8-
<url>http://localhost:3100/loki/api/v1/push</url>
9+
<url>${lokiUrl}</url>
910
</http>
1011
<format>
1112
<label>

0 commit comments

Comments
 (0)