<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # 寫日志 ## 在本地編寫日志 用戶可以使用`base_log_folder`設置在`airflow.cfg`指定日志文件夾。 默認情況下,它位于`AIRFLOW_HOME`目錄中。 此外,用戶可以提供遠程位置,以便在云存儲中存儲日志和日志備份。 在Airflow Web UI中,本地日志優先于遠程日志。 如果找不到或訪問本地日志,將顯示遠程日志。 請注意,只有在任務完成(包括失敗)后才會將日志發送到遠程存儲。 換句話說,運行任務的遠程日志不可用。 日志作為`{dag_id}/{task_id}/{execution_date}/{try_number}.log`存儲在日志文件夾中。 ## 將日志寫入Amazon S3 ### 在你開始之前 遠程日志記錄使用現有的Airflow連接來讀取/寫入日志。 如果沒有正確設置連接,則會失敗。 ### 啟用遠程日志記錄 要啟用此功能,必須按照此示例配置`airflow.cfg` : ``` [ core ] # Airflow can store logs remotely in AWS S3\. Users must supply a remote # location URL (starting with either 's3://...') and an Airflow connection # id that provides access to the storage location. remote_base_log_folder = s3://my-bucket/path/to/logs remote_log_conn_id = MyS3Conn # Use server-side encryption for logs stored in S3 encrypt_s3_logs = False ``` 在上面的例子中,Airflow將嘗試使用`S3Hook('MyS3Conn')` 。 ## 將日志寫入Azure Blob存儲 可以將Airflow配置為在Azure Blob存儲中讀取和寫入任務日志。 按照以下步驟啟用Azure Blob存儲日志記錄。 1. Airflow的日志記錄系統需要將自定義.py文件放在`PYTHONPATH` ,以便可以從Airflow導入。 首先創建一個存儲配置文件的目錄。 建議使用`$AIRFLOW_HOME/config` 。 2. 創建名為`$AIRFLOW_HOME/config/log_config.py`和`$AIRFLOW_HOME/config/__init__.py`空文件。 3. 將`airflow/config_templates/airflow_local_settings.py`的內容復制到剛剛在上面的步驟中創建的`log_config.py`文件中。 4. 自定義模板的以下部分: &gt; ``` &gt; # wasb buckets should start with "wasb" just to help Airflow select correct handler &gt; REMOTE_BASE_LOG_FOLDER = 'wasb-&lt;whatever you want here&gt;' &gt; &gt; # Rename DEFAULT_LOGGING_CONFIG to LOGGING CONFIG &gt; LOGGING_CONFIG = ... &gt; &gt; ``` 5. 確保已在Airflow中定義Azure Blob存儲(Wasb)連接掛鉤。 掛鉤應具有對`REMOTE_BASE_LOG_FOLDER`定義的Azure Blob存儲桶的讀寫訪問權限。 6. 更新`$AIRFLOW_HOME/airflow.cfg`以包含: &gt; ``` &gt; remote_logging = True &gt; logging_config_class = log_config.LOGGING_CONFIG &gt; remote_log_conn_id = &lt;name of the Azure Blob Storage connection&gt; &gt; &gt; ``` 7. 重新啟動Airflow網絡服務器和調度程序,并觸發(或等待)新任務執行。 8. 驗證日志是否顯示在您定義的存儲桶中新執行的任務中。 ## 將日志寫入Google云端存儲 請按照以下步驟啟用Google云端存儲日志記錄。 1. Airflow的日志記錄系統需要將自定義.py文件放在`PYTHONPATH` ,以便可以從Airflow導入。 首先創建一個存儲配置文件的目錄。 建議使用`$AIRFLOW_HOME/config` 。 2. 創建名為`$AIRFLOW_HOME/config/log_config.py`和`$AIRFLOW_HOME/config/__init__.py`空文件。 3. 將`airflow/config_templates/airflow_local_settings.py`的內容復制到剛剛在上面的步驟中創建的`log_config.py`文件中。 4. 自定義模板的以下部分: &gt; ``` &gt; # Add this variable to the top of the file. Note the trailing slash. &gt; GCS_LOG_FOLDER = 'gs://&lt;bucket where logs should be persisted&gt;/' &gt; &gt; # Rename DEFAULT_LOGGING_CONFIG to LOGGING CONFIG &gt; LOGGING_CONFIG = ... &gt; &gt; # Add a GCSTaskHandler to the 'handlers' block of the LOGGING_CONFIG variable &gt; 'gcs.task' : { &gt; 'class' : 'airflow.utils.log.gcs_task_handler.GCSTaskHandler' , &gt; 'formatter' : 'airflow.task' , &gt; 'base_log_folder' : os.path.expanduser ( BASE_LOG_FOLDER ) , &gt; 'gcs_log_folder' : GCS_LOG_FOLDER, &gt; 'filename_template' : FILENAME_TEMPLATE, &gt; } , &gt; &gt; # Update the airflow.task and airflow.task_runner blocks to be 'gcs.task' instead of 'file.task'. &gt; 'loggers' : { &gt; 'airflow.task' : { &gt; 'handlers' : [ 'gcs.task' ] , &gt; ... &gt; } , &gt; 'airflow.task_runner' : { &gt; 'handlers' : [ 'gcs.task' ] , &gt; ... &gt; } , &gt; 'airflow' : { &gt; 'handlers' : [ 'console' ] , &gt; ... &gt; } , &gt; } &gt; &gt; ``` 5. 確保已在Airflow中定義了Google Cloud Platform連接掛鉤。 該掛鉤應具有對`GCS_LOG_FOLDER`定義的Google Cloud Storage存儲桶的讀寫訪問權限。 6. 更新`$AIRFLOW_HOME/airflow.cfg`以包含: &gt; ``` &gt; task_log_reader = gcs.task &gt; logging_config_class = log_config.LOGGING_CONFIG &gt; remote_log_conn_id = &lt;name of the Google cloud platform hook&gt; &gt; &gt; ``` 7. 重新啟動Airflow網絡服務器和調度程序,并觸發(或等待)新任務執行。 8. 驗證日志是否顯示在您定義的存儲桶中新執行的任務中。 9. 確認Google Cloud Storage查看器在U??I中正常運行。 拉出新執行的任務,并驗證您是否看到類似的內容: &gt; ``` &gt; *** Reading remote log from gs://&lt;bucket where logs should be persisted&gt;/example_bash_operator/run_this_last/2017-10-03T00:00:00/16.log. &gt; [ 2017 -10-03 21 :57:50,056 ] { cli.py:377 } INFO - Running on host chrisr-00532 &gt; [ 2017 -10-03 21 :57:50,093 ] { base_task_runner.py:115 } INFO - Running: [ 'bash' , '-c' , u 'airflow run example_bash_operator run_this_last 2017-10-03T00:00:00 --job_id 47 --raw -sd DAGS_FOLDER/example_dags/example_bash_operator.py' ] &gt; [ 2017 -10-03 21 :57:51,264 ] { base_task_runner.py:98 } INFO - Subtask: [ 2017 -10-03 21 :57:51,263 ] { __init__.py:45 } INFO - Using executor SequentialExecutor &gt; [ 2017 -10-03 21 :57:51,306 ] { base_task_runner.py:98 } INFO - Subtask: [ 2017 -10-03 21 :57:51,306 ] { models.py:186 } INFO - Filling up the DagBag from /airflow/dags/example_dags/example_bash_operator.py &gt; &gt; ``` 請注意它從遠程日志文件中讀取的頂行。 請注意,如果您使用舊式airflow.cfg配置方法將日志保存到Google云端存儲,則舊的日志將不再在Airflow用戶界面中顯示,但它們仍將存在于Google云端存儲中。 這是一個向后無比的變化。 如果您對此不滿意,可以更改`FILENAME_TEMPLATE`以反映舊式日志文件名格式。
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看