-
Notifications
You must be signed in to change notification settings - Fork 6
Add metabase stack ⚠️ (manual action required) #1093
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
YuryHrytsuk
merged 8 commits into
ITISFoundation:main
from
YuryHrytsuk:add-metabase-stack
Jun 30, 2025
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
63c4ea7
Update postgres exporter
YuryHrytsuk 49f5721
Merge remote-tracking branch 'upstream/main' into add-metabase-stack
YuryHrytsuk 4a79721
Add metabase stack
YuryHrytsuk df61d49
Merge remote-tracking branch 'upstream/main' into add-metabase-stack
YuryHrytsuk 4e0817b
Add metabase stack
YuryHrytsuk 7e30b6f
Add replicas and fix browser errors
YuryHrytsuk e892209
Reduce logging noise
YuryHrytsuk 21c1950
Remove comments
YuryHrytsuk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| STACK_NAME = $(notdir $(shell pwd)) | ||
| TEMP_COMPOSE=.stack.${STACK_NAME}.yaml | ||
| REPO_BASE_DIR := $(shell git rev-parse --show-toplevel) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| configure_metabase.sql | ||
| docker-compose.yml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| REPO_BASE_DIR := $(shell git rev-parse --show-toplevel) | ||
|
|
||
| include ${REPO_BASE_DIR}/scripts/common.Makefile | ||
| include ${REPO_BASE_DIR}/scripts/common-services.Makefile | ||
|
|
||
| .PHONY: up | ||
| up: ${TEMP_COMPOSE} ## Deploys metabase stack | ||
|
|
||
| ${TEMP_COMPOSE}: docker-compose.yml .env | ||
| @${REPO_BASE_DIR}/scripts/docker-stack-config.bash -e .env $< > $@ | ||
|
|
||
| docker-compose.yml: docker-compose.yml.j2 .env .venv | ||
| @$(call jinja, $<, .env, $@) | ||
|
|
||
| configure_metabase.sql: .env | ||
| @set -o allexport; source $<; set +o allexport; \ | ||
| envsubst < [email protected] > $@ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| CREATE USER ${METABASE_POSTGRES_USER} WITH PASSWORD '${METABASE_POSTGRES_PASSWORD}'; | ||
|
|
||
| -- relies on readonly role aldready existing in the database | ||
| GRANT ${POSTGRES_DB}_readonly TO ${METABASE_POSTGRES_USER}; | ||
|
|
||
| CREATE DATABASE ${METABASE_POSTGRES_DB} | ||
| WITH OWNER ${METABASE_POSTGRES_USER}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| # https://www.metabase.com/docs/v0.54/installation-and-operation/running-metabase-on-docker | ||
|
|
||
| # https://www.metabase.com/docs/v0.54/installation-and-operation/running-metabase-on-docker#example-docker-compose-yaml-file | ||
| services: | ||
| metabase: | ||
| image: metabase/metabase:v0.54.13.3 | ||
| networks: | ||
| - public | ||
| - monitored | ||
| environment: | ||
| - MB_HEALTH_CHECK_LOGGING_ENABLED=false | ||
| # Avoid: site URL basename "/" does not match the actual basename | ||
| # https://www.metabase.com/docs/latest/configuring-metabase/environment-variables#mb_site_url | ||
| - MB_SITE_URL=https://${ADMIN_DOMAIN}/metabase/ | ||
| # Metabase logs: https://www.metabase.com/docs/v0.54/configuring-metabase/log-configuration | ||
| - JAVA_OPTS=-Dlog4j.configurationFile=file:/etc/metabase/log4j2.xml | ||
| # https://www.metabase.com/docs/v0.54/installation-and-operation/configuring-application-database | ||
| - MB_DB_TYPE=postgres | ||
| - MB_DB_DBNAME=metabase | ||
| - MB_DB_HOST=${POSTGRES_HOST} | ||
| - MB_DB_PORT=${POSTGRES_PORT} | ||
| - MB_DB_USER=${METABASE_POSTGRES_USER} | ||
| - MB_DB_PASS=${METABASE_POSTGRES_PASSWORD} | ||
| # https://www.metabase.com/docs/v0.54/installation-and-operation/running-metabase-on-docker#setting-the-java-timezone | ||
| - JAVA_TIMEZONE=UTC | ||
| # https://www.metabase.com/docs/latest/installation-and-operation/observability-with-prometheus | ||
| - MB_PROMETHEUS_SERVER_PORT=9191 | ||
| deploy: | ||
| # https://www.metabase.com/learn/metabase-basics/administration/administration-and-operation/metabase-at-scale | ||
| replicas: ${METABASE_REPLICAS} | ||
| update_config: | ||
| parallelism: 1 | ||
| order: start-first | ||
| failure_action: rollback | ||
| delay: 30s | ||
| placement: | ||
| constraints: | ||
| - node.labels.ops==true | ||
| labels: | ||
| # prometheus only keeps jobs with `prometheus-job` label | ||
| - prometheus-job=metabase | ||
| # Set in `MB_PROMETHEUS_SERVER_PORT` environment variable | ||
| - prometheus-port=9191 | ||
| # TODO: add prometheus metrics | ||
| - traefik.enable=true | ||
| - traefik.docker.network=${PUBLIC_NETWORK} | ||
| # router | ||
| - traefik.http.routers.metabase.rule=Host(`${ADMIN_DOMAIN}`) && PathPrefix(`/metabase`) | ||
| - traefik.http.routers.metabase.entrypoints=https | ||
| - traefik.http.routers.metabase.tls=true | ||
| - traefik.http.middlewares.metabase_stripprefixregex.stripprefixregex.regex=^/metabase | ||
| - traefik.http.routers.metabase.middlewares=ops_whitelist_ips@swarm, ops_gzip@swarm, ops_auth@swarm, metabase_stripprefixregex | ||
| # service | ||
| - traefik.http.services.metabase.loadbalancer.server.port=3000 | ||
| - traefik.http.services.metabase.loadbalancer.healthcheck.path=/api/health | ||
| - traefik.http.services.metabase.loadbalancer.healthcheck.interval=10s | ||
| # GET method sometimes fails (`Request canceled before finishing`) log | ||
| # This does not happen with HEAD method. Official healthcheck documentation | ||
| # defines HEAD as well | ||
| - traefik.http.services.metabase.loadbalancer.healthcheck.method=HEAD | ||
| - traefik.http.services.metabase.loadbalancer.healthcheck.timeout=1s | ||
|
|
||
| # https://www.metabase.com/learn/metabase-basics/administration/administration-and-operation/metabase-in-production | ||
| resources: | ||
| limits: | ||
| memory: 2G | ||
| cpus: "2.0" | ||
| reservations: | ||
| memory: 1G | ||
| cpus: "1.0" | ||
| healthcheck: | ||
| test: curl --fail -I http://localhost:3000/api/health || exit 1 | ||
| interval: 15s | ||
| timeout: 5s | ||
| retries: 5 | ||
| configs: | ||
| - source: logging_configuration | ||
| target: /etc/metabase/log4j2.xml | ||
|
|
||
| configs: | ||
| logging_configuration: | ||
| file: ./logging_configuration.xml | ||
| name: {{ STACK_NAME }}_logging_configuration_{{ "./logging_configuration.xml" | sha256file | substring(0,10) }} | ||
|
|
||
| networks: | ||
| public: | ||
| external: true | ||
| name: ${PUBLIC_NETWORK} | ||
| monitored: | ||
| name: ${MONITORED_NETWORK} | ||
| external: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <!-- Original file: https://github.com/metabase/metabase/blob/v0.54.14.3/resources/log4j2.xml --> | ||
|
|
||
| <Configuration> | ||
| <Appenders> | ||
| <Console name="STDOUT" target="SYSTEM_OUT" follow="true"> | ||
| <PatternLayout pattern="%date %level %logger{2} :: %message %notEmpty{%X}%n%throwable"> | ||
| <replace regex=":basic-auth \\[.*\\]" replacement=":basic-auth [redacted]"/> | ||
| </PatternLayout> | ||
| </Console> | ||
| </Appenders> | ||
|
|
||
| <Loggers> | ||
| <Logger name="com.mchange" level="ERROR"/> | ||
| <Logger name="liquibase" level="INFO"/> | ||
| <Logger name="metabase" level="INFO"/> | ||
| <Logger name="metabase-enterprise" level="INFO"/> | ||
| <Logger name="metabase.metabot" level="INFO"/> | ||
| <Logger name="metabase.plugins" level="INFO"/> | ||
| <Logger name="metabase.query-processor.async" level="INFO"/> | ||
| <Logger name="metabase.server.middleware" level="INFO"/> | ||
| <Logger name="org.quartz" level="INFO"/> | ||
| <Logger name="net.snowflake.client.jdbc.SnowflakeConnectString" level="ERROR"/> | ||
| <Logger name="net.snowflake.client.core.SessionUtil" level="FATAL"/> | ||
|
|
||
| <Root level="WARN"> | ||
| <AppenderRef ref="STDOUT"/> | ||
| </Root> | ||
| </Loggers> | ||
| </Configuration> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| STACK_NAME=${STACK_NAME} | ||
|
|
||
| METABASE_REPLICAS=${METABASE_REPLICAS} | ||
|
|
||
| ADMIN_DOMAIN=${ADMIN_DOMAIN} | ||
|
|
||
| PUBLIC_NETWORK=${PUBLIC_NETWORK} | ||
| MONITORED_NETWORK=${MONITORED_NETWORK} | ||
|
|
||
| POSTGRES_HOST=${POSTGRES_HOST} | ||
| POSTGRES_PORT=${POSTGRES_PORT} | ||
| POSTGRES_DB=${POSTGRES_DB} | ||
|
|
||
| METABASE_POSTGRES_USER=${METABASE_POSTGRES_USER} | ||
| METABASE_POSTGRES_PASSWORD=${METABASE_POSTGRES_PASSWORD} | ||
| METABASE_POSTGRES_DB=${METABASE_POSTGRES_DB} | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.