File tree Expand file tree Collapse file tree 6 files changed +43
-2
lines changed
Expand file tree Collapse file tree 6 files changed +43
-2
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @hyperdx/api " : patch
3+ ---
4+
5+ Add new logging pararmeter for otel collector
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ services:
3333 OPAMP_SERVER_URL : ' http://host.docker.internal:${HYPERDX_OPAMP_PORT}'
3434 CUSTOM_OTELCOL_CONFIG_FILE : ' /etc/otelcol-contrib/custom.config.yaml'
3535 # Uncomment to enable stdout logging for the OTel collector
36- OTEL_SUPERVISOR_PASSTHROUGH_LOGS : ' false '
36+ # OTEL_SUPERVISOR_LOGS : 'true '
3737 # Uncomment to enable JSON schema in ClickHouse
3838 # Be sure to also set BETA_CH_OTEL_JSON_SCHEMA_ENABLED to 'true' in ch-server
3939 # OTEL_AGENT_FEATURE_GATE_ARG: '--feature-gates=clickhouse.json'
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ COPY --from=col --chmod=755 /otelcol-contrib /otelcontribcol
2626# Copy entrypoint and log rotation scripts
2727COPY --chmod=755 ./entrypoint.sh /entrypoint.sh
2828COPY --chmod=755 ./log-rotator.sh /log-rotator.sh
29+ COPY --chmod=755 ./log-tailer.sh /log-tailer.sh
2930
3031# # dev ##############################################################################################
3132FROM base AS dev
Original file line number Diff line number Diff line change 55# Arguments: log_file_path [max_size_mb] [max_archives] [check_interval_seconds]
66/log-rotator.sh /etc/otel/supervisor-data/agent.log 16 1 60 &
77
8+ # Start log tailer script in background for agent.log
9+ # Arguments: log_file_path [check_interval_seconds]
10+ if [ " $OTEL_SUPERVISOR_LOGS " = " true" ]; then
11+ /log-tailer.sh /etc/otel/supervisor-data/agent.log 1 &
12+ fi
13+
814# Render the supervisor config template using gomplate
915# Write to supervisor-data directory which has proper permissions for otel user
1016gomplate -f /etc/otel/supervisor.yaml.tmpl -o /etc/otel/supervisor-data/supervisor-runtime.yaml
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+ # Generic log tailer script that follows a log file and echoes new lines to stdout
3+ # Handles file rotation and truncation (e.g., when used with log-rotator.sh)
4+ # Usage: log-tailer.sh <log_file_path> [sleep_interval]
5+
6+ # Parse arguments
7+ LOG_FILE=" ${1} "
8+ SLEEP_INTERVAL=" ${2:- 1} "
9+
10+ # Validate required argument
11+ if [ -z " $LOG_FILE " ]; then
12+ echo " Error: Log file path is required" >&2
13+ echo " Usage: $0 <log_file_path> [sleep_interval]" >&2
14+ exit 1
15+ fi
16+
17+ # Wait for file to exist if it doesn't yet
18+ while [ ! -f " $LOG_FILE " ]; do
19+ echo " Waiting for log file to be created: $LOG_FILE " >&2
20+ sleep " $SLEEP_INTERVAL "
21+ done
22+
23+ echo " Starting to tail: $LOG_FILE " >&2
24+
25+ # Use tail -F to follow the file by name, not by descriptor
26+ # This handles rotation and truncation gracefully
27+ # -n 0: Start from the end (don't output existing content)
28+ # -F: Follow by name and retry if file is inaccessible
29+ # -s: Sleep interval between checks
30+ tail -n 0 -F -s " $SLEEP_INTERVAL " " $LOG_FILE "
Original file line number Diff line number Diff line change 2727{{- if getenv " OTEL_AGENT_FEATURE_GATE_ARG" }}
2828 - {{ getenv " OTEL_AGENT_FEATURE_GATE_ARG" }}
2929{{- end }}
30- passthrough_logs: {{ getenv " OTEL_SUPERVISOR_PASSTHROUGH_LOGS" | default " false" }}
3130
3231storage:
3332 directory: /etc/otel/supervisor-data/
You can’t perform that action at this time.
0 commit comments