Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions alloy/config.alloy
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
prometheus.scrape "spring" {
targets = [
{
__address__ = "recycle-study-server:8080",
app = "recycle-study-server",
},
]

metrics_path = "/actuator/prometheus"
scrape_interval = "15s"
scrape_timeout = "10s"

forward_to = [prometheus.remote_write.to_prom.receiver]
}

prometheus.remote_write "to_prom" {
endpoint {
url = sys.env("PROMETHEUS_HOST") + "/api/v1/write"
}
}

prometheus.scrape "node" {
targets = [
{
__address__ = "node-exporter:9100",
app = "recycle-study-server",
},
]

scrape_interval = "15s"
scrape_timeout = "10s"

forward_to = [prometheus.remote_write.to_prom.receiver]
}

local.file_match "local_files" {
path_targets = [
{
__path__ = "/var/log/app/*.json",
env = "dev",
app = "recycle-study-server",
},
]
sync_period = "5s"
}

loki.source.file "log_scrape" {
targets = local.file_match.local_files.targets
forward_to = [loki.process.filter_logs.receiver]
tail_from_end = true
}

loki.process "filter_logs" {
stage.drop {
source = ""
expression = ".*Connection closed by authenticating user root"
drop_counter_reason = "noisy"
}
forward_to = [loki.write.grafana_loki.receiver]
}

loki.write "grafana_loki" {
endpoint {
url = sys.env("LOKI_HOST") + "/loki/api/v1/push"
}
}

otelcol.receiver.otlp "default" {
grpc { endpoint = "0.0.0.0:4317" }

output {
traces = [otelcol.processor.memory_limiter.default.input]
}
}

otelcol.processor.memory_limiter "default" {
check_interval = "1s"
limit_percentage = 90
spike_limit_percentage = 95

output {
traces = [otelcol.exporter.otlphttp.default.input]
}
}

otelcol.exporter.otlphttp "default" {
client {
endpoint = sys.env("TEMPO_HOST") + "/v1/traces"
}
}
31 changes: 31 additions & 0 deletions alloy/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
services:
alloy:
image: grafana/alloy:latest
container_name: alloy
restart: unless-stopped
env_file:
- ../.env
volumes:
- ./config.alloy:/etc/alloy/config.alloy
- /app/logs:/var/log/app
command:
- "run"
- "--server.http.listen-addr=0.0.0.0:12345"
- "--storage.path=/var/lib/alloy"
- "--stability.level=experimental"
- "/etc/alloy/config.alloy"
ports:
- "12345:12345" # Alloy UI
- "4317:4317" # OTLP gRPC
networks:
- observability

node-exporter:
image: quay.io/prometheus/node-exporter:latest
container_name: node-exporter
restart: unless-stopped
networks:
- observability

networks:
observability:
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ dependencies {
// monitoring
implementation 'org.springframework.boot:spring-boot-starter-actuator'
runtimeOnly 'io.micrometer:micrometer-registry-prometheus'
implementation 'io.micrometer:micrometer-tracing-bridge-otel'
implementation 'io.opentelemetry:opentelemetry-exporter-otlp'

testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'io.rest-assured:rest-assured'
Expand Down
9 changes: 9 additions & 0 deletions src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,14 @@ management:
exposure:
include: prometheus, health

tracing:
sampling:
probability: 1.0

otlp:
tracing:
endpoint: ${ALLOY_URL}
transport: grpc

auth:
base-url: ${BASE_URL}