### Install Dependencies and Run Development Server Source: https://github.com/trinodb/trino-gateway/blob/main/webapp/README.md Use these commands to install project dependencies and start the development server. ```bash pnpm install pnpm run dev ``` -------------------------------- ### Start Trino Gateway and PostgreSQL Source: https://github.com/trinodb/trino-gateway/blob/main/docs/quickstart.md This script downloads the Trino Gateway JAR, copies the configuration file, starts a PostgreSQL database in Docker if not running, and then launches the Trino Gateway server. ```shell #!/usr/bin/env sh VERSION=19 BASE_URL="https://repo1.maven.org/maven2/io/trino/gateway/gateway-ha" JAR_FILE="gateway-ha-$VERSION-jar-with-dependencies.jar" GATEWAY_JAR="gateway-ha.jar" CONFIG_YAML="config.yaml" # Copy necessary files copy_files() { if [[ ! -f "$GATEWAY_JAR" ]]; then echo "Fetching $GATEWAY_JAR version $VERSION" curl -O "$BASE_URL/$VERSION/$JAR_FILE" mv "$JAR_FILE" "$GATEWAY_JAR" fi [[ ! -f "$CONFIG_YAML" ]] && cp ../docs/$CONFIG_YAML . } # Start PostgreSQL database if not running start_postgres_db() { if ! docker ps --format '{{.Names}}' | grep -q '^local-postgres$'; then echo "Starting PostgreSQL database container" PGPASSWORD=mysecretpassword docker run -v "$PWD/$POSTGRES_SQL:/tmp/$POSTGRES_SQL" \ --name local-postgres -p 5432:5432 -e POSTGRES_PASSWORD=$PGPASSWORD -d postgres sleep 5 docker exec local-postgres psql -U postgres -h localhost -c 'CREATE DATABASE gateway' fi } # Main execution flow copy_files start_postgres_db # Start Trino Gateway server echo "Starting Trino Gateway server..." java -Xmx1g -jar ./$GATEWAY_JAR ./$CONFIG_YAML ``` -------------------------------- ### Install MkDocs Material Source: https://github.com/trinodb/trino-gateway/blob/main/docs/docs.md Installs the MkDocs Material theme and its dependencies using pipx. Ensure Python and pipx are installed first. ```shell pipx install --include-deps mkdocs-material ``` -------------------------------- ### Install Trino Gateway Helm Chart Source: https://github.com/trinodb/trino-gateway/blob/main/docs/installation.md Deploy Trino Gateway using the Helm chart with a values override file. ```shell helm install tg --values values-override.yaml trino/trino-gateway ``` -------------------------------- ### Build Web Application Separately Source: https://github.com/trinodb/trino-gateway/blob/main/webapp/README.md Navigate to the webapp directory and run these commands to install dependencies and build the web application independently. ```bash cd ./webapp pnpm install pnpm run build ``` -------------------------------- ### Start Trino Gateway with Docker Compose Source: https://github.com/trinodb/trino-gateway/blob/main/docs/docker.md Starts Trino Gateway and its PostgreSQL backend database using Docker Compose. The --wait flag ensures the health check is successful before proceeding. ```bash docker compose up --wait ``` -------------------------------- ### Serve MkDocs Site Locally Source: https://github.com/trinodb/trino-gateway/blob/main/docs/docs.md Starts the local development server for the documentation site. Navigate to the project root and run this command. Access the site at http://127.0.0.1:8000/ ```shell cd trino-gateway mkdocs serve ``` -------------------------------- ### Trino Gateway Configuration Example Source: https://github.com/trinodb/trino-gateway/blob/main/docs/routers.md This YAML configuration demonstrates how to set up backend state, cluster statistics monitoring, and load routing modules for Trino Gateway. ```yaml backendState: username: password: ssl: xForwardedProtoHeader: clusterStatsConfiguration: monitorType: UI_API modules: - io.trino.gateway.ha.module.QueryCountBasedRouterProvider ``` -------------------------------- ### Rule Priority Example Source: https://github.com/trinodb/trino-gateway/blob/main/docs/routing-rules.md Demonstrates how to use rule priorities to control the order of rule execution. Lower priority values are executed earlier. This example routes 'airflow' queries to 'etl' and specific 'special' labeled queries to 'etl-special'. ```yaml --- name: "airflow" description: "if query from airflow, route to etl group" priority: 0 condition: 'request.getHeader("X-Trino-Source") == "airflow"' actions: - 'result.put("routingGroup", "etl")' --- name: "airflow special" description: "if query from airflow with special label, route to etl-special group" priority: 1 condition: 'request.getHeader("X-Trino-Source") == "airflow" && request.getHeader("X-Trino-Client-Tags") contains "label=special"' actions: - 'result.put("routingGroup", "etl-special")' ``` -------------------------------- ### Default Trino Gateway Startup Command Source: https://github.com/trinodb/trino-gateway/blob/main/docs/installation.md The default command used to start the Trino Gateway process in a containerized environment. ```shell java -XX:MinRAMPercentage=80.0 -XX:MaxRAMPercentage=80.0 -jar /usr/lib/trino-gateway/gateway-ha-jar-with-dependencies.jar /etc/trino-gateway/config.yaml ``` -------------------------------- ### Run Trino Gateway JAR Source: https://github.com/trinodb/trino-gateway/blob/main/docs/installation.md Start Trino Gateway using its JAR file with specified JVM memory settings. ```shell java -XX:MinRAMPercentage=50 -XX:MaxRAMPercentage=80 \ -jar gateway-ha.jar config.yaml ``` -------------------------------- ### Build Trino Gateway Locally Source: https://github.com/trinodb/trino-gateway/blob/main/docs/development.md Build the trino-gateway project using Maven. Ensure Java 25+ is installed. VM options for compilation and testing are configured in .mvn/jvm.config. ```shell ./mvnw clean install ``` -------------------------------- ### Configure Data Store and Query History Source: https://github.com/trinodb/trino-gateway/blob/main/docs/installation.md Example configuration for the data store, showing how to disable automatic database migrations and query history recording. This is useful for reducing database load when history tracking is not needed. ```yaml dataStore: jdbcUrl: jdbc:postgresql://postgres:5432/trino_gateway_db user: USER password: PASSWORD driver: org.postgresql.Driver queryHistoryHoursRetention: 24 runMigrationsEnabled: false queryHistoryEnabled: true # Set to false to disable query history recording ``` -------------------------------- ### Add Trino Backends to Gateway Source: https://github.com/trinodb/trino-gateway/blob/main/docs/quickstart.md This script starts two Trino servers in Docker and then adds them as backends to the Trino Gateway server using the Gateway's API. ```shell #!/usr/bin/env sh TRINO_IMAGE="trinodb/trino" JAVA_OPTS="-Dhttp-server.process-forwarded=true" # Start Trino servers for i in 1 2; do PORT=808$i if ! lsof -i:$PORT > /dev/null; then docker run --name trino$i -d -p $PORT:8080 \ -e JAVA_TOOL_OPTIONS="$JAVA_OPTS" $TRINO_IMAGE else echo "Warning: Port $PORT is already in use. Skipping trino$i." fi done # Add Trino servers as Gateway backends add_backend() { curl -H "Content-Type: application/json" -X POST \ localhost:8080/gateway/backend/modify/add \ -d "{ \"name\": \"$1\", \"proxyTo\": \"http://localhost:808$2\", \"active\": true, \"routingGroup\": \"adhoc\" }" } # Adding Trino servers as backends for i in 1 2; do add_backend "trino$i" "$i" done ``` -------------------------------- ### External Routing Service Response Example Source: https://github.com/trinodb/trino-gateway/blob/main/docs/routing-rules.md An example JSON response from an external routing service. It specifies the routing group, any errors encountered, and optional external headers to be added or modified. ```json { "routingGroup": "test-group", "errors": [ "Error1", "Error2", "Error3" ], "externalHeaders": { "x-trino-client-tags": "['etl']", "x-trino-session": "query_max_memory=50GB,optimize_metadata_queries=false" } } ``` -------------------------------- ### Run MkDocs with Docker Source: https://github.com/trinodb/trino-gateway/blob/main/docs/docs.md Runs the MkDocs Material documentation build process inside a Docker container. This avoids local installation of dependencies. Mounts the current directory to /docs and maps port 8000. ```shell docker run --rm -it -v ${PWD}:/docs -p8000:8000 squidfunk/mkdocs-material ``` -------------------------------- ### Atomic Rule Example Source: https://github.com/trinodb/trino-gateway/blob/main/docs/routing-rules.md An example of an atomic routing rule that routes queries from 'airflow' to the 'etl' group. This rule is designed to be specific enough to avoid conflicts with other rules. ```yaml --- name: "airflow" description: "if query from airflow, route to etl group" condition: 'request.getHeader("X-Trino-Source") == "airflow" && request.getHeader("X-Trino-Client-Tags") == null' actions: - 'result.put("routingGroup", "etl")' --- ``` -------------------------------- ### Passing State Between Rules Source: https://github.com/trinodb/trino-gateway/blob/main/docs/routing-rules.md Illustrates how to use the `state` object to pass information between rules. This example initializes a `HashSet` to track triggered rules and uses it to conditionally apply routing. ```yaml --- name: "initialize state" description: "Add a set to the state map to track rules that have evaluated to true" priority: 0 condition: "true" actions: - | state.put("triggeredRules",new HashSet()) # MVEL does not support type parameters! HashSet() would result in an error. --- name: "airflow" description: "if query from airflow, route to etl group" priority: 1 condition: | request.getHeader("X-Trino-Source") == "airflow" actions: - | result.put("routingGroup", "etl") - | state.get("triggeredRules").add("airflow") --- name: "airflow special" description: "if query from airflow with special label, route to etl-special group" priority: 2 condition: | state.get("triggeredRules").contains("airflow") && request.getHeader("X-Trino-Client-Tags") contains "label=special" actions: - | result.put("routingGroup", "etl-special") ``` -------------------------------- ### MVEL Flow Control with If Statements Source: https://github.com/trinodb/trino-gateway/blob/main/docs/routing-rules.md Shows how to implement conditional logic using MVEL's `if`, `else if`, and `else` statements within a routing rule. This example routes 'airflow' queries based on different client tags. ```yaml --- name: "airflow rules" description: "if query from airflow" condition: "request.getHeader(\"X-Trino-Source\") == \"airflow\"" actions: - "if (request.getHeader(\"X-Trino-Client-Tags\") contains \"label=foo\") { result.put(\"routingGroup\", \"etl-foo\") } else if (request.getHeader(\"X-Trino-Client-Tags\") contains \"label=bar\") { result.put(\"routingGroup\", \"etl-bar\") } else { result.put(\"routingGroup\", \"etl\") }" ``` -------------------------------- ### List all Trino clusters Source: https://github.com/trinodb/trino-gateway/blob/main/docs/gateway-api.md Retrieves a JSON array of all configured Trino clusters. This command is useful for auditing and understanding the current gateway setup. ```shell curl -X GET http://localhost:8080/gateway/backend/all ``` ```json [ { "name": "trino-1", "proxyTo": "http://localhost:8081", "active": true, "routingGroup": "adhoc", "externalUrl": "http://localhost:8081" }, { "name": "trino-2", "proxyTo": "http://localhost:8082", "active": true, "routingGroup": "adhoc", "externalUrl": "http://localhost:8082" }, { "name": "trino-3", "proxyTo": "http://localhost:8083", "active": true, "routingGroup": "adhoc", "externalUrl": "http://localhost:8084" } ] ``` -------------------------------- ### Configure File-Based Access Control for JMX Source: https://github.com/trinodb/trino-gateway/blob/main/docs/installation.md Allow JMX endpoint access by adding rules to your file-based access control configuration. This example grants read-only access to the 'system' catalog for a 'user' and read access to system information. ```json { "catalogs": [ { "user": "user", "catalog": "system", "allow": "read-only" } ], "system_information": [ { "user": "user", "allow": ["read"] } ] } ``` -------------------------------- ### Build Project Source: https://github.com/trinodb/trino-gateway/blob/main/webapp/README.md Command to build the project for deployment. ```bash pnpm run build ``` -------------------------------- ### Build Trino Gateway Docker Image for All Architectures Source: https://github.com/trinodb/trino-gateway/blob/main/docs/docker.md Builds Docker images for all valid processor architectures (amd64, arm64, ppc64le) by default. The script prints the ID and tags the built image. ```bash ./build.sh ``` -------------------------------- ### Display Docker Images Source: https://github.com/trinodb/trino-gateway/blob/main/docs/docker.md Lists all Docker images on the system, including their repository, tag, image ID, creation date, and size. This is useful for verifying built images. ```bash $ docker images REPOSITORY TAG IMAGE ID CREATED SIZE trino-gateway 6-SNAPSHOT-ppc64le a72b750d2745 33 seconds ago 547MB trino-gateway 6-SNAPSHOT-arm64 bc5e8b0db63c 35 seconds ago 523MB trino-gateway 6-SNAPSHOT-amd64 6c066fa5b0c5 36 seconds ago 518MB ... ``` -------------------------------- ### Define Datastore Configuration Source: https://github.com/trinodb/trino-gateway/blob/main/docs/installation.md Create a YAML file to configure the datastore connection details for Trino Gateway. ```shell cat << EOF > datastore.yaml dataStore: jdbcUrl: jdbc:postgresql://yourdatabasehost:5432/gateway user: postgres password: secretpassword driver: org.postgresql.Driver EOF ``` -------------------------------- ### Configure Backend Authentication and SSL Source: https://github.com/trinodb/trino-gateway/blob/main/docs/installation.md Configure username, password, SSL, and xForwardedProtoHeader for health checks. These settings must be valid across all backends. ```yaml backendState: username: "user" password: "password" ssl: xForwardedProtoHeader: ``` -------------------------------- ### Add HashSet to State Variable Source: https://github.com/trinodb/trino-gateway/blob/main/docs/routing-rules.md When using parametrized types in MVEL actions, exclude type parameters. This example shows how to add a HashSet to the state variable, equivalent to `new HashSet()`. ```java actions: - | state.put("triggeredRules",new HashSet()) ``` -------------------------------- ### Define Routing Rules with Conditions and Actions Source: https://github.com/trinodb/trino-gateway/blob/main/docs/routing-rules.md Configure routing rules in a multi-document YAML file. Each rule has a name, description, condition, and a list of actions. If the condition evaluates to true, the actions are executed, typically to set a routing group. ```yaml --- name: "airflow" description: "if query from airflow, route to etl group" condition: 'request.getHeader("X-Trino-Source") == "airflow"' actions: - 'result.put("routingGroup", "etl")' --- name: "airflow special" description: "if query from airflow with special label, route to etl-special group" condition: 'request.getHeader("X-Trino-Source") == "airflow" && request.getHeader("X-Trino-Client-Tags") contains "label=special"' actions: - 'result.put("routingGroup", "etl-special")' ``` -------------------------------- ### Create ConfigMap for Routing Rules Source: https://github.com/trinodb/trino-gateway/blob/main/docs/installation.md Create a Kubernetes ConfigMap to store routing rules defined in a YAML file. ```shell kubectl create cm routing-rules --from-file your-routing-rules.yaml ``` -------------------------------- ### Update JVM Startup Arguments Source: https://github.com/trinodb/trino-gateway/blob/main/docs/migration-to-airlift.md Remove the `server` argument from the JVM startup command. ```bash java -jar gateway-ha.jar server config.yaml ``` ```bash java -jar gateway-ha.jar config.yaml ``` -------------------------------- ### Update routing rules Source: https://github.com/trinodb/trino-gateway/blob/main/docs/gateway-api.md Programmatically updates routing rules. Requires the `ADMIN` role and a writeable file for storage with `rulesType: FILE`. Ensure shared storage with file locking is used for multi-replica setups to prevent synchronization issues. ```shell curl -X POST http://localhost:8080/webapp/updateRoutingRules \ -H 'Content-Type: application/json' \ -d '{ "name": "trino-rule", "description": "updated rule description", "priority": 0, "actions": ["updated action"], "condition": "updated condition" }' ``` -------------------------------- ### Build Trino Gateway Docker Image for Specific Architecture Source: https://github.com/trinodb/trino-gateway/blob/main/docs/docker.md Builds a Docker image for a specific processor architecture (e.g., arm64). Ensure you have run the Maven build in the project root first. ```bash ./build.sh -a arm64 ``` -------------------------------- ### Update TLS Configuration Source: https://github.com/trinodb/trino-gateway/blob/main/docs/migration-to-airlift.md Migrate TLS settings from `ssl`, `keystorePath`, and `keystorePass` to `http-server.https.*` properties. ```yaml requestRouter: ssl: true port: 8080 name: trinoRouter historySize: 1000 keystorePath: keystorePass: server: applicationConnectors: - type: https port: 8090 keyStorePath: keyStorePassword: useForwardedHeaders: true adminConnectors: - type: https port: 8091 keyStorePath: keyStorePassword: useForwardedHeaders: true ``` ```yaml serverConfig: http-server.http.enabled: false http-server.https.enabled: true http-server.https.port: 8080 http-server.https.keystore.path: http-server.https.keystore.key: ``` -------------------------------- ### Build Trino Gateway Docker Image for a Released Version Source: https://github.com/trinodb/trino-gateway/blob/main/docs/docker.md Builds a Docker image for a specific, already released version of Trino Gateway. The build script automatically downloads required artifacts. ```bash ./build.sh -r 4 ``` -------------------------------- ### Configure JDBC Monitor Explicit Prepare Option Source: https://github.com/trinodb/trino-gateway/blob/main/docs/installation.md Set 'explicitPrepare' to true for JDBC health checks if using Trino versions older than 431 to ensure compatibility. ```yaml monitor: explicitPrepare: true ``` -------------------------------- ### Add Trino Helm Chart Repository Source: https://github.com/trinodb/trino-gateway/blob/main/docs/installation.md Configure Helm to use the Trino chart repository for deploying Trino Gateway. ```shell helm repo add trino https://trinodb.github.io/charts/ ``` -------------------------------- ### Configure OAuth/OpenIDConnect Authentication Source: https://github.com/trinodb/trino-gateway/blob/main/docs/security.md Set up OAuth/OpenIDConnect authentication by providing issuer, client details, endpoints, and user/scope fields. ```yaml authentication: defaultType: "oauth" oauth: issuer: clientId: clientSecret: tokenEndpoint: authorizationEndpoint: jwkEndpoint: redirectUrl: redirectWebUrl: userIdField: scopes: - s1 - s2 - s3 ``` -------------------------------- ### Run Trino Gateway JAR Locally Source: https://github.com/trinodb/trino-gateway/blob/main/docs/development.md Execute the Trino Gateway JAR file after building it. This requires updating the configuration file 'config.yaml' with your MySQL database information. ```shell cd gateway-ha/target/ java -jar gateway-ha-{{VERSION}}-jar-with-dependencies.jar ../config.yaml ``` -------------------------------- ### Configure Logging Path Source: https://github.com/trinodb/trino-gateway/blob/main/docs/migration-to-airlift.md Specify the path to the `log.properties` file directly in the `serverConfig`. ```yaml logging: type: external ``` ```yaml serverConfig: log.levels-file: gateway-ha/etc/log.properties ``` -------------------------------- ### Run Trino Gateway in IDE Source: https://github.com/trinodb/trino-gateway/blob/main/docs/development.md Execute the main class of Trino Gateway for development purposes. This command can be run directly from your IDE. ```shell ./mvnw test-compile exec:java -pl gateway-ha -Dexec.classpathScope=test -Dexec.mainClass="io.trino.gateway.TrinoGatewayRunner" ``` -------------------------------- ### Configure Form Authentication with Self-Signed Key Pair Source: https://github.com/trinodb/trino-gateway/blob/main/docs/security.md Set up form authentication using a self-signed RSA key pair for signing credentials. Specify paths to the private and public keys. ```yaml authentication: defaultType: "form" form: selfSignKeyPair: privateKeyRsa: publicKeyRsa: ``` -------------------------------- ### LDAP Configuration Parameters Source: https://github.com/trinodb/trino-gateway/blob/main/docs/security.md Details for connecting to and authenticating with an LDAP server. Ensure secure connectivity by configuring trust store details if using TLS/SSL. ```yaml ldapHost: '' ldapPort: useTls: useSsl: ldapAdminBindDn: <> ldapUserBaseDn: <> ldapUserSearch: <> ldapGroupMemberAttribute: <> ldapAdminPassword: <> ldapTrustStorePath: ldapTrustStorePassword: '' poolMaxIdle: 8 poolMaxTotal: 8 poolMinIdle: 0 poolTestOnBorrow: true ``` -------------------------------- ### Configure Additional Statement Paths Source: https://github.com/trinodb/trino-gateway/blob/main/docs/installation.md Treat additional experimental or commercial Trino endpoints equivalently to `/v1/statement` by listing them under `additionalStatementPaths`. Paths must be absolute and unique. ```yaml additionalStatementPaths: - '/ui/api/insights/ide/statement' - '/v2/statement' ``` -------------------------------- ### Inspect Trino Gateway Logs Source: https://github.com/trinodb/trino-gateway/blob/main/docs/docker.md View the logs for the Trino Gateway container to monitor progress and troubleshoot issues. ```bash docker compose logs trino-gateway ``` -------------------------------- ### Set Custom Base Image for Docker Build Source: https://github.com/trinodb/trino-gateway/blob/main/docs/docker.md Set the TRINO_GATEWAY_BASE_IMAGE environment variable to specify a custom base image for building the Trino Gateway Docker image. ```bash export TRINO_GATEWAY_BASE_IMAGE= ./build.sh ``` -------------------------------- ### Configure METRICS Monitor Minimum and Maximum Values Source: https://github.com/trinodb/trino-gateway/blob/main/docs/installation.md Define minimum and maximum acceptable values for specific metrics to determine cluster health. This overwrites default configurations. ```yaml monitor: metricMinimumValues: trino_metadata_name_DiscoveryNodeManager_ActiveNodeCount: 1 metricMaximumValues: io_airlift_stats_name_GcMonitor_MajorGc_FiveMinutes_count: 2 ``` -------------------------------- ### Create Kubernetes Secret for Datastore Source: https://github.com/trinodb/trino-gateway/blob/main/docs/installation.md Create a Kubernetes secret from the datastore configuration file and apply it. ```shell kubectl create secret generic datastore-yaml --from-file datastore.yaml --dry-run=client -o yaml | kubectl apply -f - ``` -------------------------------- ### Configure Monitor Task Delay Source: https://github.com/trinodb/trino-gateway/blob/main/docs/operation.md Configure the interval at which the router operates by setting `taskDelay` under the `monitor` section. The default interval is 1 minute. ```yaml monitor: taskDelay: 1m ``` -------------------------------- ### Configure Form Authentication with LDAP Source: https://github.com/trinodb/trino-gateway/blob/main/docs/security.md Enable form authentication using LDAP by providing the LDAP configuration path and a self-signed RSA key pair. ```yaml authentication: defaultType: "form" form: ldapConfigPath: selfSignKeyPair: privateKeyRsa: publicKeyRsa: ``` -------------------------------- ### Set Trino Gateway Image for AMD64-based Machines Source: https://github.com/trinodb/trino-gateway/blob/main/docs/docker.md Export the TRINO_GATEWAY_IMAGE environment variable to use a locally-built Trino Gateway image on an AMD64-based machine. ```shell export TRINO_GATEWAY_IMAGE="trino-gateway:6-SNAPSHOT-amd64" ``` -------------------------------- ### Set Trino Gateway Image for ARM-based Machines Source: https://github.com/trinodb/trino-gateway/blob/main/docs/docker.md Export the TRINO_GATEWAY_IMAGE environment variable to use a locally-built Trino Gateway image on an ARM-based machine. ```shell export TRINO_GATEWAY_IMAGE="trino-gateway:6-SNAPSHOT-arm64" ``` -------------------------------- ### Enable TLS for Trino Gateway Source: https://github.com/trinodb/trino-gateway/blob/main/docs/security.md Configure Trino Gateway to use TLS for client connections by specifying the port and keystore details. ```yaml serverConfig: http-server.http.enabled: false http-server.https.enabled: true http-server.https.port: 8443 http-server.https.keystore.path: certificate.pem http-server.https.keystore.key: changeme ``` -------------------------------- ### Configure Proxying Additional Paths Source: https://github.com/trinodb/trino-gateway/blob/main/docs/installation.md Add extra paths to be proxied by Trino Gateway using regexes in the `extraWhitelistPaths` configuration. Ensure URIs exactly match the provided regexes. ```yaml extraWhitelistPaths: - '/ui/insights' - '/api/v1/biac' - '/api/v1/dataProduct' - '/api/v1/dataproduct' - '/api/v2/.*' - '/ext/faster' ``` -------------------------------- ### Configure Preset Users for Form Authentication Source: https://github.com/trinodb/trino-gateway/blob/main/docs/security.md Define users with passwords and privileges for form-based authentication. Privileges can be ADMIN, USER, or API. ```yaml presetUsers: user1: password: privileges: ADMIN_USER user2: password: privileges: API ``` -------------------------------- ### Configure Backend Authentication for JMX Source: https://github.com/trinodb/trino-gateway/blob/main/docs/installation.md Ensure a username and password are configured for backend clusters to authenticate against the JMX endpoint. The credentials must be consistent across all backend clusters and have 'read' rights on the 'system_information'. ```yaml backendState: username: "user" password: "password" ``` -------------------------------- ### Configure Authorization Roles Source: https://github.com/trinodb/trino-gateway/blob/main/docs/security.md Define roles like admin, user, and api using regex patterns. Specify the path to the LDAP configuration file if LDAP authorization is used. ```yaml authorization: admin: (.*)ADMIN(.*) user: (.*)USER(.*) api: (.*)API(.*) ldapConfigPath: '' ``` -------------------------------- ### Enable Query Count Based Router Source: https://github.com/trinodb/trino-gateway/blob/main/docs/operation.md Enable the QueryCountBasedRouter to route queries to the least loaded cluster. Add the module name to the `modules` section of the config file. ```yaml modules: - io.trino.gateway.ha.module.QueryCountBasedRouterProvider ``` -------------------------------- ### Configure INFO_API Monitor Timeouts Source: https://github.com/trinodb/trino-gateway/blob/main/docs/installation.md Define connection, request, and idle timeouts for the INFO_API health check monitor. Retries can also be configured. ```yaml monitor: connectTimeoutSeconds: 5 requestTimeoutSeconds: 10 idleTimeoutSeconds: 1 retries: 1 ``` -------------------------------- ### Pull Docker Image Source: https://github.com/trinodb/trino-gateway/blob/main/docs/development.md Command to pull the Trino Gateway container image for verification. ```shell docker pull trinodb/trino-gateway:17 ``` -------------------------------- ### Add Plugins to MkDocs Material Source: https://github.com/trinodb/trino-gateway/blob/main/docs/docs.md Injects the 'cairosvg' plugin into the MkDocs Material virtual environment. This is necessary for certain features like SVG rendering. ```shell pipx inject --include-deps mkdocs-material cairosvg ``` -------------------------------- ### Enabling and Configuring Routing Rules Engine Source: https://github.com/trinodb/trino-gateway/blob/main/docs/routing-rules.md Enables the routing rules engine and specifies its type (FILE or EXTERNAL) and configuration path or external service URL. The rules file refresh period can also be configured. ```yaml routingRules: rulesEngineEnabled: true rulesType: FILE rulesConfigPath: "app/config/routing_rules.yml" # replace with actual path to your rules config file rulesExternalConfiguration: urlPath: https://router.example.com/gateway-rules # replace with your own API path excludeHeaders: - 'Authorization' - 'Accept-Encoding' propagateErrors: false ``` -------------------------------- ### Prometheus Monitoring Configuration Source: https://github.com/trinodb/trino-gateway/blob/main/docs/operation.md Configure Prometheus to scrape metrics from the Trino Gateway's `/metrics` endpoint. This allows for monitoring Trino Gateway instances. ```yaml scrape_configs: - job_name: trino_gateway static_configs: - targets: - gateway1.example.com:8080 ``` -------------------------------- ### Use Environment Variable in Configuration Source: https://github.com/trinodb/trino-gateway/blob/main/docs/installation.md Reference an environment variable in the configuration file using the ${ENV:VARIABLE} syntax for secure secret management. ```yaml dataStore: jdbcUrl: jdbc:postgresql://localhost:5432/gateway user: postgres password: ${ENV:DB_PASSWORD} ```