Skip to content

Commit 3c484f2

Browse files
authored
Download topology from telemetry in bootstrap (#87)
1 parent 433afde commit 3c484f2

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

beyla/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ RUN apt-get update && \
2121
curl \
2222
procps \
2323
ruby \
24-
ruby-json && \
24+
ruby-json \
25+
jq && \
2526
apt-get clean && \
2627
rm -rf /var/lib/apt/lists/*
2728

collector/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ RUN mkdir -p /versions/0-default \
3434
# Set environment variables
3535
ENV BASE_URL=https://telemetry.betterstack.com
3636
ENV CLUSTER_COLLECTOR=false
37-
ENV COLLECTOR_VERSION=1.1.6
37+
ENV COLLECTOR_VERSION=1.1.7
3838
ENV VECTOR_VERSION=0.47.0
3939
ENV BEYLA_VERSION=2.7.5
4040
ENV CLUSTER_AGENT_VERSION=1.2.4

collector/bootstrap.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,35 @@ for i in $(seq 0 $((FILES_COUNT - 1))); do
221221
log_info " Saved to: $DEST_FILE"
222222
done
223223

224+
# Step 4: Download topology configuration (optional, with retries)
225+
log_info "Downloading topology configuration..."
226+
TOPOLOGY_URL="$BASE_URL/api/collector/configuration-file?collector_secret=$(printf %s "$COLLECTOR_SECRET" | jq -sRr @uri)&configuration_version=latest&file=topology.json"
227+
TOPOLOGY_FILE="$MANIFEST_DIR/topology.json"
228+
TOPOLOGY_MAX_ATTEMPTS=3
229+
TOPOLOGY_ATTEMPT=1
230+
TOPOLOGY_SUCCESS=false
231+
232+
while [ "$TOPOLOGY_ATTEMPT" -le "$TOPOLOGY_MAX_ATTEMPTS" ]; do
233+
TEMP_TOPOLOGY=$(mktemp)
234+
if make_api_request "$TOPOLOGY_URL" "$TEMP_TOPOLOGY"; then
235+
mv "$TEMP_TOPOLOGY" "$TOPOLOGY_FILE"
236+
log_info "Topology configuration saved to: $TOPOLOGY_FILE"
237+
TOPOLOGY_SUCCESS=true
238+
break
239+
else
240+
rm -f "$TEMP_TOPOLOGY"
241+
if [ "$TOPOLOGY_ATTEMPT" -lt "$TOPOLOGY_MAX_ATTEMPTS" ]; then
242+
log_warn "Failed to download topology configuration (attempt $TOPOLOGY_ATTEMPT/$TOPOLOGY_MAX_ATTEMPTS, retrying...)"
243+
sleep 2
244+
fi
245+
TOPOLOGY_ATTEMPT=$((TOPOLOGY_ATTEMPT + 1))
246+
fi
247+
done
248+
249+
if [ "$TOPOLOGY_SUCCESS" = false ]; then
250+
log_warn "Failed to download topology configuration after $TOPOLOGY_MAX_ATTEMPTS attempts (continuing anyway)"
251+
fi
252+
224253
log_info "Bootstrap completed successfully!"
225254
log_info "Manifest version: $MANIFEST_VERSION"
226255
log_info "Files downloaded: $FILES_COUNT"

0 commit comments

Comments
 (0)