diff --git a/.changeset/famous-apples-shake.md b/.changeset/famous-apples-shake.md new file mode 100644 index 00000000..48f09f26 --- /dev/null +++ b/.changeset/famous-apples-shake.md @@ -0,0 +1,7 @@ +--- +"@hyperdx/api": patch +"@hyperdx/app": patch +"@hyperdx/common-utils": patch +--- + +fix: otelcol process in aio build diff --git a/docker/hyperdx/Dockerfile b/docker/hyperdx/Dockerfile index 9dbfac78..01d90c99 100644 --- a/docker/hyperdx/Dockerfile +++ b/docker/hyperdx/Dockerfile @@ -76,9 +76,12 @@ COPY --chown=node:node --from=hyperdx ./entry.prod.sh /etc/local/entry.sh ENTRYPOINT ["sh", "/etc/local/entry.sh"] # all-in-one base ############################################################################################ +FROM hairyhenderson/gomplate:v4.3.3-alpine AS gomplate FROM clickhouse/clickhouse-server:${CLICKHOUSE_VERSION}-alpine AS all-in-one-base ARG CODE_VERSION +ARG USER_UID=10001 +ARG USER_GID=10001 ENV CODE_VERSION=$CODE_VERSION # Copy from otel collector bases @@ -100,15 +103,24 @@ COPY --from=hyperdx ./clickhouseConfig.xml /etc/clickhouse-server/config.xml # Set up Otel Collector COPY --from=otel-collector ./config.yaml /etc/otelcol-contrib/config.yaml -COPY --from=otel-collector ./supervisor_docker.yaml /etc/otel/supervisor.yaml +COPY --from=otel-collector ./supervisor_docker.yaml.tmpl /etc/otel/supervisor.yaml.tmpl + +# Copy otel-collector entrypoint and log rotation scripts +COPY --from=otel-collector --chmod=755 ./entrypoint.sh /otel-entrypoint.sh +COPY --from=otel-collector --chmod=755 ./log-rotator.sh /log-rotator.sh + +# Copy gomplate binary from the gomplate image +COPY --from=gomplate /bin/gomplate /usr/local/bin/gomplate # Install MongoDB and other dependencies (consolidated into a single RUN command) RUN echo 'http://dl-cdn.alpinelinux.org/alpine/v3.9/main' >> /etc/apk/repositories && \ echo 'http://dl-cdn.alpinelinux.org/alpine/v3.9/community' >> /etc/apk/repositories && \ apk update && \ apk add --no-cache mongodb yaml-cpp=0.6.2-r2 curl ca-certificates && \ + addgroup -S -g ${USER_GID} otel && \ + adduser -S -u ${USER_UID} -G otel otel && \ mkdir -p /data/db && \ - mkdir -p /etc/otel/supervisor-data && \ + install -d -m 0777 -o ${USER_UID} -g ${USER_GID} /etc/otel/supervisor-data && \ rm -rf /var/cache/apk/* ENV NODE_ENV production diff --git a/docker/hyperdx/clickhouseConfig.xml b/docker/hyperdx/clickhouseConfig.xml index 308d40d5..50cab2ce 100644 --- a/docker/hyperdx/clickhouseConfig.xml +++ b/docker/hyperdx/clickhouseConfig.xml @@ -37,6 +37,16 @@ UTC false + + + + + + + + + + system diff --git a/docker/hyperdx/entry.local.base.sh b/docker/hyperdx/entry.local.base.sh index dcfc81f6..f2682f87 100644 --- a/docker/hyperdx/entry.local.base.sh +++ b/docker/hyperdx/entry.local.base.sh @@ -16,6 +16,7 @@ export HYPERDX_OTEL_EXPORTER_CLICKHOUSE_DATABASE="${HYPERDX_OTEL_EXPORTER_CLICKH export CLICKHOUSE_ENDPOINT="${CLICKHOUSE_ENDPOINT:-tcp://ch-server:9000?dial_timeout=10s}" export MONGO_URI="mongodb://db:27017/hyperdx" export OPAMP_SERVER_URL="http://127.0.0.1:${OPAMP_PORT}" +export CLICKHOUSE_PROMETHEUS_METRICS_ENDPOINT="${CLICKHOUSE_PROMETHEUS_METRICS_ENDPOINT:-ch-server:9363}" export EXPRESS_SESSION_SECRET="hyperdx is cool 👋" # IS_LOCAL_APP_MODE should be set by the calling script @@ -58,8 +59,8 @@ while ! curl -s "http://ch-server:8123" > /dev/null; do done echo "ClickHouse is ready!" -# Start Otel Collector -opampsupervisor --config /etc/otel/supervisor.yaml > /var/log/otel-collector.log 2>&1 & +# Start Otel Collector with entrypoint script for template rendering and log rotation +/otel-entrypoint.sh /usr/local/bin/opampsupervisor > /var/log/otel-collector.log 2>&1 & # Start HyperDX app npx concurrently \ diff --git a/docker/otel-collector/Dockerfile b/docker/otel-collector/Dockerfile index 1dd44190..bc5866bd 100644 --- a/docker/otel-collector/Dockerfile +++ b/docker/otel-collector/Dockerfile @@ -1,6 +1,7 @@ ## base ############################################################################################# FROM otel/opentelemetry-collector-contrib:0.129.1 AS col FROM otel/opentelemetry-collector-opampsupervisor:0.128.0 AS supervisor +FROM hairyhenderson/gomplate:v4.3.3-alpine AS gomplate # From: https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/aa5c3aa4c7ec174361fcaf908de8eaca72263078/cmd/opampsupervisor/Dockerfile#L18 FROM alpine:latest@sha256:a8560b36e8b8210634f77d9f7f9efd7ffa463e380b75e2e74aff4511df3ef88c AS base @@ -8,14 +9,15 @@ FROM alpine:latest@sha256:a8560b36e8b8210634f77d9f7f9efd7ffa463e380b75e2e74aff45 ARG USER_UID=10001 ARG USER_GID=10001 -# Install certs, gomplate for templating, create user/group, and make the writable data dir +# Install certs, create user/group, and make the writable data dir RUN apk add --no-cache ca-certificates && \ - wget -O /usr/local/bin/gomplate https://github.com/hairyhenderson/gomplate/releases/download/v4.3.3/gomplate_linux-amd64 && \ - chmod +x /usr/local/bin/gomplate && \ addgroup -S -g ${USER_GID} otel && \ adduser -S -u ${USER_UID} -G otel otel && \ install -d -m 0777 -o ${USER_UID} -g ${USER_GID} /etc/otel/supervisor-data +# Copy gomplate binary from the gomplate image +COPY --from=gomplate /bin/gomplate /usr/local/bin/gomplate + USER ${USER_UID}:${USER_GID} COPY --from=supervisor --chmod=755 /usr/local/bin/opampsupervisor /opampsupervisor diff --git a/packages/api/src/controllers/team.ts b/packages/api/src/controllers/team.ts index 89f45a3c..bd94c6f4 100644 --- a/packages/api/src/controllers/team.ts +++ b/packages/api/src/controllers/team.ts @@ -1,3 +1,4 @@ +import mongoose from 'mongoose'; import { v4 as uuidv4 } from 'uuid'; import * as config from '@/config'; @@ -8,7 +9,7 @@ import Team, { TeamCHSettings } from '@/models/team'; const LOCAL_APP_TEAM_ID = '_local_team_'; export const LOCAL_APP_TEAM = { - _id: LOCAL_APP_TEAM_ID, + _id: new mongoose.Types.ObjectId(LOCAL_APP_TEAM_ID), id: LOCAL_APP_TEAM_ID, name: 'Local App Team', // Placeholder keys @@ -48,6 +49,10 @@ export async function createTeam({ } export function getAllTeams(fields?: string[]) { + if (config.IS_LOCAL_APP_MODE) { + return [LOCAL_APP_TEAM]; + } + return Team.find({}, fields); }