From 5759983bbc38ef0328f639c7499e4e6b92327943 Mon Sep 17 00:00:00 2001 From: Steve Waterworth Date: Tue, 13 Feb 2018 16:56:45 +0000 Subject: [PATCH] end user monitoring --- README.md | 5 ++--- docker-compose.yaml | 3 +++ web/Dockerfile | 4 ++-- web/default.conf | 1 + web/entrypoint.sh | 23 +++++++++++++++++++++++ web/static/empty.html | 1 + web/static/eum-tmpl.html | 10 ++++++++++ web/static/index.html | 1 + web/static/js/controller.js | 18 ++++++++++++++++++ 9 files changed, 61 insertions(+), 5 deletions(-) create mode 100755 web/entrypoint.sh create mode 100644 web/static/empty.html create mode 100644 web/static/eum-tmpl.html diff --git a/README.md b/README.md index c5081a7..a12a42b 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,5 @@ If you are using a cloud Kubernetes / Openshift / Mesosphere then it will be ava ## Load Generation A separate load generation utility is provided in the *load-gen* directory. This is not automatically run when the application is started. The load generator is built with Python and [Locust](https://locust.io). The *build.sh* script builds the Docker image, optionally taking *push* as the first argument to also push the image to the registry. The registry and tag settings are loaded from the *.env* file in the parent directory. The script *load-gen.sh* runs the image, edit this and set the HOST environment variable to point the load at where you are running the application. You could run this inside an orchestration system (K8s) as well if you want to, how to do this is left as an exercise for the reader. -## TO DO - -- End User Monitoring +## End User Monitoring +To enable End User Monitoring (EUM) see the official [documentation](https://docs.instana.io/products/website_monitoring/) for how to create a configuration. There is no need to inject the javascript fragment into the page, this will be handled automatically. Just make a note of the unique key and set the environment variable INSTANA_EUM_KEY for the *web* image, see *docker-compose.yaml* for an example. diff --git a/docker-compose.yaml b/docker-compose.yaml index f553ee5..9e59541 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -103,6 +103,9 @@ services: - "8080:8080" networks: - robot-shop + # Uncomment to enable Instana EUM + # environment: + # INSTANA_EUM_KEY: networks: robot-shop: diff --git a/web/Dockerfile b/web/Dockerfile index 0e21260..07da3a0 100644 --- a/web/Dockerfile +++ b/web/Dockerfile @@ -2,8 +2,8 @@ FROM nginx:1.13.8 EXPOSE 8080 -# RUN apt-get update -y && apt-get install -y curl iputils-ping dnsutils -# RUN mkdir -p /var/cache/nginx && chmod 777 /var/cache/nginx +COPY entrypoint.sh /root/ +ENTRYPOINT ["/root/entrypoint.sh"] COPY default.conf /etc/nginx/conf.d/default.conf COPY static /usr/share/nginx/html diff --git a/web/default.conf b/web/default.conf index dd80215..2bbb8f5 100644 --- a/web/default.conf +++ b/web/default.conf @@ -8,6 +8,7 @@ server { location / { root /usr/share/nginx/html; index index.html index.htm; + ssi on; } #error_page 404 /404.html; diff --git a/web/entrypoint.sh b/web/entrypoint.sh new file mode 100755 index 0000000..de82d19 --- /dev/null +++ b/web/entrypoint.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +# set -x + +# echo "arg 1 $1" + +BASE_DIR=/usr/share/nginx/html + +if [ -n "$1" ] +then + exec "$@" +fi + +if [ -n "$INSTANA_EUM_KEY" ] +then + echo "Enabling Instana EUM" + sed -e "/ineum/s/INSTANA_EUM_KEY/$INSTANA_EUM_KEY/" $BASE_DIR/eum-tmpl.html > $BASE_DIR/eum.html +else + cp $BASE_DIR/empty.html $BASE_DIR/eum.html +fi + +exec nginx -g "daemon off;" + diff --git a/web/static/empty.html b/web/static/empty.html new file mode 100644 index 0000000..e17a5cc --- /dev/null +++ b/web/static/empty.html @@ -0,0 +1 @@ + diff --git a/web/static/eum-tmpl.html b/web/static/eum-tmpl.html new file mode 100644 index 0000000..3630f21 --- /dev/null +++ b/web/static/eum-tmpl.html @@ -0,0 +1,10 @@ + + + + diff --git a/web/static/index.html b/web/static/index.html index 80ea215..ca04514 100644 --- a/web/static/index.html +++ b/web/static/index.html @@ -1,6 +1,7 @@ + Stan's Robot Shop