Logging to Alternative Sinks from Docker

We log to graylog to keep a searchable overview. Logging directly with the docker GELF driver resulted in a ton of hard to read messages with metabase, because e.g. every line of a Query or Exception trace that got logged was its own message.

Relevant excerpt of our solution, on the Metabase service in docker-compose :

 1     volumes:
 2       - ./logstash-gelf-1.12.0.jar:/gelf.jar:ro
 3       - ./log4j2.xml:/log4j2.xml:ro
 4     environment:
11       - MB_EMOJI_IN_LOGS="false"
12       - "JAVA_OPTS=-Xms1G -Xmx1G -Dlog4j.configurationFile=file:/log4j2.xml -cp /gelf.jar:/app/metabase.jar metabase.bootstrap; echo"

So, (L.2-3) Mount a log sink jar and the corresponding log4j2.xml into the container. Then (L.12):

  1. (LSet log4j to use the mounted config
  2. Set the Classpath to the alternative log sink jar and metabase itself
  3. Set the same bootstrap class as the META-INF/MANIFEST.MF in the Metabas JAR would
  4. Deactivate the rest of the command line with ; echo [1]

Question for Metabase staff potentially reading this: How robust should this be to changes? E.g., is the bootstrap namespace expected to get renamed at some point?

[1] basically a SQL injection attack, but for a command line (the echo is actually superfluous since this will never get called – exec replaces the process image and never returns, but it’s a bit more robust to changes in invocation structure that way since it will only print should the rest ever get called)

we changed the bootstrap command once, but don't think we'll do it again soon.

My only concern here is that you're doing a lot of work for something that should be simple. What are you trying to achieve so we can prioritize the right issue?

Using alternative logging backends. Don’t really see how that could be made much easier unless you just wanna bundle a lot of frequently used logging backends:

  1. Mounting in the backend and its config is baseline necessary to have it available of course
  2. Changing the commandline this way is necessary because Java doesn’t take additional -cp when using -jar (which otherwise is nice & convenient)

So I really have no complaints here that this did some extra doing; it’s not an expected central OOTB use-case IMO. I just wrote it up because I have a lot more JDK/JRE experience than many others will so what was obvious to me might not be obvious but still useful to some other users.