Skip to content

Commit f286e9d

Browse files
Merge pull request #157 from EyeSeeTea/development
Release 1.17.0
2 parents 31becc8 + 922b3aa commit f286e9d

File tree

6 files changed

+67
-20
lines changed

6 files changed

+67
-20
lines changed

README.md

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -383,14 +383,42 @@ $ curl -sS 'http://localhost:5000/harbor/https://docker.eyeseetea.com/api/v2.0/q
383383
## Glowroot
384384

385385
Glowroot is an open-source Java APM (Application Performance Monitoring) tool. It can help detect and diagnose application performance problems, tracing slow requests, errors, response time breakdowns, SQL capture and more.
386-
When starting a container, there are two options to enable glowroot on the Tomcat process:
387-
- Use option `--glowroot` to use the latest version of glowroot in the Tomcat process. This requires internet access to be able to retrieve the file.
388-
- Use option `--glowroot-zip=FILE` to specify the zip file with the version of glowroot to run in the Tomcat process. This takes precedence over the other option.
389-
When enabling glowroot, it will start listening on port 4000/tcp so you can connect via browser to its interface. You may override this port with:
390-
- `--glowroot-port=PORT` to specify the APM glowroot port.
386+
The startup script in the core container expects a `/opt/glowroot.zip` file; if it exists, it will decompress that file and enable a default configuration for glowroot in the tomcat process.
387+
The only needed parameter to use glowroot is the `--glowroot-port`, as the metrics are exposes through its own http connection, so the port must be opened in the container.
388+
To use glowroot:
391389

392-
### Run d2-docker with glowroot enabled in the default port at the latest version available
390+
- start d2-docker with `--glowroot-port=<PORT>` (default port for glowroot is 4000, but any available port can be used)
391+
- download the latest version of glowroot to the host machine:
393392

394393
```
395-
$ d2-docker start docker.eyeseetea.com/eyeseetea/dhis2-data:2.37.9-sierra --glowroot
394+
lastversion=$(wget -q -O - https://api.github.com/repos/glowroot/glowroot/releases/latest | jq '.tag_name' | sed 's_"__g')
395+
wget -q https://github.com/glowroot/glowroot/releases/download/$lastversion/glowroot-${lastversion#v}-dist.zip
396396
```
397+
398+
- determine the core instance name (note that as there might be several d2-docker instances running, you must pick the one you want manually from the list)
399+
400+
```
401+
docker ps | awk '/core.1/ {print $NF}'
402+
```
403+
404+
- copy the zip file to the core container with the filename `/opt/glowroot.zip`:
405+
406+
```
407+
docker cp glowroot-0.14.4-dist.zip ${core_instance_name}:/opt/glowroot.zip
408+
```
409+
410+
- restart the core container:
411+
412+
```
413+
docker restart ${core_instance_name}
414+
```
415+
416+
Glowroot is configured to store its data for several days, so the size of its folder should be limited to some extent. This size may be further reduced editing the configuration via WebUI, but might require a restart of the container. Configuration (and glowroot historical data) will be kept unless the `/opt/glowroot` folder is deleted from the container and restarted.
417+
418+
To remove glowroot from a container you must:
419+
420+
- connect to the core container (`docker exec -it ${core_instance_name} bash`)
421+
- inside the core container, remove the `/opt/glowroot.zip` file
422+
- inside the core container, remove the `/opt/glowroot` folder
423+
- inside the core container, remove the `/usr/local/tomcat/bin/setenv.sh` file. (This is not extrictly necessary as the jar file will no longer exist and won't be able to start, but if it is not removed, some warnings/errors may be generated upon tomcat start)
424+
- exit the core container and restart it (`docker restart ${core_instance_name}`)

src/d2_docker/commands/start.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ def setup(parser):
4242
parser.add_argument("--enable-postgres-queries-logging", action="store_true",
4343
help="Enable Postgres queries logging")
4444

45-
parser.add_argument("--glowroot", action="store_true", help="Enables glowroot in tomcat in latest version")
46-
parser.add_argument("--glowroot-zip", metavar="FILE", help="ZIP file with glowroot binaries")
4745
parser.add_argument("--glowroot-port", metavar="PORT", help="Set glowroot port")
4846

4947

@@ -117,9 +115,7 @@ def start(args):
117115
java_opts=args.java_opts,
118116
postgis_version=args.postgis_version,
119117
enable_postgres_queries_logging=args.enable_postgres_queries_logging,
120-
glowroot=args.glowroot,
121-
glowroot_zip=args.glowroot_zip,
122-
glowroot_port=args.glowroot_port,
118+
glowroot_port=args.glowroot_port
123119
)
124120

125121
if args.detach:

src/d2_docker/config/dhis2-core-entrypoint.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,33 @@ setup_glowroot() {
5757
fi
5858
if [ -d $GLOWROOT_DIR ] ; then
5959
echo '{ "web": { "bindAddress": "0.0.0.0", "port": "4000" }}' > $GLOWROOT_DIR/admin.json
60+
echo '{"transactions":{"slowThresholdMillis":2000,"profilingIntervalMillis":1000,"captureThreadStats":true},
61+
"jvm":{"maskSystemProperties":["*password*","*token*","*access*","*secret*"],"maskMBeanAttributes":["*password*","*token*","*access*","*secret*"]},
62+
"uiDefaults":{"defaultTransactionType":"Web","defaultPercentiles":[50,95,99],"defaultGaugeNames":["java.lang:type=Memory:HeapMemoryUsage.used"]},
63+
"advanced":{"immediatePartialStoreThresholdSeconds":60,"maxTransactionAggregates":500,"maxQueryAggregates":500,"maxServiceCallAggregates":500,
64+
"maxTraceEntriesPerTransaction":2000,"maxProfileSamplesPerTransaction":50000,"mbeanGaugeNotFoundDelaySeconds":60},"gauges":[{"mbeanObjectName":"java.lang:type=Memory",
65+
"mbeanAttributes":[{"name":"HeapMemoryUsage.used"}]},{"mbeanObjectName":"java.lang:type=GarbageCollector,name=*","mbeanAttributes":[{"name":"CollectionCount","counter":true},
66+
{"name":"CollectionTime","counter":true}]},{"mbeanObjectName":"java.lang:type=MemoryPool,name=*","mbeanAttributes":[{"name":"Usage.used"}]},
67+
{"mbeanObjectName":"java.lang:type=OperatingSystem","mbeanAttributes":[{"name":"FreePhysicalMemorySize"},{"name":"ProcessCpuLoad"},{"name":"SystemCpuLoad"}]}],
68+
"plugins":[{"properties":{"stackTraceThresholdMillis":1000},"id":"cassandra"},{"properties":{"stackTraceThresholdMillis":1000},"id":"elasticsearch"},
69+
{"properties":{"sessionUserAttribute":"","captureSessionAttributes":[],"captureRequestParameters":["*"],"maskRequestParameters":["*password*","*token*","*access*","*secret*"],
70+
"captureRequestHeaders":[],"captureResponseHeaders":[],"traceErrorOn4xxResponseCode":false,"captureRequestRemoteAddr":false,"captureRequestRemoteHostname":false,
71+
"captureRequestRemotePort":false,"captureRequestLocalAddr":false,"captureRequestLocalHostname":false,"captureRequestLocalPort":false,"captureRequestServerHostname":false,
72+
"captureRequestServerPort":false},"id":"jakartaservlet"},{"properties":{"captureRequestHeaders":[],"maskRequestHeaders":["Authorization"],"captureRequestRemoteAddr":false,
73+
"captureRequestRemoteHost":false,"captureResponseHeaders":[],"traceErrorOn4xxResponseCode":false},"id":"java-http-server"},{"properties":{"useAltTransactionNaming":false},
74+
"id":"jaxrs"},{"properties":{"captureBindParametersIncludes":[".*"],"captureBindParametersExcludes":[],"captureResultSetNavigate":true,"captureResultSetGet":false,
75+
"captureConnectionPoolLeaks":false,"captureConnectionPoolLeakDetails":false,"captureGetConnection":true,"captureConnectionClose":false,"capturePreparedStatementCreation":false,
76+
"captureStatementClose":false,"captureTransactionLifecycleTraceEntries":false,"captureConnectionLifecycleTraceEntries":false,"stackTraceThresholdMillis":1000},"id":"jdbc"},
77+
{"properties":{"traceErrorOnErrorWithThrowable":true,"traceErrorOnErrorWithoutThrowable":false,"traceErrorOnWarningWithThrowable":false,"traceErrorOnWarningWithoutThrowable":false},
78+
"id":"logger"},{"properties":{"stackTraceThresholdMillis":1000},"id":"mongodb"},{"properties":{"useAltTransactionNaming":false},"id":"play"},{"properties":{"sessionUserAttribute":"",
79+
"captureSessionAttributes":[],"captureRequestParameters":["*"],"maskRequestParameters":["*password*","*token*","*access*","*secret*"],"captureRequestHeaders":[],
80+
"captureResponseHeaders":[],"traceErrorOn4xxResponseCode":false,"captureRequestRemoteAddr":false,"captureRequestRemoteHostname":false,"captureRequestRemotePort":false,
81+
"captureRequestLocalAddr":false,"captureRequestLocalHostname":false,"captureRequestLocalPort":false,"captureRequestServerHostname":false,"captureRequestServerPort":false},
82+
"id":"servlet"},{"properties":{"useAltTransactionNaming":false},"id":"spring"}],"instrumentation":[{"className":"org.hisp.dhis.webapi.controller.event.TrackedEntityInstanceController",
83+
"methodName":"getTrackedEntityInstances","methodParameterTypes":[".."],"order":0,"captureKind":"other","transactionType":"Web","transactionNameTemplate":"/api/trackedEntityInstances: GET"},
84+
{"className":"org.hisp.dhis.tracker.report.DefaultTrackerImportService","methodName":"importTracker","methodParameterTypes":[".."],"order":0,"captureKind":"transaction",
85+
"transactionType":"Web","transactionNameTemplate":"/api/tracker: import","alreadyInTransactionBehavior":"capture-new-transaction","traceEntryMessageTemplate":"{{0}}",
86+
"traceEntryStackThresholdMillis":300,"traceEntryCaptureSelfNested":true,"timerName":"Timer"}]}' > $GLOWROOT_DIR/config.json
6087
chown -R tomcat:tomcat $GLOWROOT_DIR
6188
chmod -R u=rwX,g=rX,o-rwx $GLOWROOT_DIR
6289
echo 'export CATALINA_OPTS="$CATALINA_OPTS -javaagent:/opt/glowroot/glowroot.jar"' > /usr/local/tomcat/bin/setenv.sh

src/d2_docker/docker-compose.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ services:
55
- "com.eyeseetea.image-name=${DHIS2_DATA_IMAGE}"
66
volumes:
77
- home:/DHIS2_home
8-
- ${GLOWROOT_ZIP}:/opt/glowroot.zip
98
- ${DHIS_CONF}:/config/override/dhis2/dhis.conf
109
- ${ROOT_PATH}/config:/config
1110
- data:/data

src/d2_docker/glowroot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ def get_glowroot_zip(command, glowroot_zip, glowroot):
4242

4343
return utils.get_absfile_for_docker_volume(glowroot_path)
4444

45-
def get_port_glowroot(glowroot_port, glowroot_zip, glowroot):
45+
def get_port_glowroot(glowroot_port):
4646
port = glowroot_port if glowroot_port else GLOWROOT_DEFAULT_PORT
47-
return "{}:{}".format(port, GLOWROOT_DEFAULT_PORT) if (glowroot_port or glowroot_zip or glowroot) else None
47+
return "{}:{}".format(port, GLOWROOT_DEFAULT_PORT) if glowroot_port else None

src/d2_docker/utils.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from typing import Optional
1616

1717
import d2_docker
18-
from d2_docker.glowroot import get_glowroot_zip, get_port_glowroot
18+
from d2_docker.glowroot import get_port_glowroot
1919
from .image_name import ImageName
2020

2121
PROJECT_NAME_PREFIX = "d2-docker"
@@ -262,8 +262,6 @@ def run_docker_compose(
262262
tomcat_server=None,
263263
postgis_version=None,
264264
enable_postgres_queries_logging=False,
265-
glowroot=None,
266-
glowroot_zip=None,
267265
glowroot_port=None,
268266
**kwargs,
269267
):
@@ -301,8 +299,7 @@ def run_docker_compose(
301299
# Add ROOT_PATH from environment (required when run inside a docker)
302300
("ROOT_PATH", ROOT_PATH),
303301
("PSQL_ENABLE_QUERY_LOGS", "") if not enable_postgres_queries_logging else None,
304-
("GLOWROOT_PORT", get_port_glowroot(glowroot_port, glowroot_zip, glowroot)),
305-
("GLOWROOT_ZIP", get_glowroot_zip(args, glowroot_zip, glowroot)),
302+
("GLOWROOT_PORT", get_port_glowroot(glowroot_port))
306303
]
307304
env = dict((k, v) for (k, v) in [pair for pair in env_pairs if pair] if v is not None)
308305

0 commit comments

Comments
 (0)