-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Improve logging and add OpenMetrics docs #21089
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
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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,133 @@ | ||
|
|
||
| # Logging | ||
|
|
||
| Trino include numerous features to better understand and monitor a running | ||
| system, such as [](/admin/opentelemetry) or [](/admin/jmx). Logging and | ||
| configuring logging is one important aspect for operating and troubleshooting | ||
| Trino. | ||
|
|
||
| (logging-configuration)= | ||
| ## Configuration | ||
|
|
||
| Trino application logging is optional and configured in the `log.properties` | ||
| file in your Trino installation `etc` configuration directory as set by the | ||
| [launcher](running-trino). | ||
|
|
||
| Use it to add specific loggers and configure the minimum log levels. Every | ||
| logger has a name, which is typically the fully qualified name of the class that | ||
| uses the logger. Loggers have a hierarchy based on the dots in the name, like | ||
| Java packages. The four log levels are `DEBUG`, `INFO`, `WARN` and `ERROR`, | ||
| sorted by decreasing verbosity. | ||
|
|
||
| For example, consider the following log levels file: | ||
|
|
||
| ```properties | ||
| io.trino=WARN | ||
| io.trino.plugin.iceberg=DEBUG | ||
| io.trino.parquet=DEBUG | ||
| ``` | ||
|
|
||
| The preceding configuration sets the changes the level for all loggers in the | ||
| `io.trino` namespace to `WARN` as an update from the default `INFO` to make | ||
| logging less verbose. The example also increases logging verbosity for the | ||
| Iceberg connector using the `io.trino.plugin.iceberg` namespace, and the Parquet | ||
| file reader and writer support located in the `io.trino.parquet` namespace to | ||
| `DEBUG` for troubleshooting purposes. | ||
|
|
||
| Additional loggers can include other package namespaces from libraries and | ||
| dependencies embedded within Trino or part of the Java runtime, for example: | ||
|
|
||
| * `io.airlift` for the [Airlift](https://github.com/airlift/airlift) application | ||
| framework used by Trino. | ||
| * `org.eclipse.jetty` for the [Eclipse Jetty](https://jetty.org/) web server | ||
| used by Trino. | ||
| * `org.postgresql` for the [PostgresSQL JDBC driver](https://github.com/pgjdbc) | ||
| used by the PostgreSQL connector. | ||
| * `javax.net.ssl` for TLS from the Java runtime. | ||
| * `java.io` for I/O operations. | ||
|
|
||
| There are numerous additional properties available to customize logging in | ||
| [](config-properties), with details documented in [](/admin/properties-logging) | ||
| and in following example sections. | ||
|
|
||
| ## Log output | ||
|
|
||
| By default, logging output is file-based with rotated files in `var/log`: | ||
|
|
||
| * `launcher.log` for logging out put from the application startup from the | ||
| [launcher](running-trino). Only used if the launcher starts Trino in the | ||
| background, and therefore not used in the Trino container. | ||
| * `http-request.log` for HTTP request logs, mostly from the [client | ||
| protocol](/client/client-protocol) and the [Web UI](/admin/web-interface). | ||
| * `server.log` for the main application log of Trino, including logging from all | ||
| plugins. | ||
|
|
||
| ## JSON and TCP channel logging | ||
|
|
||
| Trino supports logging to JSON-formatted output files with the configuration | ||
| `log.format=json`. Optionally you can set `node.annotations-file` as path to a | ||
| properties file such as the following example: | ||
|
|
||
| ```properties | ||
| host_ip=1.2.3.4 | ||
| service_name=trino | ||
| node_name=${ENV:MY_NODE_NAME} | ||
| pod_name=${ENV:MY_POD_NAME} | ||
| pod_namespace=${ENV:MY_POD_NAMESPACE} | ||
| ``` | ||
|
|
||
| The annotations file supports environment variable substitution, so that the | ||
| above example attaches the name of the Trino node as `pod_name` and other | ||
| information to every log line. When running Trino on Kubernetes, you have access | ||
| to [a lot of information to use in the | ||
| log](https://kubernetes.io/docs/tasks/inject-data-application/environment-variable-expose-pod-information/). | ||
|
|
||
| TCP logging allows you to log to a TCP socket instead of a file with the | ||
| configuration `log.path=tcp://<server_ip>:<server_port>`. The endpoint must be | ||
| available at the URL configured with `server_ip` and `server_port` and is | ||
| assumed to be stable. | ||
|
|
||
| You can use an application such as [fluentbit](https://fluentbit.io/) as a | ||
| consumer for these JSON-formatted logs. | ||
|
|
||
| Example fluentbit configuration file `config.yaml`: | ||
|
|
||
| ```yaml | ||
| pipeline: | ||
| inputs: | ||
| - name: tcp | ||
| tag: trino | ||
| listen: 0.0.0.0 | ||
| port: 5170 | ||
| buffer_size: 2048 | ||
| format: json | ||
| outputs: | ||
| - name: stdout | ||
| match: '*' | ||
| ``` | ||
|
|
||
| Start the application with the command: | ||
|
|
||
| ```shell | ||
| fluent-bit -c config.yaml | ||
| ``` | ||
|
|
||
| Use the following Trino properties configuration: | ||
|
|
||
| ```properties | ||
| log.path=tcp://localhost:5170 | ||
| log.format=json | ||
| node.annotation-file=etc/annotations.properties | ||
| ``` | ||
|
|
||
| File `etc/annotation.properties`: | ||
|
|
||
| ```properties | ||
| host_ip=1.2.3.4 | ||
| service_name=trino | ||
| pod_name=${ENV:HOSTNAME} | ||
| ``` | ||
|
|
||
| As a result, Trino logs appear as structured JSON log lines in fluentbit in the | ||
| user interface, and can also be [forwarded into a configured logging | ||
| system](https://docs.fluentbit.io/manual/pipeline/outputs). | ||
Oops, something went wrong.
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.