Skip to content

Commit 5f38be8

Browse files
Merge pull request #112 from OneBusAway/feat/jmx-setup
Feat/jmx-setup
2 parents 4809c6f + 6541cb4 commit 5f38be8

File tree

5 files changed

+75
-10
lines changed

5 files changed

+75
-10
lines changed

docker-compose.prod.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ services:
5353
# Access the webapp on your host machine at a path like
5454
# http://localhost:8080/onebusaway-api-webapp/api/where/agency/${YOUR_AGENCY}.json?key=TEST
5555
- "8080:8080"
56+
- "1234:1234" # JMX exporter port
5657
# restart: always
5758
labels:
5859
caddy: "${DOMAIN}"

docker-compose.standalone.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,20 @@ services:
4949
# Access the webapp on your host machine at a path like
5050
# http://localhost:8080/onebusaway-api-webapp/api/where/agency/${YOUR_AGENCY}.json?key=TEST
5151
- "8080:8080"
52+
- "1234:1234" # JMX exporter port
53+
54+
# Uncomment the following section to test with prometheus and the JMX exporter in localhost
55+
# networks:
56+
# - monitoring
57+
# - default
5258
# restart: always
5359

60+
# Uncomment the following section to test with prometheus and the JMX exporter in localhost
61+
# networks:
62+
# monitoring:
63+
# external: true
64+
65+
5466
volumes:
5567
mysql-data:
56-
pg-data:
68+
pg-data:

docker-compose.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,19 @@ services:
6363
# Access the webapp on your host machine at a path like
6464
# http://localhost:8080/onebusaway-api-webapp/api/where/agency/${YOUR_AGENCY}.json?key=TEST
6565
- "8080:8080"
66+
- "1234:1234" # JMX exporter port
67+
68+
# networks:
69+
# - monitoring
70+
# - default
6671
# restart: always
6772

73+
74+
# Uncomment the following section to test with prometheus and the JMX exporter in localhost
75+
# networks:
76+
# monitoring:
77+
# external: true
78+
6879
volumes:
6980
mysql-data:
70-
pg-data:
81+
pg-data:

oba/Dockerfile

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,23 +105,23 @@ WORKDIR $CATALINA_HOME/webapps
105105
##########
106106

107107
COPY --from=builder \
108-
--chown=oba_user:oba_group \
109-
/oba/libs/onebusaway-api-webapp.war .
108+
--chown=oba_user:oba_group \
109+
/oba/libs/onebusaway-api-webapp.war .
110110

111111
RUN mkdir ROOT && \
112112
cd ROOT && \
113113
jar xvf ../onebusaway-api-webapp.war && \
114114
rm ../onebusaway-api-webapp.war
115115

116116
COPY --from=builder \
117-
--chown=oba_user:oba_group \
118-
/oba/libs/mysql-connector-j.jar \
119-
$CATALINA_HOME/webapps/ROOT/WEB-INF/lib/
117+
--chown=oba_user:oba_group \
118+
/oba/libs/mysql-connector-j.jar \
119+
$CATALINA_HOME/webapps/ROOT/WEB-INF/lib/
120120

121121
COPY --from=builder \
122-
--chown=oba_user:oba_group \
123-
/oba/libs/postgresql.jar \
124-
$CATALINA_HOME/webapps/ROOT/WEB-INF/lib/
122+
--chown=oba_user:oba_group \
123+
/oba/libs/postgresql.jar \
124+
$CATALINA_HOME/webapps/ROOT/WEB-INF/lib/
125125

126126
RUN mkdir -p /opt/oba/logs
127127
RUN chown -R oba_user:oba_group /opt/oba/logs
@@ -157,10 +157,23 @@ COPY --from=builder \
157157
RUN apt-get autoremove -y && apt-get clean
158158
RUN rm -rf /oba/webapps
159159

160+
161+
162+
# Jmx exporter
163+
164+
RUN mkdir -p /app && \
165+
wget -O /app/jmx_prometheus_javaagent.jar https://repo1.maven.org/maven2/io/prometheus/jmx/jmx_prometheus_javaagent/0.19.0/jmx_prometheus_javaagent-0.19.0.jar
166+
COPY ./jmx_exporter_config.yml /app/jmx_exporter_config.yml
167+
168+
# Set JVM options to include JMX exporter
169+
ENV JAVA_OPTS="-javaagent:/app/jmx_prometheus_javaagent.jar=1234:/app/jmx_exporter_config.yml"
170+
171+
160172
##########
161173
# Bootstrapper and Supervisor
162174
##########
163175

176+
164177
COPY bootstrap.sh /oba/bootstrap.sh
165178
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
166179
RUN chmod +x /oba/bootstrap.sh

oba/jmx_exporter_config.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
lowercaseOutputLabelNames: true
2+
lowercaseOutputName: true
3+
whitelistObjectNames:
4+
- "java.lang:type=OperatingSystem"
5+
- "java.lang:type=Memory"
6+
- "java.lang:type=MemoryPool,name=*"
7+
blacklistObjectNames: []
8+
rules:
9+
- pattern: "java.lang<type=OperatingSystem><>(committed_virtual_memory|free_physical_memory|free_swap_space|total_physical_memory|total_swap_space)_size:"
10+
name: os_$1_bytes
11+
type: GAUGE
12+
attrNameSnakeCase: true
13+
- pattern: 'java.lang<type=OperatingSystem><>((?!process_cpu_time)\w+):'
14+
name: os_$1
15+
type: GAUGE
16+
attrNameSnakeCase: true
17+
18+
- pattern: "java.lang<type=Memory><>HeapMemoryUsage"
19+
name: "jvm_memory_used_bytes"
20+
type: GAUGE
21+
- pattern: "java.lang<type=Memory><>NonHeapMemoryUsage"
22+
name: jvm_memory_non_heap_usage
23+
type: GAUGE
24+
- pattern: "java.lang<type=MemoryPool, name=.*><>Usage"
25+
name: jvm_memory_pool_usage
26+
type: GAUGE
27+
labels:
28+
pool: "$1"

0 commit comments

Comments
 (0)