Skip to content
This repository has been archived by the owner on Nov 16, 2022. It is now read-only.

Commit

Permalink
Fix #21 - Merge branch 'issue21'
Browse files Browse the repository at this point in the history
Collect JVM metrics from the Vamp API info command using httpbeat:
- https://github.com/christiangalsterer/httpbeat
  • Loading branch information
Mikael Sörlin committed Feb 22, 2017
2 parents b2b2e0d + f9bb96e commit 4d4c5fe
Show file tree
Hide file tree
Showing 16 changed files with 2,451 additions and 8 deletions.
69 changes: 64 additions & 5 deletions vamp/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,75 @@
FROM java:openjdk-8-jre-alpine
FROM magneticio/java:openjdk-8-jre-alpine

# https://github.com/peterbourgon/runsvinit
ENV RUNSVINIT_URL=https://github.com/peterbourgon/runsvinit/releases/download/v2.0.0/runsvinit-linux-amd64.tgz

ENV METRICBEAT_VER=5.2.1
ENV METRICBEAT_URL=https://artifacts.elastic.co/downloads/beats/metricbeat/metricbeat-${METRICBEAT_VER}-linux-x86_64.tar.gz

ENV HTTPBEAT_VER=4.0.0
ENV HTTPBEAT_URL=https://github.com/christiangalsterer/httpbeat/releases/download/${HTTPBEAT_VER}/httpbeat-${HTTPBEAT_VER}-linux-x86_64.tar.gz

RUN ALPINE_GLIBC_BASE_URL="https://github.com/sgerrand/alpine-pkg-glibc/releases/download" && \
ALPINE_GLIBC_PACKAGE_VERSION="2.23-r3" && \
ALPINE_GLIBC_BASE_PACKAGE_FILENAME="glibc-$ALPINE_GLIBC_PACKAGE_VERSION.apk" && \
ALPINE_GLIBC_BIN_PACKAGE_FILENAME="glibc-bin-$ALPINE_GLIBC_PACKAGE_VERSION.apk" && \
ALPINE_GLIBC_I18N_PACKAGE_FILENAME="glibc-i18n-$ALPINE_GLIBC_PACKAGE_VERSION.apk" && \
apk add --no-cache --virtual=.build-dependencies wget ca-certificates && \
wget \
"https://raw.githubusercontent.com/andyshinn/alpine-pkg-glibc/master/sgerrand.rsa.pub" \
-O "/etc/apk/keys/sgerrand.rsa.pub" && \
wget \
"$ALPINE_GLIBC_BASE_URL/$ALPINE_GLIBC_PACKAGE_VERSION/$ALPINE_GLIBC_BASE_PACKAGE_FILENAME" \
"$ALPINE_GLIBC_BASE_URL/$ALPINE_GLIBC_PACKAGE_VERSION/$ALPINE_GLIBC_BIN_PACKAGE_FILENAME" \
"$ALPINE_GLIBC_BASE_URL/$ALPINE_GLIBC_PACKAGE_VERSION/$ALPINE_GLIBC_I18N_PACKAGE_FILENAME" && \
apk add --no-cache \
"$ALPINE_GLIBC_BASE_PACKAGE_FILENAME" \
"$ALPINE_GLIBC_BIN_PACKAGE_FILENAME" \
"$ALPINE_GLIBC_I18N_PACKAGE_FILENAME" && \
\
rm "/etc/apk/keys/sgerrand.rsa.pub" && \
/usr/glibc-compat/bin/localedef --force --inputfile POSIX --charmap UTF-8 C.UTF-8 || true && \
echo "export LANG=C.UTF-8" > /etc/profile.d/locale.sh && \
\
apk del glibc-i18n && \
\
rm "/root/.wget-hsts" && \
apk del .build-dependencies && \
rm \
"$ALPINE_GLIBC_BASE_PACKAGE_FILENAME" \
"$ALPINE_GLIBC_BIN_PACKAGE_FILENAME" \
"$ALPINE_GLIBC_I18N_PACKAGE_FILENAME"

ENV LANG=C.UTF-8

RUN set -xe \
&& apk add --no-cache \
bash \
curl \
runit \
&& curl --location --silent --show-error $RUNSVINIT_URL --output - | tar zxf - -C /sbin \
&& chown 0:0 /sbin/runsvinit \
&& chmod 0775 /sbin/runsvinit \
\
&& mkdir -p /usr/local/metricbeat/ \
&& curl --location --silent --show-error $METRICBEAT_URL --output - | tar zxf - -C /tmp \
&& mv /tmp/metricbeat-${METRICBEAT_VER}-linux-x86_64/metricbeat /usr/local/metricbeat/ \
&& rm -rf /tmp/metricbeat-${METRICBEAT_VER}-linux-x86_64 \
\
&& mkdir -p /usr/local/httpbeat/ \
&& curl --location --silent --show-error $HTTPBEAT_URL --output - | tar zxf - -C /tmp \
&& mv /tmp/httpbeat-5.2.1-SNAPSHOT-linux-x86_64/httpbeat /usr/local/httpbeat/ \
&& rm -rf /tmp/httpbeat-5.2.1-SNAPSHOT-linux-x86_64

RUN mkdir -p /usr/local/vamp/conf
ADD vamp-artifacts /usr/local/vamp/artifacts
ADD vamp-ui /usr/local/vamp/ui
ADD vamp /usr/local/vamp/bin
ADD logback.xml /usr/local/vamp/
ADD vamp.sh /usr/local/vamp/vamp
RUN chmod +x /usr/local/vamp/vamp
ADD files/ /

ENV VAMP_REST_API_UI_DIRECTORY /usr/local/vamp/ui
ENV VAMP_REST_API_UI_INDEX /usr/local/vamp/ui/index.html

VOLUME /usr/local/vamp/conf

CMD ["/usr/local/vamp/vamp"]
CMD ["/sbin/runsvinit"]
10 changes: 8 additions & 2 deletions vamp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@ This can be done in few way:
- providing `application.conf` file and/or
- setting environment variables


Let's say `application.conf` is stored in `/MY/APP/CONF/PATH` directory (absolute path), then:
```
```shell
docker run -v /MY/APP/CONF/PATH:/usr/local/vamp/conf magneticio/vamp:katana
```

For metric collection to work Elasticsearch URL need to be provided through the environment variable `VAMP_ELASTICSEARCH_URL`.
```shell
docker run -e VAMP_ELASTICSEARCH_URL=http://elasticsearch.example.com:9200 -v /MY/APP/CONF/PATH:/usr/local/vamp/conf magneticio/vamp:katana
```

Required minimal configuration is:
```yaml
vamp {
Expand Down Expand Up @@ -74,4 +80,4 @@ An example can be found also in `Dockerfile`:
```bash
ENV VAMP_REST_API_UI_DIRECTORY /usr/local/vamp/ui
ENV VAMP_REST_API_UI_INDEX /usr/local/vamp/ui/index.html
```
```
32 changes: 32 additions & 0 deletions vamp/alpine/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Alpine 3.5 version of java:openjdk-8-jre-alpine
# From: https://github.com/docker-library/openjdk/blob/9a0822673dffd3e5ba66f18a8547aa60faed6d08/8-jre/alpine/Dockerfile

FROM alpine:3.5

# A few problems with compiling Java from source:
# 1. Oracle. Licensing prevents us from redistributing the official JDK.
# 2. Compiling OpenJDK also requires the JDK to be installed, and it gets
# really hairy.

# Default to UTF-8 file.encoding
ENV LANG C.UTF-8

# add a simple script that can auto-detect the appropriate JAVA_HOME value
# based on whether the JDK or only the JRE is installed
RUN { \
echo '#!/bin/sh'; \
echo 'set -e'; \
echo; \
echo 'dirname "$(dirname "$(readlink -f "$(which javac || which java)")")"'; \
} > /usr/local/bin/docker-java-home \
&& chmod +x /usr/local/bin/docker-java-home
ENV JAVA_HOME /usr/lib/jvm/java-1.8-openjdk/jre
ENV PATH $PATH:/usr/lib/jvm/java-1.8-openjdk/jre/bin:/usr/lib/jvm/java-1.8-openjdk/bin

ENV JAVA_VERSION 8u111
ENV JAVA_ALPINE_VERSION 8.121.13-r0

RUN set -x \
&& apk add --no-cache \
openjdk8-jre="$JAVA_ALPINE_VERSION" \
&& [ "$JAVA_HOME" = "$(docker-java-home)" ]
7 changes: 7 additions & 0 deletions vamp/alpine/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
all: build

build:
docker build --tag magneticio/java:openjdk-8-jre-alpine .

clean:
docker rmi magneticio/java:openjdk-8-jre-alpine
13 changes: 13 additions & 0 deletions vamp/files/etc/service/httpbeat/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#! /bin/bash
handle() { echo "httpbeat/run: got signal"; exit; }
trap handle SIGINT

if [[ -z $VAMP_ELASTICSEARCH_URL ]] ; then
sv stop httpbeat
exit
fi

[[ -e /usr/local/httpbeat/httpbeat.yml ]] || exit 1

exec 2>&1
exec /usr/local/httpbeat/httpbeat -c /usr/local/httpbeat/httpbeat.yml
13 changes: 13 additions & 0 deletions vamp/files/etc/service/metricbeat/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#! /bin/bash
handle() { echo "metricbeat/run: got signal"; exit; }
trap handle SIGINT

if [[ -z $VAMP_ELASTICSEARCH_URL ]] ; then
sv stop metricbeat
exit
fi

[[ -e /usr/local/metricbeat/metricbeat.yml ]] || exit 1

exec 2>&1
exec /usr/local/metricbeat/metricbeat -c /usr/local/metricbeat/metricbeat.yml
6 changes: 6 additions & 0 deletions vamp/files/etc/service/vamp/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#! /bin/bash
handle() { echo "vamp/run: got signal"; exit; }
trap handle SIGINT

exec 2>&1
exec /usr/local/vamp/vamp
143 changes: 143 additions & 0 deletions vamp/files/usr/local/httpbeat/httpbeat.template-es2x.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
{
"mappings": {
"_default_": {
"_all": {
"norms": {
"enabled": false
}
},
"_meta": {
"version": "5.2.1"
},
"dynamic_templates": [
{
"strings_as_keyword": {
"mapping": {
"ignore_above": 1024,
"index": "not_analyzed",
"type": "string"
},
"match_mapping_type": "string"
}
}
],
"properties": {
"@timestamp": {
"type": "date"
},
"beat": {
"properties": {
"hostname": {
"ignore_above": 1024,
"index": "not_analyzed",
"type": "string"
},
"name": {
"ignore_above": 1024,
"index": "not_analyzed",
"type": "string"
},
"version": {
"ignore_above": 1024,
"index": "not_analyzed",
"type": "string"
}
}
},
"meta": {
"properties": {
"cloud": {
"properties": {
"availability_zone": {
"ignore_above": 1024,
"index": "not_analyzed",
"type": "string"
},
"instance_id": {
"ignore_above": 1024,
"index": "not_analyzed",
"type": "string"
},
"machine_type": {
"ignore_above": 1024,
"index": "not_analyzed",
"type": "string"
},
"project_id": {
"ignore_above": 1024,
"index": "not_analyzed",
"type": "string"
},
"provider": {
"ignore_above": 1024,
"index": "not_analyzed",
"type": "string"
},
"region": {
"ignore_above": 1024,
"index": "not_analyzed",
"type": "string"
}
}
}
}
},
"request": {
"properties": {
"body": {
"ignore_above": 1024,
"index": "not_analyzed",
"type": "string"
},
"headers": {
"properties": {},
"type": "nested"
},
"method": {
"ignore_above": 1024,
"index": "not_analyzed",
"type": "string"
},
"url": {
"ignore_above": 1024,
"index": "not_analyzed",
"type": "string"
}
}
},
"response": {
"properties": {
"body": {
"ignore_above": 1024,
"index": "not_analyzed",
"type": "string"
},
"code": {
"ignore_above": 1024,
"index": "not_analyzed",
"type": "string"
},
"headers": {
"properties": {},
"type": "nested"
},
"jsonBody": {
"properties": {},
"type": "nested"
}
}
},
"tags": {
"ignore_above": 1024,
"index": "not_analyzed",
"type": "string"
}
}
}
},
"order": 0,
"settings": {
"index.refresh_interval": "5s"
},
"template": "httpbeat-*"
}
Loading

0 comments on commit 4d4c5fe

Please sign in to comment.