Skip to content

Commit

Permalink
Merge pull request vromero#101 from vromero/feature/configure-jmx-exp…
Browse files Browse the repository at this point in the history
…orter

Add ability to configure jmx-exporter
  • Loading branch information
vromero authored Oct 27, 2018
2 parents ba4878e + 82f3ae0 commit 51cc419
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 27 deletions.
58 changes: 40 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,9 @@ TMP_DIR = $(shell DIR=$$(mktemp -d) && chmod 777 -R $${DIR} && echo $${DIR})


build_%:
$(guile $(GUILEIO))
cd src && \
docker build --build-arg ACTIVEMQ_ARTEMIS_VERSION=$(call versionFromTag,$*) $(BUILD_ARGS) -t $(call fullTagNameFromTag,$*) -f $(call dockerfileFromTag,$*) .

test_%:
GOSS_FILES_PATH=$$(pwd)/test GOSS_VARS="vars.yaml" dgoss run -it --rm -h testHostName.local $(call fullTagNameFromTag,$*) && \
GOSS_FILES_PATH=$$(pwd)/test GOSS_VARS="vars.yaml" dgoss run -it --rm -h testHostName.local -e ARTEMIS_USERNAME=myusername -e ARTEMIS_PASSWORD=mypassword $(call fullTagNameFromTag,$*) && \
GOSS_FILES_PATH=$$(pwd)/test GOSS_VARS="vars.yaml" dgoss run -it --rm -h testHostName.local -e ARTEMIS_PERF_JOURNAL=AUTO $(call fullTagNameFromTag,$*) && \
GOSS_FILES_PATH=$$(pwd)/test GOSS_VARS="vars.yaml" dgoss run -it --rm -h testHostName.local -e ARTEMIS_PERF_JOURNAL=NEVER $(call fullTagNameFromTag,$*) && \
GOSS_FILES_PATH=$$(pwd)/test GOSS_VARS="vars.yaml" dgoss run -it --rm -h testHostName.local -e ENABLE_JMX=true -e JMX_PORT=2222 -e JMX_RMI_PORT=3333 \
-e JAVA_OPTS="-Dmyjavaopt=yes" -e BROKER_CONFIG_GLOBAL_MAX_SIZE=9500 $(call fullTagNameFromTag,$*) && \
GOSS_FILES_PATH=$$(pwd)/test GOSS_VARS="vars.yaml" dgoss run -it --rm -h testHostName.local -e ENABLE_JMX_EXPORTER=true $(call fullTagNameFromTag,$*) && \
GOSS_FILES_PATH=$$(pwd)/test GOSS_VARS="vars.yaml" dgoss run -it --rm -h testHostName.local -e ARTEMIS_MIN_MEMORY=1512M -e ARTEMIS_MAX_MEMORY=3048M $(call fullTagNameFromTag,$*) && \
GOSS_FILES_PATH=$$(pwd)/test GOSS_VARS="vars.yaml" dgoss run -it --rm -h testHostName.local -e DISABLE_SECURITY=true $(call fullTagNameFromTag,$*) && \
GOSS_FILES_PATH=$$(pwd)/test GOSS_VARS="vars-etc-override.yaml" dgoss run -it --rm -h testHostName.local -v $$(pwd)/test/$$(echo "$*" | cut -d "." -f 1).x.x/etc-override:/var/lib/artemis/etc-override $(call fullTagNameFromTag,$*) && \
GOSS_FILES_PATH=$$(pwd)/test GOSS_VARS="vars.yaml" dgoss run -it --rm -h testHostName.local -v "$(TMP_DIR):/var/lib/artemis/etc" -e RESTORE_CONFIGURATION=true $(call fullTagNameFromTag,$*) && rm -Rf tmp

testdockerfile_%:
cd src && \
docker run --rm -i hadolint/hadolint < $(call dockerfileFromTag,$*)

testentrypoint_%:
shellcheck --version
shellcheck src/assets/docker-entrypoint.sh
Expand All @@ -55,3 +37,43 @@ runsh_%: build

all: $(ALL_VERSION_TAGS)

testdockerfile_%:
cd src && \
docker run --rm -i hadolint/hadolint < $(call dockerfileFromTag,$*)

test_%: test_can_run_% test_can_set_username_password_% test_can_autorun_perf_journal_% test_can_skip_perf_journal_% test_can_enable_jmx_% test_can_enable_jmx_exporter_% test_can_enable_jmx_exporter_with_custom_config_% test_can_set_memory_limits_% test_can_disable_security_% test_can_disable_security_% test_can_override_etc_% test_can_override_etc_%


test_can_run_%:
GOSS_FILES_PATH=$$(pwd)/test GOSS_VARS="vars.yaml" dgoss run -it --rm -h testHostName.local $(call fullTagNameFromTag,$*) > /dev/null 2>&1

test_can_set_username_password_%:
GOSS_FILES_PATH=$$(pwd)/test GOSS_VARS="vars.yaml" dgoss run -it --rm -h testHostName.local -e ARTEMIS_USERNAME=myusername -e ARTEMIS_PASSWORD=mypassword $(call fullTagNameFromTag,$*) > /dev/null 2>&1

test_can_autorun_perf_journal_%:
GOSS_FILES_PATH=$$(pwd)/test GOSS_VARS="vars.yaml" dgoss run -it --rm -h testHostName.local -e ARTEMIS_PERF_JOURNAL=AUTO $(call fullTagNameFromTag,$*) > /dev/null 2>&1

test_can_skip_perf_journal_%:
GOSS_FILES_PATH=$$(pwd)/test GOSS_VARS="vars.yaml" dgoss run -it --rm -h testHostName.local -e ARTEMIS_PERF_JOURNAL=NEVER $(call fullTagNameFromTag,$*) > /dev/null 2>&1

test_can_enable_jmx_exporter_with_custom_config_%:
GOSS_FILES_PATH=$$(pwd)/test GOSS_VARS="vars.yaml" dgoss run -it --rm -h testHostName.local -e ENABLE_JMX_EXPORTER=true -e TEST_CUSTOM_JMX_EXPORTER_CONFIG=true -v $$(pwd)/test/etc-override:/opt/jmx-exporter/etc-override $(call fullTagNameFromTag,$*) > /dev/null 2>&1

test_can_enable_jmx_exporter_%:
GOSS_FILES_PATH=$$(pwd)/test GOSS_VARS="vars.yaml" dgoss run -it --rm -h testHostName.local -e ENABLE_JMX_EXPORTER=true $(call fullTagNameFromTag,$*) > /dev/null 2>&1

test_can_enable_jmx_%:
GOSS_FILES_PATH=$$(pwd)/test GOSS_VARS="vars.yaml" dgoss run -it --rm -h testHostName.local -e ENABLE_JMX=true -e JMX_PORT=2222 -e JMX_RMI_PORT=3333 \
-e JAVA_OPTS="-Dmyjavaopt=yes" -e BROKER_CONFIG_GLOBAL_MAX_SIZE=9500 $(call fullTagNameFromTag,$*) > /dev/null 2>&1

test_can_set_memory_limits_%:
GOSS_FILES_PATH=$$(pwd)/test GOSS_VARS="vars.yaml" dgoss run -it --rm -h testHostName.local -e ARTEMIS_MIN_MEMORY=1512M -e ARTEMIS_MAX_MEMORY=3048M $(call fullTagNameFromTag,$*) > /dev/null 2>&1

test_can_disable_security_%:
GOSS_FILES_PATH=$$(pwd)/test GOSS_VARS="vars.yaml" dgoss run -it --rm -h testHostName.local -e DISABLE_SECURITY=true $(call fullTagNameFromTag,$*) > /dev/null 2>&1

test_can_override_etc_%:
GOSS_FILES_PATH=$$(pwd)/test GOSS_VARS="vars-etc-override.yaml" dgoss run -it --rm -h testHostName.local -v $$(pwd)/test/$$(echo "$*" | cut -d "." -f 1).x.x/etc-override:/var/lib/artemis/etc-override $(call fullTagNameFromTag,$*) > /dev/null 2>&1

test_can_override_etc_%:
GOSS_FILES_PATH=$$(pwd)/test GOSS_VARS="vars.yaml" dgoss run -it --rm -h testHostName.local -v "$(TMP_DIR):/var/lib/artemis/etc" -e RESTORE_CONFIGURATION=true $(call fullTagNameFromTag,$*) > /dev/null 2>&1
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,9 @@ artemis_journal_buffer_size 501760.0
artemis_journal_max_io 4096.0
```

In case you need more control over the metrics that are exported, you can mount a [jmx-exporter](https://github.com/prometheus/jmx_exporter)
configuration file in `/opt/jmx-exporter/etc-override` with the file name `jmx-exporter-config.yaml`.

### 5.6 Settings the console's allow origin

ActiveMQ Artemis console uses Jolokia. In the default vanilla non-docker installation Jolokia does set a CORS header to
Expand Down Expand Up @@ -383,12 +386,13 @@ Additionally, the following environment variables are supported

### 5.12 Mount points

| Mount point | Description |
|--------------------------------- |-------------------------------------------------------------------|
|`/var/lib/artemis/data` | Holds the data files used for storing persistent messages |
|`/var/lib/artemis/etc` | Hold the instance configuration files |
|`/var/lib/artemis/etc-override` | Hold the instance configuration files |
|`/var/lib/artemis/lock` | Hold the command line locks (typically not useful to mount) |
| Mount point | Description |
|--------------------------------- |--------------------------------------------------------------------------|
|`/var/lib/artemis/data` | Holds the data files used for storing persistent messages |
|`/var/lib/artemis/etc` | Holds the instance configuration files |
|`/var/lib/artemis/etc-override` | Holds the instance configuration files |
|`/var/lib/artemis/lock` | Holds the command line locks (typically not useful to mount) |
|`/opt/jmx-exporter/etc-override` | Holds the configuration file for jmx-exporter `jmx-exporter-config.yaml` |

### 5.13 Exposed ports

Expand Down
5 changes: 4 additions & 1 deletion src/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ RUN wget "https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_javaag
echo "$(cat "jmx_prometheus_javaagent-${JMX_EXPORTER_VERSION}.jar.sha1")" "jmx_prometheus_javaagent-${JMX_EXPORTER_VERSION}.jar" | sha1sum -c - && \
rm "jmx_prometheus_javaagent-${JMX_EXPORTER_VERSION}.jar.sha1" && \
ln -s "/opt/jmx-exporter/jmx_prometheus_javaagent-${JMX_EXPORTER_VERSION}.jar" "/opt/jmx-exporter/jmx_prometheus_javaagent.jar"
COPY assets/jmx-exporter-config.yaml /opt/jmx-exporter

COPY assets/jmx-exporter-config.yaml /opt/jmx-exporter/etc/

##########################################################
## Run Image #
Expand Down Expand Up @@ -141,6 +142,7 @@ COPY --from=builder "/var/lib/artemis/etc" "/var/lib/artemis/etc-backup"

RUN ln -s "/opt/apache-artemis-${ACTIVEMQ_ARTEMIS_VERSION}" /opt/apache-artemis && chmod 755 /opt/apache-artemis
RUN chown -R artemis.artemis /var/lib/artemis
RUN chown -R artemis.artemis /opt/jmx-exporter

RUN mkdir -p /opt/assets
COPY assets/merge.xslt /opt/assets
Expand Down Expand Up @@ -179,6 +181,7 @@ VOLUME ["/var/lib/artemis/tmp"]
VOLUME ["/var/lib/artemis/etc"]
VOLUME ["/var/lib/artemis/etc-override"]
VOLUME ["/var/lib/artemis/lock"]
VOLUME ["/opt/jmx-exporter/etc-override"]

COPY assets/docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]
Expand Down
3 changes: 2 additions & 1 deletion src/Dockerfile.alpine
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ RUN wget "https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_javaag
echo "$(cat "jmx_prometheus_javaagent-${JMX_EXPORTER_VERSION}.jar.sha1")" "jmx_prometheus_javaagent-${JMX_EXPORTER_VERSION}.jar" | sha1sum -c - && \
rm "jmx_prometheus_javaagent-${JMX_EXPORTER_VERSION}.jar.sha1" && \
ln -s "/opt/jmx-exporter/jmx_prometheus_javaagent-${JMX_EXPORTER_VERSION}.jar" "/opt/jmx-exporter/jmx_prometheus_javaagent.jar"
COPY assets/jmx-exporter-config.yaml /opt/jmx-exporter
COPY assets/jmx-exporter-config.yaml /opt/jmx-exporter/etc/

##########################################################
## Run Image #
Expand All @@ -135,6 +135,7 @@ COPY --from=builder "/var/lib/artemis/etc" "/var/lib/artemis/etc-backup"

RUN ln -s "/opt/apache-artemis-${ACTIVEMQ_ARTEMIS_VERSION}" /opt/apache-artemis
RUN chown -R artemis.artemis /var/lib/artemis
RUN chown -R artemis.artemis /opt/jmx-exporter

RUN mkdir -p /opt/assets
COPY assets/merge.xslt /opt/assets
Expand Down
5 changes: 4 additions & 1 deletion src/assets/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ if [ "$ENABLE_JMX" ] || [ "$ENABLE_JMX_EXPORTER" ]; then
fi

if [ "$ENABLE_JMX_EXPORTER" ]; then
sed -i "/jmx_prometheus_javaagent.jar/!s/^JAVA_ARGS=\"/JAVA_ARGS=\"-javaagent:\\/opt\\/jmx-exporter\\/jmx_prometheus_javaagent.jar=9404:\\/opt\\/jmx-exporter\\/jmx-exporter-config.yaml /g" $CONFIG_PATH/artemis.profile
if [ -f /opt/jmx-exporter/etc-override/jmx-exporter-config.yaml ]; then
cp /opt/jmx-exporter/etc-override/jmx-exporter-config.yaml /opt/jmx-exporter/etc/jmx-exporter-config.yaml
fi
sed -i "/jmx_prometheus_javaagent.jar/!s/^JAVA_ARGS=\"/JAVA_ARGS=\"-javaagent:\\/opt\\/jmx-exporter\\/jmx_prometheus_javaagent.jar=9404:\\/opt\\/jmx-exporter\\/etc\\/jmx-exporter-config.yaml /g" $CONFIG_PATH/artemis.profile
fi

if [ -e /var/lib/artemis/etc/jolokia-access.xml ]; then
Expand Down
8 changes: 8 additions & 0 deletions test/etc-override/jmx-exporter-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
lowercaseOutputName: true
lowercaseOutputLabelNames: true
rules:
- pattern: "^org.apache.activemq.artemis<broker=\"([^\"]*)\"><>([^:]*):\\s(.*)"
attrNameSnakeCase: true
name: just_for_test_$2
type: COUNTER
9 changes: 9 additions & 0 deletions test/goss.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,12 @@ file:
owner: artemis
group: artemis
{{end}}

{{if and (getEnv "ENABLE_JMX_EXPORTER") (getEnv "TEST_CUSTOM_JMX_EXPORTER_CONFIG") }}
/opt/jmx-exporter/etc/jmx-exporter-config.yaml:
exists: true
owner: artemis
group: artemis
contains:
- "just_for_test"
{{end}}

0 comments on commit 51cc419

Please sign in to comment.