Skip to content

Commit

Permalink
Added the jaeger-query service that visualizes traces stored in Elast…
Browse files Browse the repository at this point in the history
…icsearch

The jaeger-query service uses a custom image containing a wait script wrapping the jaeger-query binary.

The wait script is a workaround for ensuring elastic search is ready before starting the query service. Docker does not support this natively.

TODO: figure out a way to download the jaeger-query binary in the Dockerfile, instead of saving the binary in the repo.
  • Loading branch information
Uzziah Eyee committed May 5, 2019
1 parent bc47d3a commit 6e4baac
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 0 deletions.
14 changes: 14 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,20 @@ services:
# receiving port of Query & UI
QUERY_PORT: 16686

jaeger-query:
build: jaeger-query
environment:
SPAN_STORAGE_TYPE: elasticsearch
ES_SERVER_URLS: http://elasticsearch:9200
ports:
- "16686:16686" # provides UI
- "16687:16687" # healthcheck
networks:
- aparnet
command: wait.sh http://elasticsearch:9200 5 20 "jaeger-query"
depends_on:
- elasticsearch

elasticsearch:
image: elasticsearch:5.6-alpine
ports:
Expand Down
8 changes: 8 additions & 0 deletions jaeger-query/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM alpine:3.9.3

# required by wait script
RUN apk add --no-cache bash curl

COPY jaeger-query wait.sh /usr/local/bin/

RUN chmod +x /usr/local/bin/wait.sh
Binary file added jaeger-query/jaeger-query
Binary file not shown.
36 changes: 36 additions & 0 deletions jaeger-query/wait.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

# Requires a container with Bash and Curl installed.

is_healthy () {
retryInterval=${2:-5}
maxAttempts=${3:-1000000}

i=0
while [ $i -lt $maxAttempts ]
do
status=$(curl -s -L -o /dev/null -w %{http_code} $1)

# stop trying if we get a success response
if [ $status -ge 200 ] && [ $status -lt 300 ]
then
return 0
fi

((i++))
echo "Attempt $i of $maxAttempts: Endpoint $1 returned code $status. Retrying in $retryInterval seconds."
sleep $retryInterval
done

return 1
}

# args: endpoint, retryInterval (secs), maxAttempts, command
if is_healthy $1 $2 $3
then
echo "Running command: $4"
# vulnerable to input-injection attacts (but I don't care :)
eval "$4"
else
echo "Exiting: Cannot run command because health-check failed."
fi

0 comments on commit 6e4baac

Please sign in to comment.