-
Notifications
You must be signed in to change notification settings - Fork 17.6k
[AIRFLOW-6372] Align WASB remote logging URI scheme (1.10.x) #6930
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
Closed
Closed
Changes from all commits
Commits
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
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -72,36 +72,19 @@ In the above example, Airflow will try to use ``S3Hook('MyS3Conn')``. | |||||
| Writing Logs to Azure Blob Storage | ||||||
| ---------------------------------- | ||||||
|
|
||||||
| Airflow can be configured to read and write task logs in Azure Blob Storage. | ||||||
|
|
||||||
| Follow the steps below to enable Azure Blob Storage logging: | ||||||
|
|
||||||
| #. Airflow's logging system requires a custom ``.py`` file to be located in the ``PYTHONPATH``, so that it's importable from Airflow. Start by creating a directory to store the config file, ``$AIRFLOW_HOME/config`` is recommended. | ||||||
| #. Create empty files called ``$AIRFLOW_HOME/config/log_config.py`` and ``$AIRFLOW_HOME/config/__init__.py``. | ||||||
| #. Copy the contents of ``airflow/config_templates/airflow_local_settings.py`` into the ``log_config.py`` file created in ``Step 2``. | ||||||
| #. Customize the following portions of the template: | ||||||
|
|
||||||
| .. code-block:: ini | ||||||
|
|
||||||
| # wasb buckets should start with "wasb" just to help Airflow select correct handler | ||||||
| REMOTE_BASE_LOG_FOLDER = 'wasb-<whatever you want here>' | ||||||
|
|
||||||
| # Rename DEFAULT_LOGGING_CONFIG to LOGGING CONFIG | ||||||
| LOGGING_CONFIG = ... | ||||||
|
|
||||||
|
|
||||||
| #. Make sure a Azure Blob Storage (Wasb) connection hook has been defined in Airflow. The hook should have read and write access to the Azure Blob Storage bucket defined above in ``REMOTE_BASE_LOG_FOLDER``. | ||||||
|
|
||||||
| #. Update ``$AIRFLOW_HOME/airflow.cfg`` to contain: | ||||||
|
|
||||||
| .. code-block:: bash | ||||||
| .. code-block:: ini | ||||||
|
|
||||||
| remote_logging = True | ||||||
| logging_config_class = log_config.LOGGING_CONFIG | ||||||
| remote_log_conn_id = <name of the Azure Blob Storage connection> | ||||||
| [core] | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Recently these options have been moved.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This PR is for 1.10.x version, I have submitted another PR (#6931) for master branch. |
||||||
| # Airflow can store logs remotely in Azure Blob Storage. Users must supply a remote | ||||||
| # location URL (starting with either 'wasb://...') and an Airflow connection | ||||||
| # id that provides access to the storage location. | ||||||
| remote_logging = True | ||||||
| remote_base_log_folder = wasb://container-name@account-name.blob.core.windows.net/path/to/logs | ||||||
| remote_log_conn_id = MyWasbConn | ||||||
|
|
||||||
| #. Restart the Airflow webserver and scheduler, and trigger (or wait for) a new task execution. | ||||||
| #. Verify that logs are showing up for newly executed tasks in the bucket you've defined. | ||||||
| #. Make sure a Azure Blob Storage (Wasb) connection hook has been defined in Airflow. The hook should have read and write access to the Azure Blob Storage container defined above in ``REMOTE_BASE_LOG_FOLDER``. | ||||||
|
|
||||||
| .. _write-logs-gcp: | ||||||
|
|
||||||
|
|
@@ -115,8 +98,9 @@ example: | |||||
|
|
||||||
| .. code-block:: ini | ||||||
|
|
||||||
|
|
||||||
| [core] | ||||||
|
phstudy marked this conversation as resolved.
Outdated
|
||||||
| # Airflow can store logs remotely in AWS S3, Google Cloud Storage or Elastic Search. | ||||||
| # Airflow can store logs remotely in AWS S3, Azure Blob Storage, Google Cloud Storage or Elasticsearch. | ||||||
| # Users must supply an Airflow connection id that provides access to the storage | ||||||
| # location. If remote_logging is set to true, see UPDATING.md for additional | ||||||
| # configuration requirements. | ||||||
|
|
@@ -155,7 +139,7 @@ First, to use the handler, ``airflow.cfg`` must be configured as follows: | |||||
| .. code-block:: ini | ||||||
|
|
||||||
| [core] | ||||||
|
phstudy marked this conversation as resolved.
Outdated
|
||||||
| # Airflow can store logs remotely in AWS S3, Google Cloud Storage or Elastic Search. | ||||||
| # Airflow can store logs remotely in AWS S3, Azure Blob Storage, Google Cloud Storage or Elasticsearch. | ||||||
| # Users must supply an Airflow connection id that provides access to the storage | ||||||
| # location. If remote_logging is set to true, see UPDATING.md for additional | ||||||
| # configuration requirements. | ||||||
|
|
@@ -172,7 +156,7 @@ To output task logs to stdout in JSON format, the following config could be used | |||||
| .. code-block:: ini | ||||||
|
|
||||||
| [core] | ||||||
|
phstudy marked this conversation as resolved.
Outdated
|
||||||
| # Airflow can store logs remotely in AWS S3, Google Cloud Storage or Elastic Search. | ||||||
| # Airflow can store logs remotely in AWS S3, Azure Blob Storage, Google Cloud Storage or Elasticsearch. | ||||||
| # Users must supply an Airflow connection id that provides access to the storage | ||||||
| # location. If remote_logging is set to true, see UPDATING.md for additional | ||||||
| # configuration requirements. | ||||||
|
|
@@ -190,12 +174,12 @@ To output task logs to stdout in JSON format, the following config could be used | |||||
| Writing Logs to Elasticsearch over TLS | ||||||
| ---------------------------------------- | ||||||
|
|
||||||
| To add custom configurations to ElasticSearch (e.g. turning on ``ssl_verify``, adding a custom self-signed cert, etc.) use the ``elasticsearch_configs`` setting in your ``airfow.cfg`` | ||||||
| To add custom configurations to Elasticsearch (e.g. turning on ``ssl_verify``, adding a custom self-signed cert, etc.) use the ``elasticsearch_configs`` setting in your ``airfow.cfg`` | ||||||
|
|
||||||
| .. code-block:: ini | ||||||
|
|
||||||
| [core] | ||||||
|
phstudy marked this conversation as resolved.
Outdated
|
||||||
| # Airflow can store logs remotely in AWS S3, Google Cloud Storage or Elastic Search. | ||||||
| # Airflow can store logs remotely in AWS S3, Azure Blob Storage, Google Cloud Storage or Elasticsearch. | ||||||
| # Users must supply an Airflow connection id that provides access to the storage | ||||||
| # location. If remote_logging is set to true, see UPDATING.md for additional | ||||||
| # configuration requirements. | ||||||
|
|
@@ -205,3 +189,48 @@ To add custom configurations to ElasticSearch (e.g. turning on ``ssl_verify``, a | |||||
| use_ssl=True | ||||||
| verify_certs=True | ||||||
| ca_certs=/path/to/CA_certs | ||||||
|
|
||||||
| .. _customize-write-logs-configuration: | ||||||
|
|
||||||
| Customize Logging Configuration | ||||||
| ---------------------------------------- | ||||||
|
|
||||||
| Airflow can be configured to override default logging behaviors and add custom logging handlers. | ||||||
|
|
||||||
| Follow the steps below to customize default logging behaviors: | ||||||
|
|
||||||
| #. Airflow's logging system requires a custom ``.py`` file to be located in the ``PYTHONPATH``, so that it's importable from Airflow. Start by creating a directory to store the config file, ``$AIRFLOW_HOME/config`` is recommended. | ||||||
| #. Create empty files called ``$AIRFLOW_HOME/config/log_config.py`` and ``$AIRFLOW_HOME/config/__init__.py``. | ||||||
| #. Copy the contents of ``airflow/config_templates/airflow_local_settings.py`` into the ``log_config.py`` file created in ``Step 2``. | ||||||
| #. Customize the following portions of the template: | ||||||
|
|
||||||
| .. code-block:: ini | ||||||
|
|
||||||
| # Rename DEFAULT_LOGGING_CONFIG to LOGGING CONFIG | ||||||
| LOGGING_CONFIG = ... | ||||||
|
|
||||||
| #. Update ``$AIRFLOW_HOME/airflow.cfg`` to contain: | ||||||
|
|
||||||
| .. code-block:: bash | ||||||
|
|
||||||
| remote_logging = True | ||||||
| logging_config_class = log_config.LOGGING_CONFIG | ||||||
| remote_log_conn_id = <name of the Remote Logging System connection> | ||||||
|
|
||||||
| To add custom logging handler. You must implement a log task handler and add related parameters to above template. | ||||||
| The configuration may look like: | ||||||
|
|
||||||
| .. code-block:: ini | ||||||
|
|
||||||
| elif REMOTE_BASE_LOG_FOLDER.startswith('smb://'): | ||||||
| SMB_REMOTE_HANDLERS = { | ||||||
| 'task': { | ||||||
| 'class': 'airflow.utils.log.smb_task_handler.SmbTaskHandler', | ||||||
| 'formatter': 'airflow', | ||||||
| 'base_log_folder': os.path.expanduser(BASE_LOG_FOLDER), | ||||||
| 'smb_log_folder': REMOTE_BASE_LOG_FOLDER, | ||||||
| 'filename_template': FILENAME_TEMPLATE, | ||||||
| }, | ||||||
| } | ||||||
|
|
||||||
| LOGGING_CONFIG['handlers'].update(SMB_REMOTE_HANDLERS) | ||||||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a very valuable piece of documentation, although it may not be well written. This contains the description of the
logging_config_classkey.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe, this description can be move to advanced configuration section.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have moved the description of the
logging_config_class keyto Customize Logging Configuration section.