apache-airflow-providers-elasticsearch 5.4.0rc2__py3-none-any.whl → 5.4.1rc1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- airflow/providers/elasticsearch/__init__.py +3 -6
- airflow/providers/elasticsearch/get_provider_info.py +10 -2
- airflow/providers/elasticsearch/log/es_task_handler.py +25 -7
- {apache_airflow_providers_elasticsearch-5.4.0rc2.dist-info → apache_airflow_providers_elasticsearch-5.4.1rc1.dist-info}/METADATA +6 -6
- {apache_airflow_providers_elasticsearch-5.4.0rc2.dist-info → apache_airflow_providers_elasticsearch-5.4.1rc1.dist-info}/RECORD +7 -7
- {apache_airflow_providers_elasticsearch-5.4.0rc2.dist-info → apache_airflow_providers_elasticsearch-5.4.1rc1.dist-info}/WHEEL +0 -0
- {apache_airflow_providers_elasticsearch-5.4.0rc2.dist-info → apache_airflow_providers_elasticsearch-5.4.1rc1.dist-info}/entry_points.txt +0 -0
|
@@ -25,14 +25,11 @@ from __future__ import annotations
|
|
|
25
25
|
|
|
26
26
|
import packaging.version
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
from airflow import __version__ as airflow_version
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
__all__ = ["__version__"]
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
from airflow import __version__ as airflow_version
|
|
34
|
-
except ImportError:
|
|
35
|
-
from airflow.version import version as airflow_version
|
|
32
|
+
__version__ = "5.4.1"
|
|
36
33
|
|
|
37
34
|
if packaging.version.parse(packaging.version.parse(airflow_version).base_version) < packaging.version.parse(
|
|
38
35
|
"2.7.0"
|
|
@@ -28,8 +28,9 @@ def get_provider_info():
|
|
|
28
28
|
"name": "Elasticsearch",
|
|
29
29
|
"description": "`Elasticsearch <https://www.elastic.co/elasticsearch>`__\n",
|
|
30
30
|
"state": "ready",
|
|
31
|
-
"source-date-epoch":
|
|
31
|
+
"source-date-epoch": 1716287658,
|
|
32
32
|
"versions": [
|
|
33
|
+
"5.4.1",
|
|
33
34
|
"5.4.0",
|
|
34
35
|
"5.3.4",
|
|
35
36
|
"5.3.3",
|
|
@@ -163,12 +164,19 @@ def get_provider_info():
|
|
|
163
164
|
"default": "offset",
|
|
164
165
|
},
|
|
165
166
|
"index_patterns": {
|
|
166
|
-
"description": "Comma separated list of index patterns to use when searching for logs (default: `_all`).\n",
|
|
167
|
+
"description": "Comma separated list of index patterns to use when searching for logs (default: `_all`).\nThe index_patterns_callable takes precedence over this.\n",
|
|
167
168
|
"version_added": "2.6.0",
|
|
168
169
|
"type": "string",
|
|
169
170
|
"example": "something-*",
|
|
170
171
|
"default": "_all",
|
|
171
172
|
},
|
|
173
|
+
"index_patterns_callable": {
|
|
174
|
+
"description": "A string representing the full path to the Python callable path which accept TI object and\nreturn comma separated list of index patterns. This will takes precedence over index_patterns.\n",
|
|
175
|
+
"version_added": "5.5.0",
|
|
176
|
+
"type": "string",
|
|
177
|
+
"example": "module.callable",
|
|
178
|
+
"default": "",
|
|
179
|
+
},
|
|
172
180
|
},
|
|
173
181
|
},
|
|
174
182
|
"elasticsearch_configs": {
|
|
@@ -41,6 +41,7 @@ from airflow.providers.elasticsearch.log.es_response import ElasticSearchRespons
|
|
|
41
41
|
from airflow.utils import timezone
|
|
42
42
|
from airflow.utils.log.file_task_handler import FileTaskHandler
|
|
43
43
|
from airflow.utils.log.logging_mixin import ExternalLoggingMixin, LoggingMixin
|
|
44
|
+
from airflow.utils.module_loading import import_string
|
|
44
45
|
from airflow.utils.session import create_session
|
|
45
46
|
|
|
46
47
|
if TYPE_CHECKING:
|
|
@@ -108,7 +109,7 @@ def _ensure_ti(ti: TaskInstanceKey | TaskInstance, session) -> TaskInstance:
|
|
|
108
109
|
.one_or_none()
|
|
109
110
|
)
|
|
110
111
|
if isinstance(val, TaskInstance):
|
|
111
|
-
val.
|
|
112
|
+
val.try_number = ti.try_number
|
|
112
113
|
return val
|
|
113
114
|
else:
|
|
114
115
|
raise AirflowException(f"Could not find TaskInstance for {ti}")
|
|
@@ -152,7 +153,8 @@ class ElasticsearchTaskHandler(FileTaskHandler, ExternalLoggingMixin, LoggingMix
|
|
|
152
153
|
offset_field: str = "offset",
|
|
153
154
|
host: str = "http://localhost:9200",
|
|
154
155
|
frontend: str = "localhost:5601",
|
|
155
|
-
index_patterns: str
|
|
156
|
+
index_patterns: str = conf.get("elasticsearch", "index_patterns"),
|
|
157
|
+
index_patterns_callable: str = conf.get("elasticsearch", "index_patterns_callable", fallback=""),
|
|
156
158
|
es_kwargs: dict | None | Literal["default_es_kwargs"] = "default_es_kwargs",
|
|
157
159
|
*,
|
|
158
160
|
filename_template: str | None = None,
|
|
@@ -184,6 +186,7 @@ class ElasticsearchTaskHandler(FileTaskHandler, ExternalLoggingMixin, LoggingMix
|
|
|
184
186
|
self.host_field = host_field
|
|
185
187
|
self.offset_field = offset_field
|
|
186
188
|
self.index_patterns = index_patterns
|
|
189
|
+
self.index_patterns_callable = index_patterns_callable
|
|
187
190
|
self.context_set = False
|
|
188
191
|
|
|
189
192
|
self.formatter: logging.Formatter
|
|
@@ -213,6 +216,19 @@ class ElasticsearchTaskHandler(FileTaskHandler, ExternalLoggingMixin, LoggingMix
|
|
|
213
216
|
|
|
214
217
|
return host
|
|
215
218
|
|
|
219
|
+
def _get_index_patterns(self, ti: TaskInstance | None) -> str:
|
|
220
|
+
"""
|
|
221
|
+
Get index patterns by calling index_patterns_callable, if provided, or the configured index_patterns.
|
|
222
|
+
|
|
223
|
+
:param ti: A TaskInstance object or None.
|
|
224
|
+
"""
|
|
225
|
+
if self.index_patterns_callable:
|
|
226
|
+
self.log.debug("Using index_patterns_callable: %s", self.index_patterns_callable)
|
|
227
|
+
index_pattern_callable_obj = import_string(self.index_patterns_callable)
|
|
228
|
+
return index_pattern_callable_obj(ti)
|
|
229
|
+
self.log.debug("Using index_patterns: %s", self.index_patterns)
|
|
230
|
+
return self.index_patterns
|
|
231
|
+
|
|
216
232
|
def _render_log_id(self, ti: TaskInstance | TaskInstanceKey, try_number: int) -> str:
|
|
217
233
|
from airflow.models.taskinstance import TaskInstanceKey
|
|
218
234
|
|
|
@@ -302,7 +318,7 @@ class ElasticsearchTaskHandler(FileTaskHandler, ExternalLoggingMixin, LoggingMix
|
|
|
302
318
|
|
|
303
319
|
offset = metadata["offset"]
|
|
304
320
|
log_id = self._render_log_id(ti, try_number)
|
|
305
|
-
response = self._es_read(log_id, offset)
|
|
321
|
+
response = self._es_read(log_id, offset, ti)
|
|
306
322
|
if response is not None and response.hits:
|
|
307
323
|
logs_by_host = self._group_logs_by_host(response)
|
|
308
324
|
next_offset = attrgetter(self.offset_field)(response[-1])
|
|
@@ -372,12 +388,13 @@ class ElasticsearchTaskHandler(FileTaskHandler, ExternalLoggingMixin, LoggingMix
|
|
|
372
388
|
# Just a safe-guard to preserve backwards-compatibility
|
|
373
389
|
return hit.message
|
|
374
390
|
|
|
375
|
-
def _es_read(self, log_id: str, offset: int | str) -> ElasticSearchResponse | None:
|
|
391
|
+
def _es_read(self, log_id: str, offset: int | str, ti: TaskInstance) -> ElasticSearchResponse | None:
|
|
376
392
|
"""
|
|
377
393
|
Return the logs matching log_id in Elasticsearch and next offset or ''.
|
|
378
394
|
|
|
379
395
|
:param log_id: the log_id of the log to read.
|
|
380
396
|
:param offset: the offset start to read log from.
|
|
397
|
+
:param ti: the task instance object
|
|
381
398
|
|
|
382
399
|
:meta private:
|
|
383
400
|
"""
|
|
@@ -388,16 +405,17 @@ class ElasticsearchTaskHandler(FileTaskHandler, ExternalLoggingMixin, LoggingMix
|
|
|
388
405
|
}
|
|
389
406
|
}
|
|
390
407
|
|
|
408
|
+
index_patterns = self._get_index_patterns(ti)
|
|
391
409
|
try:
|
|
392
|
-
max_log_line = self.client.count(index=
|
|
410
|
+
max_log_line = self.client.count(index=index_patterns, query=query)["count"] # type: ignore
|
|
393
411
|
except NotFoundError as e:
|
|
394
|
-
self.log.exception("The target index pattern %s does not exist",
|
|
412
|
+
self.log.exception("The target index pattern %s does not exist", index_patterns)
|
|
395
413
|
raise e
|
|
396
414
|
|
|
397
415
|
if max_log_line != 0:
|
|
398
416
|
try:
|
|
399
417
|
res = self.client.search(
|
|
400
|
-
index=
|
|
418
|
+
index=index_patterns,
|
|
401
419
|
query=query,
|
|
402
420
|
sort=[self.offset_field],
|
|
403
421
|
size=self.MAX_LINE_PER_PAGE,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: apache-airflow-providers-elasticsearch
|
|
3
|
-
Version: 5.4.
|
|
3
|
+
Version: 5.4.1rc1
|
|
4
4
|
Summary: Provider package apache-airflow-providers-elasticsearch for Apache Airflow
|
|
5
5
|
Keywords: airflow-provider,elasticsearch,airflow,integration
|
|
6
6
|
Author-email: Apache Software Foundation <dev@airflow.apache.org>
|
|
@@ -26,8 +26,8 @@ Requires-Dist: apache-airflow>=2.7.0rc0
|
|
|
26
26
|
Requires-Dist: elasticsearch>=8.10,<9
|
|
27
27
|
Requires-Dist: apache-airflow-providers-common-sql ; extra == "common.sql"
|
|
28
28
|
Project-URL: Bug Tracker, https://github.com/apache/airflow/issues
|
|
29
|
-
Project-URL: Changelog, https://airflow.apache.org/docs/apache-airflow-providers-elasticsearch/5.4.
|
|
30
|
-
Project-URL: Documentation, https://airflow.apache.org/docs/apache-airflow-providers-elasticsearch/5.4.
|
|
29
|
+
Project-URL: Changelog, https://airflow.apache.org/docs/apache-airflow-providers-elasticsearch/5.4.1/changelog.html
|
|
30
|
+
Project-URL: Documentation, https://airflow.apache.org/docs/apache-airflow-providers-elasticsearch/5.4.1
|
|
31
31
|
Project-URL: Slack Chat, https://s.apache.org/airflow-slack
|
|
32
32
|
Project-URL: Source Code, https://github.com/apache/airflow
|
|
33
33
|
Project-URL: Twitter, https://twitter.com/ApacheAirflow
|
|
@@ -78,7 +78,7 @@ Provides-Extra: common.sql
|
|
|
78
78
|
|
|
79
79
|
Package ``apache-airflow-providers-elasticsearch``
|
|
80
80
|
|
|
81
|
-
Release: ``5.4.
|
|
81
|
+
Release: ``5.4.1.rc1``
|
|
82
82
|
|
|
83
83
|
|
|
84
84
|
`Elasticsearch <https://www.elastic.co/elasticsearch>`__
|
|
@@ -91,7 +91,7 @@ This is a provider package for ``elasticsearch`` provider. All classes for this
|
|
|
91
91
|
are in ``airflow.providers.elasticsearch`` python package.
|
|
92
92
|
|
|
93
93
|
You can find package information and changelog for the provider
|
|
94
|
-
in the `documentation <https://airflow.apache.org/docs/apache-airflow-providers-elasticsearch/5.4.
|
|
94
|
+
in the `documentation <https://airflow.apache.org/docs/apache-airflow-providers-elasticsearch/5.4.1/>`_.
|
|
95
95
|
|
|
96
96
|
Installation
|
|
97
97
|
------------
|
|
@@ -133,4 +133,4 @@ Dependent package
|
|
|
133
133
|
============================================================================================================ ==============
|
|
134
134
|
|
|
135
135
|
The changelog for the provider package can be found in the
|
|
136
|
-
`changelog <https://airflow.apache.org/docs/apache-airflow-providers-elasticsearch/5.4.
|
|
136
|
+
`changelog <https://airflow.apache.org/docs/apache-airflow-providers-elasticsearch/5.4.1/changelog.html>`_.
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
airflow/providers/elasticsearch/LICENSE,sha256=ywUBpKZc7Jb96rVt5I3IDbg7dIJAbUSHkuoDcF3jbH4,13569
|
|
2
|
-
airflow/providers/elasticsearch/__init__.py,sha256=
|
|
3
|
-
airflow/providers/elasticsearch/get_provider_info.py,sha256=
|
|
2
|
+
airflow/providers/elasticsearch/__init__.py,sha256=leQgUnvVqq9KHi7Uffo5O3HuM6OldRNLpqcwJxlBFjE,1500
|
|
3
|
+
airflow/providers/elasticsearch/get_provider_info.py,sha256=b7kZ8E03LE7dotRl0fc2ZbPpfpf8EkJ7unuUmpxNwSQ,8507
|
|
4
4
|
airflow/providers/elasticsearch/hooks/__init__.py,sha256=mlJxuZLkd5x-iq2SBwD3mvRQpt3YR7wjz_nceyF1IaI,787
|
|
5
5
|
airflow/providers/elasticsearch/hooks/elasticsearch.py,sha256=nraT_vR1vm0VZ13G4lIJ9YEI0igsm-A66BjFlf-yNmE,6362
|
|
6
6
|
airflow/providers/elasticsearch/log/__init__.py,sha256=9hdXHABrVpkbpjZgUft39kOFL2xSGeG4GEua0Hmelus,785
|
|
7
7
|
airflow/providers/elasticsearch/log/es_json_formatter.py,sha256=DwWPDJtZLr_6Mdae1-XVEgmE1XErFIanSzxWovs50ig,1796
|
|
8
8
|
airflow/providers/elasticsearch/log/es_response.py,sha256=tEFz1pAUzIg6Zw43ZjiHFTOB72kNP-czbEwMbymUZ88,6037
|
|
9
|
-
airflow/providers/elasticsearch/log/es_task_handler.py,sha256=
|
|
10
|
-
apache_airflow_providers_elasticsearch-5.4.
|
|
11
|
-
apache_airflow_providers_elasticsearch-5.4.
|
|
12
|
-
apache_airflow_providers_elasticsearch-5.4.
|
|
13
|
-
apache_airflow_providers_elasticsearch-5.4.
|
|
9
|
+
airflow/providers/elasticsearch/log/es_task_handler.py,sha256=vgEQWlZwCp_K0jTv7KKwv6jPgXLXRCeSQ5833Wto7ts,26244
|
|
10
|
+
apache_airflow_providers_elasticsearch-5.4.1rc1.dist-info/entry_points.txt,sha256=jpgAUVmTsdtWQ4nru2FJQKP9JBN4OPHK-ybfYc3_BOs,109
|
|
11
|
+
apache_airflow_providers_elasticsearch-5.4.1rc1.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
|
|
12
|
+
apache_airflow_providers_elasticsearch-5.4.1rc1.dist-info/METADATA,sha256=Ls3_xbeJ1BIoytibTNsvykeIdAkDa2oiz6oxjjWgtKY,6230
|
|
13
|
+
apache_airflow_providers_elasticsearch-5.4.1rc1.dist-info/RECORD,,
|
|
File without changes
|