Skip to content

Commit

Permalink
Merge pull request #9 from mstump/master
Browse files Browse the repository at this point in the history
Add prometheus jmx_exporter
  • Loading branch information
chrislovecnm authored Mar 16, 2017
2 parents 6fd669d + 1fc5df8 commit 4cc5c2a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
13 changes: 9 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@ ENV \
DI_VERSION=1.2.0 \
DI_SHA=81231da1cd074fdc81af62789fead8641ef3f24b6b07366a1c34e5b059faf363 \
JOLOKIA_VERSION=1.3.5 \
JOLOKIA_SHA=90907e9d1aa8799252c08cd5ec67d805b2661ad6e773d0de9c8e3d1620b72369
JOLOKIA_SHA=90907e9d1aa8799252c08cd5ec67d805b2661ad6e773d0de9c8e3d1620b72369 \
PROMETHEUS_VERSION=0.8 \
PROMETHEUS_SHA=c32440e4a98b441b4ab66a788df77494d32e1560e0f3bb5342752bf064408520

COPY files /

RUN \
set -ex \
set -ex \
&& echo 'debconf debconf/frontend select Noninteractive' | debconf-set-selections \
&& export CASSANDRA_VERSION=${CASSANDRA_VERSION:-$CASSANDRA_RELEASE} \
&& export CASSANDRA_HOME=/usr/local/apache-cassandra-${CASSANDRA_VERSION} \
Expand All @@ -52,6 +54,8 @@ RUN \
libjemalloc1 \
localepurge \
wget \
&& wget -q -O - "http://search.maven.org/remotecontent?filepath=io/prometheus/jmx/jmx_prometheus_javaagent/${PROMETHEUS_VERSION}/jmx_prometheus_javaagent-${PROMETHEUS_VERSION}.jar" > /usr/local/share/prometheus-agent.jar \
&& echo "$PROMETHEUS_SHA /usr/local/share/prometheus-agent.jar" | sha256sum -c - \
&& wget -q -O - "http://search.maven.org/remotecontent?filepath=org/jolokia/jolokia-jvm/${JOLOKIA_VERSION}/jolokia-jvm-${JOLOKIA_VERSION}-agent.jar" > /usr/local/share/jolokia-agent.jar \
&& echo "$JOLOKIA_SHA /usr/local/share/jolokia-agent.jar" | sha256sum -c - \
&& mirror_url=$( wget -q -O - http://www.apache.org/dyn/closer.cgi/cassandra \
Expand All @@ -65,7 +69,7 @@ RUN \
&& echo "$DI_SHA /sbin/dumb-init" | sha256sum -c - \
&& chmod +x /sbin/dumb-init /ready-probe.sh \
&& mkdir -p /var/lib/cassandra/ /etc/cassandra/triggers \
&& mv /logback.xml /cassandra.yaml /jvm.options /etc/cassandra/ \
&& mv /logback.xml /cassandra.yaml /jvm.options /prometheus.yaml /etc/cassandra/ \
&& mv /usr/local/apache-cassandra-${CASSANDRA_VERSION}/conf/cassandra-env.sh /etc/cassandra/ \
&& adduser --disabled-password --no-create-home --gecos '' --disabled-login cassandra \
&& chown cassandra: /ready-probe.sh \
Expand Down Expand Up @@ -131,12 +135,13 @@ RUN \

VOLUME ["/var/lib/cassandra"]

# 1234: prometheus jmx_exporter
# 7000: intra-node communication
# 7001: TLS intra-node communication
# 7199: JMX
# 9042: CQL
# 9160: thrift service
# 8778: jolokia port
EXPOSE 7000 7001 7199 9042 9160 8778
EXPOSE 1234 7000 7001 7199 9042 9160 8778

CMD ["/sbin/dumb-init", "/bin/bash", "/run.sh"]
1 change: 1 addition & 0 deletions files/jvm.options
Original file line number Diff line number Diff line change
Expand Up @@ -239,3 +239,4 @@
-XX:NumberOfGCLogFiles=10
-XX:GCLogFileSize=10M
-javaagent:/usr/local/share/jolokia-agent.jar=host=0.0.0.0
-javaagent:/usr/local/share/prometheus-agent.jar=1234:/etc/cassandra/prometheus.yaml
14 changes: 14 additions & 0 deletions files/prometheus.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
lowercaseOutputLabelNames: true
lowercaseOutputName: true
rules:
- pattern: org.apache.cassandra.metrics<type=(Connection|Streaming), scope=(\S*), name=(\S*)><>(Count|Value)
name: cassandra_$1_$3
labels:
address: "$2"
- pattern: org.apache.cassandra.metrics<type=(\S*)(?:, ((?!scope)\S*)=(\S*))?(?:, scope=(\S*))?,
name=(\S*)><>(Count|Value)
name: cassandra_$1_$5
labels:
"$1": "$4"
"$2": "$3"
2 changes: 1 addition & 1 deletion files/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ sed -ri 's/- class_name: SEED_PROVIDER/- class_name: '"$CASSANDRA_SEED_PROVIDER"

# send gc to stdout
if [[ $CASSANDRA_GC_STDOUT == 'true' ]]; then
sed -ri 's/ -Xloggc:\/var\/log\/cassandra\/gc\.log//' $CASSANDRA_CONF_DIR/cassandra-env.sh
sed -ri 's/JVM_OPTS.*-Xloggc:.*//' $CASSANDRA_CONF_DIR/cassandra-env.sh
fi

# enable RMI and JMX to work on one port
Expand Down

0 comments on commit 4cc5c2a

Please sign in to comment.