Add write feature to ESTaskHandler #44973
Merged
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.
For remote logging with Elasticsearch, currently only reading log is supported. Users need to deploy other softwares (such as filebeat & logstash) to ship Airflow task logs to Elasticsearch. Also, user would need to ensure the log messages contain a valid log_id of format {dag_id}-{task_id}-{execution_date}-{try_number} in order for reading remote log to work.
This PR will enable the ElasticSearchTaskHandler to automatically write each task log to Elasticsearch after each DAG task is completed. 2 more config are introduced (namely:
write_to_esandtarget_index, which are set to False andairflow-logsby default`)The ElasticSearchTaskHandler will now also consider the config
delete_local_logsinloggingsession. When bothwrite_to_esanddelete_local_logsare set to True, the handler will delete local task logs upon successfully writing logs to ES.related: #42780