Skip to content

Commit

Permalink
feat(monitoring): enable JMX and OTEL for frontend pods (#5834)
Browse files Browse the repository at this point in the history
  • Loading branch information
szalai1 authored Sep 6, 2022
1 parent f4eea5d commit aa146db
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 17 deletions.
34 changes: 22 additions & 12 deletions docker/datahub-frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,23 @@ RUN apk --no-cache --update-cache --available upgrade \
ARG USE_SYSTEM_NODE="true"
ENV CI=true
ENV GRADLE_OPTS="-Xms256m -Xmx512m"
COPY . datahub-src

# copy only what's realy needed for the build
# to get the benefits of caching as much as possible
COPY ./datahub-frontend ./datahub-src/datahub-frontend
COPY ./entity-registry ./datahub-src/entity-registry
COPY ./buildSrc ./datahub-src/buildSrc
COPY ./datahub-web-react ./datahub-src/datahub-web-react
COPY ./li-utils ./datahub-src/li-utils
COPY ./metadata-models ./datahub-src/metadata-models
COPY ./metadata-models-validator ./datahub-src/metadata-models-validator
COPY ./metadata-utils ./datahub-src/metadata-utils
COPY ./metadata-service ./datahub-src/metadata-service
COPY ./metadata-io ./datahub-src/metadata-io
COPY ./datahub-graphql-core ./datahub-src/datahub-graphql-core
COPY ./gradle ./datahub-src/gradle
COPY repositories.gradle gradle.properties gradlew settings.gradle build.gradle ./datahub-src/

RUN cd datahub-src \
&& ./gradlew :datahub-web-react:build -x test -x yarnTest -x yarnLint \
&& ./gradlew :datahub-frontend:dist -PuseSystemNode=${USE_SYSTEM_NODE} -x test -x yarnTest -x yarnLint \
Expand All @@ -27,6 +43,9 @@ RUN cd datahub-src \

FROM base as prod-install
COPY --from=prod-build /datahub-frontend /datahub-frontend/
COPY ./docker/monitoring/client-prometheus-config.yaml /datahub-frontend/
RUN wget https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v1.4.1/opentelemetry-javaagent-all.jar -O opentelemetry-javaagent-all.jar \
&& wget https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_javaagent/0.16.1/jmx_prometheus_javaagent-0.16.1.jar -O jmx_prometheus_javaagent.jar
RUN chown -R datahub:datahub /datahub-frontend && chmod 755 /datahub-frontend

FROM base as dev-install
Expand All @@ -43,14 +62,5 @@ RUN echo $SERVER_PORT
EXPOSE $SERVER_PORT

HEALTHCHECK --start-period=2m --retries=4 CMD curl --fail http://localhost:$SERVER_PORT/admin || exit 1

ENV JAVA_OPTS=" \
-Xms512m \
-Xmx1024m \
-Dhttp.port=$SERVER_PORT \
-Dconfig.file=datahub-frontend/conf/application.conf \
-Djava.security.auth.login.config=datahub-frontend/conf/jaas.conf \
-Dlogback.configurationFile=datahub-frontend/conf/logback.xml \
-Dlogback.debug=false \
-Dpidfile.path=/dev/null"
CMD ["datahub-frontend/bin/datahub-frontend"]
COPY ./docker/datahub-frontend/start.sh /
CMD ./start.sh
27 changes: 27 additions & 0 deletions docker/datahub-frontend/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh
set -u

PROMETHEUS_AGENT=""
if [[ ${ENABLE_PROMETHEUS:-false} == true ]]; then
PROMETHEUS_AGENT="-javaagent:jmx_prometheus_javaagent.jar=4318:/datahub-frontend/client-prometheus-config.yaml"
fi

OTEL_AGENT=""
if [[ ${ENABLE_OTEL:-false} == true ]]; then
OTEL_AGENT="-javaagent:/opentelemetry-javaagent-all.jar"
fi

# make sure there is no whitespace at the beginning and the end of
# this string
export JAVA_OPTS="-Xms512m \
-Xmx1024m \
-Dhttp.port=$SERVER_PORT \
-Dconfig.file=datahub-frontend/conf/application.conf \
-Djava.security.auth.login.config=datahub-frontend/conf/jaas.conf \
-Dlogback.configurationFile=datahub-frontend/conf/logback.xml \
-Dlogback.debug=false \
${PROMETHEUS_AGENT:-} ${OTEL_AGENT:-}
-Dpidfile.path=/dev/null"

exec ./datahub-frontend/bin/datahub-frontend

11 changes: 11 additions & 0 deletions docker/monitoring/docker-compose.monitoring.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ services:
ports:
- "4318"

datahub-frontend-react:
environment:
- ENABLE_PROMETHEUS=true
- ENABLE_OTEL=true
- OTEL_TRACES_EXPORTER=jaeger
- OTEL_EXPORTER_JAEGER_ENDPOINT=http://jaeger-all-in-one:14250
- OTEL_METRICS_EXPORTER=none
- OTEL_SERVICE_NAME=datahub-gms
ports:
- "4318"

# Jaeger
jaeger-all-in-one:
image: jaegertracing/all-in-one:latest
Expand Down
3 changes: 2 additions & 1 deletion docker/monitoring/prometheus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ scrape_configs:
- 'host.docker.internal:4318'
- 'datahub-gms:4318'
- 'datahub-mae-consumer:4318'
- 'datahub-mce-consumer:4318'
- 'datahub-mce-consumer:4318'
- 'datahub-frontend-react:4318'
10 changes: 6 additions & 4 deletions docker/quickstart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ TAG_VERSION=$(cd $DIR && git name-rev --name-only --tags HEAD)
DEFAULT_VERSION=$(echo $TAG_VERSION | sed 's/undefined/head/')
export DATAHUB_VERSION=${DATAHUB_VERSION:-${DEFAULT_VERSION}}

M1_COMPOSE=""
if [[ $(uname -m) == 'arm64' && $(uname) == 'Darwin' ]]; then
M1_COMPOSE="-f docker-compose.m1.yml"
fi

echo "Quickstarting DataHub: version ${DATAHUB_VERSION}"
if docker volume ls | grep -c -q datahub_neo4jdata
then
Expand All @@ -32,10 +37,7 @@ then
else
echo "No Datahub Neo4j volume found, starting with elasticsearch as graph service"
cd $DIR && \
docker-compose \
-f quickstart/docker-compose-without-neo4j.quickstart.yml \
$MONITORING_COMPOSE $CONSUMERS_COMPOSE pull && \
docker-compose -p datahub \
-f quickstart/docker-compose-without-neo4j.quickstart.yml \
$MONITORING_COMPOSE $CONSUMERS_COMPOSE up $@
$MONITORING_COMPOSE $CONSUMERS_COMPOSE $M1_COMPOSE up $@
fi
10 changes: 10 additions & 0 deletions docker/quickstart/docker-compose.monitoring.quickstart.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
services:
datahub-frontend-react:
environment:
- ENABLE_PROMETHEUS=true
- ENABLE_OTEL=true
- OTEL_TRACES_EXPORTER=jaeger
- OTEL_EXPORTER_JAEGER_ENDPOINT=http://jaeger-all-in-one:14250
- OTEL_METRICS_EXPORTER=none
- OTEL_SERVICE_NAME=datahub-gms
ports:
- '4318'
datahub-gms:
environment:
- ENABLE_PROMETHEUS=true
Expand Down

0 comments on commit aa146db

Please sign in to comment.