Skip to content

Commit 7ecdcb2

Browse files
committed
feat: start project
0 parents  commit 7ecdcb2

File tree

92 files changed

+4391
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+4391
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
version: "3.8"
2+
3+
services:
4+
5+
app-db-migration:
6+
build:
7+
context: ../
8+
dockerfile: Dockerfile
9+
entrypoint: [ "/flyway/flyway" ]
10+
command: "-url=jdbc:mysql://database -schemas=sampledb -user=root -password=rpassword -connectRetries=60 migrate -locations=filesystem:/flyway/sql"
11+
networks:
12+
- database-net
13+
14+
app:
15+
build:
16+
context: ../
17+
dockerfile: Dockerfile
18+
environment:
19+
KAFKA_BOOTSTRAP_SERVERS: kafka:29092
20+
DATABASE_URL: jdbc:mysql://database/sampledb
21+
DATABASE_USER: root
22+
DATABASE_PASSWORD: rpassword
23+
OTEL_EXPORTER_OTLP_METRICS_ENDPOINT: http://otel-collector:4318/v1/metrics
24+
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: http://otel-collector:4318/v1/traces
25+
ports:
26+
- "8080:8080"
27+
depends_on:
28+
- app-db-migration
29+
networks:
30+
- database-net
31+
- kafka-net
32+
- observability-net
33+
34+
networks:
35+
database-net:
36+
driver: bridge
37+
kafka-net:
38+
driver: bridge
39+
observability-net:
40+
driver: bridge
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apiVersion: 1
2+
3+
deleteDatasources:
4+
- name: Prometheus
5+
orgId: 1
6+
7+
datasources:
8+
- name: Prometheus
9+
type: prometheus
10+
url: http://prometheus:9090
11+
access: proxy
12+
orgId: 1
13+
isDefault: true
14+
basicAuth: false
15+
version: 1
16+
editable: false
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# Configuration file for OpenTelemetry Collector.
2+
# This file defines receivers, exporters, processors, and service pipelines for telemetry data collection and processing.
3+
4+
receivers:
5+
# Receivers collect telemetry data from applications or other sources.
6+
7+
otlp: # OpenTelemetry Protocol receiver.
8+
protocols:
9+
http:
10+
endpoint: 0.0.0.0:4318 # HTTP endpoint for receiving telemetry data.
11+
grpc:
12+
endpoint: 0.0.0.0:4317 # gRPC endpoint for receiving telemetry data.
13+
14+
prometheus: # Prometheus receiver to scrape metrics from endpoints.
15+
config:
16+
scrape_configs:
17+
- job_name: otelcol-metrics
18+
scrape_interval: 60s # Frequency for scraping metrics.
19+
static_configs:
20+
- targets: ["otel-collector:8888"] # Target endpoint for metrics scraping.
21+
- job_name: spanmetrics
22+
scrape_interval: 60s # Frequency for scraping span metrics.
23+
static_configs:
24+
- targets: ["otel-collector:9999"] # Target endpoint for span metrics scraping.
25+
metric_relabel_configs:
26+
- source_labels: [span_kind]
27+
regex: SPAN_KIND_SERVER
28+
action: keep # Keep only server spans.
29+
- source_labels: [http_user_agent, request_header_user_agent, http_request_header_user_agent]
30+
regex: kube-probe/.*|Prometheus/.*|Gravitee.io/.*|ELB-HealthChecker/.*
31+
action: drop # Drop metrics generated by probes or health checkers.
32+
- regex: http_user_agent|request_header_user_agent|http_request_header_user_agent
33+
action: labeldrop # Remove specified labels.
34+
35+
otlp/spanmetrics: # Separate receiver for span metrics.
36+
protocols:
37+
grpc:
38+
endpoint: 0.0.0.0:12345 # gRPC endpoint for receiving span metrics.
39+
40+
exporters:
41+
# Exporters send processed telemetry data to external systems.
42+
43+
prometheusremotewrite:
44+
endpoint: "http://prometheus:9090/api/v1/write" # Export metrics to Prometheus.
45+
46+
logging:
47+
logLevel: debug # Log telemetry data for debugging.
48+
49+
otlp/jaeger:
50+
endpoint: "jaeger:4317" # Export traces to Jaeger.
51+
tls:
52+
insecure: true # Disable TLS verification (for testing or internal use).
53+
54+
prometheus/spanmetrics:
55+
endpoint: 0.0.0.0:9999 # Endpoint for exposing span metrics to Prometheus.
56+
metric_expiration: 75s # Time to keep metrics before expiring them.
57+
58+
processors:
59+
# Processors transform telemetry data before exporting.
60+
61+
batch: # Batch processor to group data for efficient processing.
62+
63+
tail_sampling: # Sampling processor for traces.
64+
decision_wait: 45s # Wait time for sampling decision.
65+
num_traces: 50000 # Maximum number of traces to sample.
66+
policies:
67+
- name: ignore-http-user-agent
68+
type: string_attribute
69+
string_attribute:
70+
key: http.user_agent
71+
values: [kube-probe/*, Prometheus/*, Gravitee.io/*, ELB-HealthChecker/*]
72+
enabled_regex_matching: true
73+
invert_match: true # Include traces not matching these values.
74+
- name: sampling-50%
75+
type: probabilistic
76+
probabilistic:
77+
sampling_percentage: 50 # Sample 50% of traces.
78+
79+
spanmetrics: # Processor for creating span metrics.
80+
dimensions:
81+
- name: http.method
82+
- name: http.status_code
83+
- name: http.user_agent
84+
- name: request.header.user-agent
85+
- name: http.request.header-user-agent
86+
latency_histogram_buckets: [2ms, 10ms, 100ms, 1s, 10s] # Define latency buckets.
87+
metrics_exporter: prometheus/spanmetrics # Export processed metrics.
88+
89+
service:
90+
# Service defines the pipeline for processing telemetry data.
91+
92+
telemetry:
93+
metrics:
94+
address: 0.0.0.0:8888 # Address to expose collector's own metrics.
95+
96+
pipelines:
97+
metrics/spanmetrics: # Pipeline for span metrics.
98+
receivers: [otlp/spanmetrics]
99+
exporters: [prometheus/spanmetrics]
100+
101+
traces: # Pipeline for trace data.
102+
receivers: [otlp]
103+
processors: [spanmetrics, tail_sampling, batch]
104+
exporters: [logging, otlp/jaeger]
105+
106+
metrics: # Pipeline for general metrics.
107+
receivers: [otlp, prometheus]
108+
processors: [batch]
109+
exporters: [logging, prometheusremotewrite]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
scrape_configs: [ ]
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
version: "3.8"
2+
3+
services:
4+
5+
database:
6+
image: mysql:8.0.28
7+
ports:
8+
- "3306:3306"
9+
environment:
10+
MYSQL_ROOT_PASSWORD: rpassword
11+
MYSQL_DATABASE: sampledb
12+
MYSQL_USER: user
13+
MYSQL_PASSWORD: password
14+
networks:
15+
- database-net
16+
17+
flyway:
18+
image: flyway/flyway:7.5.2
19+
command: -url=jdbc:mysql://database -schemas=sampledb -user=root -password=rpassword -connectRetries=60 migrate
20+
volumes:
21+
- ../resources/flyway/db/migration:/flyway/sql
22+
depends_on:
23+
- database
24+
networks:
25+
- database-net
26+
27+
zookeeper:
28+
image: confluentinc/cp-zookeeper:7.5.0
29+
container_name: zookeeper
30+
ports:
31+
- "2181:2181"
32+
environment:
33+
ZOOKEEPER_CLIENT_PORT: 2181
34+
ZOOKEEPER_TICK_TIME: 2000
35+
networks:
36+
- kafka-net
37+
38+
kafka:
39+
image: confluentinc/cp-kafka:7.5.0
40+
container_name: kafka
41+
ports:
42+
- "9092:9092"
43+
environment:
44+
KAFKA_BROKER_ID: 1
45+
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
46+
KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092,INTERNAL://kafka:29092
47+
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://localhost:9092,INTERNAL://kafka:29092
48+
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,INTERNAL:PLAINTEXT
49+
KAFKA_INTER_BROKER_LISTENER_NAME: INTERNAL
50+
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
51+
depends_on:
52+
- zookeeper
53+
networks:
54+
- kafka-net
55+
56+
networks:
57+
database-net:
58+
driver: bridge
59+
kafka-net:
60+
driver: bridge
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
version: "3.8"
2+
3+
services:
4+
5+
jaeger:
6+
image: jaegertracing/all-in-one:1.40.0
7+
ports:
8+
- "16686:16686"
9+
environment:
10+
- COLLECTOR_OTLP_ENABLED=true
11+
- METRICS_STORAGE_TYPE=prometheus
12+
- PROMETHEUS_SERVER_URL=http://prometheus:9090
13+
networks:
14+
- observability-net
15+
16+
otel-collector:
17+
image: otel/opentelemetry-collector-contrib:0.68.0
18+
command: ["--config=/etc/otel-collector-config.yaml"]
19+
volumes:
20+
- ./config/otel-collector.yaml:/etc/otel-collector-config.yaml
21+
ports:
22+
- "4317:4317"
23+
- "4318:4318"
24+
- "8888:8888"
25+
- "9999:9999"
26+
depends_on:
27+
- jaeger
28+
- prometheus
29+
networks:
30+
- observability-net
31+
32+
prometheus:
33+
image: prom/prometheus:v2.41.0
34+
command:
35+
- --web.console.templates=/etc/prometheus/consoles
36+
- --web.console.libraries=/etc/prometheus/console_libraries
37+
- --storage.tsdb.retention.time=1h
38+
- --storage.tsdb.path=/prometheus
39+
- --web.enable-lifecycle
40+
- --web.route-prefix=/
41+
- --config.file=/etc/prometheus/prometheus.yml
42+
- --web.enable-remote-write-receiver
43+
volumes:
44+
- ./config/prometheus.yaml:/etc/prometheus/prometheus.yml
45+
ports:
46+
- "9090:9090"
47+
networks:
48+
- observability-net
49+
50+
grafana:
51+
image: grafana/grafana:9.3.2
52+
ports:
53+
- "3000:3000"
54+
volumes:
55+
- ./config/ds-prometheus.yaml:/etc/grafana/provisioning/datasources/datasource.yml
56+
environment:
57+
- GF_AUTH_ANONYMOUS_ORG_ROLE=Admin
58+
- GF_AUTH_ANONYMOUS_ENABLED=true
59+
- GF_AUTH_BASIC_ENABLED=false
60+
depends_on:
61+
- prometheus
62+
networks:
63+
- observability-net
64+
65+
networks:
66+
observability-net:
67+
driver: bridge

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/mvnw text eol=lf
2+
*.cmd text eol=crlf

.gitignore

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
HELP.md
2+
target/
3+
!.mvn/wrapper/maven-wrapper.jar
4+
!**/src/main/**/target/
5+
!**/src/test/**/target/
6+
7+
### STS ###
8+
.apt_generated
9+
.classpath
10+
.factorypath
11+
.project
12+
.settings
13+
.springBeans
14+
.sts4-cache
15+
16+
### IntelliJ IDEA ###
17+
.idea
18+
*.iws
19+
*.iml
20+
*.ipr
21+
22+
### NetBeans ###
23+
/nbproject/private/
24+
/nbbuild/
25+
/dist/
26+
/nbdist/
27+
/.nb-gradle/
28+
build/
29+
!**/src/main/**/build/
30+
!**/src/test/**/build/
31+
32+
### VS Code ###
33+
.vscode/

.images/acceptance-tests.webp

304 KB
Binary file not shown.

.images/banner.webp

74.2 KB
Binary file not shown.

0 commit comments

Comments
 (0)