forked from BaseAdresseNationale/addok-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy-otlp-metrics.sh
More file actions
executable file
Β·146 lines (124 loc) Β· 6.81 KB
/
deploy-otlp-metrics.sh
File metadata and controls
executable file
Β·146 lines (124 loc) Β· 6.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/bin/bash
# Deploy OTLP Metrics Pipeline - Complete Implementation
# This script implements the unified OTLP pipeline (traces + metrics) through Alloy
set -euo pipefail
# Configuration
ADDOK_NAMESPACE="addok-ban"
MONITORING_NAMESPACE="monitoring"
ALLOY_RELEASE="alloy"
NEW_IMAGE="registry.gitlab.com/atafaya971/packsol/addok-ban:2.1.5-otel"
echo "π Deploying OTLP Metrics Pipeline Implementation..."
echo ""
echo "π Implementation Overview:"
echo " β Unified OTLP pipeline: Addok β Alloy β (Tempo + Prometheus)"
echo " β Traces: OTLP β Alloy β Tempo β Grafana"
echo " β Metrics: OTLP β Alloy β Prometheus β Grafana"
echo " β Dual metrics collection: Direct scraping + OTLP forwarding"
echo ""
# Step 1: Update Alloy configuration with OTLP metrics support
echo "π§ Step 1: Updating Alloy configuration..."
if helm upgrade ${ALLOY_RELEASE} grafana/alloy \
--version 1.0.3 \
--values /Users/npasquin/gitRepo/talos-homelab/components/monitoring/alloy-values.yaml \
-n ${MONITORING_NAMESPACE} \
--wait; then
echo "β
Alloy configuration updated successfully"
else
echo "β Failed to update Alloy configuration"
exit 1
fi
# Step 2: Wait for Alloy rollout
echo "β³ Waiting for Alloy rollout to complete..."
kubectl rollout status deployment/alloy -n ${MONITORING_NAMESPACE} --timeout=300s
# Step 3: Verify Alloy metrics port is exposed
echo "π Verifying Alloy service configuration..."
kubectl get svc alloy -n ${MONITORING_NAMESPACE} -o jsonpath='{.spec.ports[*].name}' || {
echo "β οΈ Alloy service ports: $(kubectl get svc alloy -n ${MONITORING_NAMESPACE} -o yaml | grep -A10 ports:)"
}
# Step 4: Deploy updated Addok with OTLP metrics
echo "π Step 4: Deploying Addok 2.1.5-otel with OTLP metrics..."
kubectl set image deployment/addok-ban addok-ban=${NEW_IMAGE} -n ${ADDOK_NAMESPACE}
# Step 5: Update environment variables for OTLP metrics
echo "π§ Step 5: Configuring OTLP metrics environment..."
kubectl set env deployment/addok-ban \
OTEL_EXPORTER_OTLP_ENDPOINT="http://alloy.monitoring:4317" \
OTEL_METRICS_CONSOLE_DEBUG="true" \
-n ${ADDOK_NAMESPACE}
# Step 6: Wait for Addok rollout
echo "β³ Waiting for Addok rollout to complete..."
kubectl rollout status deployment/addok-ban -n ${ADDOK_NAMESPACE} --timeout=300s
# Step 7: Apply updated monitoring configuration
echo "π Step 7: Applying updated monitoring observability..."
kubectl apply -f /Users/npasquin/gitRepo/talos-homelab/applications/addok-ban-app/base/70-monitoring-observability.yaml
# Step 8: Verification checks
echo ""
echo "π Verification Phase..."
echo "βββββββββββββββββββββββββββββββββββββββββββββββββββ"
# Check Alloy logs for OTLP metrics
echo "π Checking Alloy OTLP configuration..."
kubectl logs -l app.kubernetes.io/name=alloy -n ${MONITORING_NAMESPACE} --tail=50 | grep -i "otlp\|metrics\|prometheus" || true
# Check Addok telemetry initialization
echo "π Checking Addok OTLP metrics initialization..."
kubectl logs -l app=addok-ban -n ${ADDOK_NAMESPACE} --tail=20 | grep -i "β OTLP metrics initialized\|metrics" || true
# Verify ServiceMonitors
echo "π Verifying ServiceMonitors..."
echo "Direct metrics: $(kubectl get servicemonitor addok-ban-metrics -n ${ADDOK_NAMESPACE} -o jsonpath='{.metadata.name}' 2>/dev/null || echo 'Not found')"
echo "Alloy OTLP metrics: $(kubectl get servicemonitor alloy-otlp-metrics -n ${MONITORING_NAMESPACE} -o jsonpath='{.metadata.name}' 2>/dev/null || echo 'Not found')"
# Test endpoints
echo ""
echo "π Testing Endpoints..."
echo "βββββββββββββββββββββββββββββββββββββββββββββββββββ"
# Port-forward and test Alloy metrics endpoint
echo "Testing Alloy Prometheus metrics endpoint..."
kubectl port-forward -n ${MONITORING_NAMESPACE} svc/alloy 8889:8889 &
PF_PID=$!
sleep 5
if curl -s http://localhost:8889/metrics | grep -q "addok_"; then
echo "β
Alloy OTLP metrics endpoint working"
else
echo "β οΈ Alloy OTLP metrics endpoint may not be ready yet"
fi
kill $PF_PID 2>/dev/null || true
# Test a few requests to generate metrics
echo "π Generating test traffic..."
kubectl port-forward -n ${ADDOK_NAMESPACE} svc/addok-ban 8080:80 &
PF_PID2=$!
sleep 3
for i in {1..5}; do
curl -s "http://localhost:8080/search?q=paris" > /dev/null || true
sleep 1
done
kill $PF_PID2 2>/dev/null || true
echo ""
echo "π OTLP Metrics Pipeline Deployment Complete!"
echo ""
echo "π Monitoring Stack Architecture:"
echo " βββββββββββββββ OTLP βββββββββββββ Traces βββββββββββββ"
echo " β Addok β βββββββββββΊ β Alloy β ββββββββββββββΊ β Tempo β"
echo " β 2.1.5 β β β β β"
echo " β β β β Prometheus β β"
echo " β β β β β β β β βΊ β β ββββββββββββββΊ βPrometheus β"
echo " βββββββββββββββ Direct βββββββββββββ β β"
echo " Scraping β βββββββββββββ"
echo " β Metrics β"
echo " βΌ β"
echo " βββββββββββββββ ββββββββββββββββββββββββ"
echo " β Grafana β Queries"
echo " βββββββββββββββ"
echo ""
echo "π Access Points:"
echo " π Grafana: http://grafana/dashboard"
echo " π Tempo: http://grafana/explore (Tempo datasource)"
echo " π Prometheus: http://prometheus/targets (check scraping status)"
echo ""
echo "π Next Steps:"
echo " 1. Check Prometheus targets: kubectl port-forward svc/prometheus-kube-prometheus-prometheus 9090:9090 -n monitoring"
echo " 2. Verify metrics in Grafana: Look for 'addok_*' metrics from both direct and OTLP sources"
echo " 3. Test distributed tracing: Make requests and check traces in Tempo"
echo " 4. Monitor both metric pipelines: Direct scraping + OTLP forwarding"
echo ""
echo "π Troubleshooting:"
echo " β’ Alloy logs: kubectl logs -l app.kubernetes.io/name=alloy -n monitoring -f"
echo " β’ Addok logs: kubectl logs -l app=addok-ban -n addok-ban -f"
echo " β’ ServiceMonitors: kubectl get servicemonitor -A"
echo " β’ Prometheus config: kubectl get prometheus -o yaml -n monitoring"