aliyun-log-python-sdk 0.8.15__tar.gz → 0.9.1__tar.gz

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.
Files changed (123) hide show
  1. aliyun-log-python-sdk-0.9.1/LICENSE +21 -0
  2. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/PKG-INFO +14 -9
  3. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/consumer/config.py +3 -1
  4. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/consumer/consumer_client.py +3 -3
  5. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/consumer/shard_worker.py +17 -7
  6. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/consumer/tasks.py +25 -5
  7. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/consumer/worker.py +2 -1
  8. aliyun-log-python-sdk-0.9.1/aliyun/log/getlogsresponse.py +568 -0
  9. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/logclient.py +44 -13
  10. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/logclient_operator.py +4 -4
  11. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/logexception.py +3 -0
  12. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/pulllog_response.py +14 -1
  13. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/queriedlog.py +22 -1
  14. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/util.py +48 -0
  15. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/version.py +1 -1
  16. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun_log_python_sdk.egg-info/PKG-INFO +14 -9
  17. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun_log_python_sdk.egg-info/SOURCES.txt +3 -1
  18. aliyun-log-python-sdk-0.9.1/tests/test_alert.py +30 -0
  19. aliyun-log-python-sdk-0.8.15/aliyun/log/getlogsresponse.py +0 -203
  20. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/README.md +0 -0
  21. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/__init__.py +0 -0
  22. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/__init__.py +0 -0
  23. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/acl_config.py +0 -0
  24. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/acl_response.py +0 -0
  25. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/auth.py +0 -0
  26. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/common_response.py +0 -0
  27. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/consumer/__init__.py +0 -0
  28. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/consumer/checkpoint_tracker.py +0 -0
  29. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/consumer/exceptions.py +0 -0
  30. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/consumer/fetched_log_group.py +0 -0
  31. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/consumer/heart_beat.py +0 -0
  32. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/consumer_group_request.py +0 -0
  33. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/consumer_group_response.py +0 -0
  34. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/cursor_response.py +0 -0
  35. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/cursor_time_response.py +0 -0
  36. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/es_migration/__init__.py +0 -0
  37. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/es_migration/doc_logitem_converter.py +0 -0
  38. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/es_migration/index_logstore_mappings.py +0 -0
  39. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/es_migration/mapping_index_converter.py +0 -0
  40. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/es_migration/migration_log.py +0 -0
  41. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/es_migration/migration_manager.py +0 -0
  42. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/es_migration/migration_response.py +0 -0
  43. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/es_migration/migration_task.py +0 -0
  44. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/es_migration/util.py +0 -0
  45. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/etl_config_response.py +0 -0
  46. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/etl_core/__init__.py +0 -0
  47. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/etl_core/config_parser.py +0 -0
  48. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/etl_core/etl_util.py +0 -0
  49. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/etl_core/exceptions.py +0 -0
  50. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/etl_core/restrict_config_parser.py +0 -0
  51. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/etl_core/runner.py +0 -0
  52. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/etl_core/settings.py +0 -0
  53. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/etl_core/trans_comp/__init__.py +0 -0
  54. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/etl_core/trans_comp/trans_base.py +0 -0
  55. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/etl_core/trans_comp/trans_csv.py +0 -0
  56. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/etl_core/trans_comp/trans_json.py +0 -0
  57. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/etl_core/trans_comp/trans_kv.py +0 -0
  58. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/etl_core/trans_comp/trans_lookup.py +0 -0
  59. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/etl_core/trans_comp/trans_mv.py +0 -0
  60. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/etl_core/trans_comp/trans_regex.py +0 -0
  61. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/etl_core/trans_comp/trans_set_field.py +0 -0
  62. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/etl_core/transform/__init__.py +0 -0
  63. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/etl_core/transform/condition_list.py +0 -0
  64. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/etl_core/transform/condition_transform.py +0 -0
  65. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/etl_core/transform/condition_util.py +0 -0
  66. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/etl_core/transform/transform_base.py +0 -0
  67. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/etl_core/transform/transform_list.py +0 -0
  68. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/etl_core/transform/transform_meta.py +0 -0
  69. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/export_response.py +0 -0
  70. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/ext/__init__.py +0 -0
  71. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/ext/jupyter_magic.py +0 -0
  72. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/ext/syslogclient.py +0 -0
  73. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/external_store_config.py +0 -0
  74. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/external_store_config_response.py +0 -0
  75. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/getcontextlogsresponse.py +0 -0
  76. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/gethistogramsrequest.py +0 -0
  77. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/gethistogramsresponse.py +0 -0
  78. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/getlogsrequest.py +0 -0
  79. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/histogram.py +0 -0
  80. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/index_config.py +0 -0
  81. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/index_config_response.py +0 -0
  82. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/ingestion_response.py +0 -0
  83. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/job.py +0 -0
  84. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/listlogstoresrequest.py +0 -0
  85. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/listlogstoresresponse.py +0 -0
  86. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/listtopicsrequest.py +0 -0
  87. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/listtopicsresponse.py +0 -0
  88. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/log_logs_pb2.py +0 -0
  89. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/log_logs_raw_pb2.py +0 -0
  90. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/logclient_core.py +0 -0
  91. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/logger_hanlder.py +0 -0
  92. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/logitem.py +0 -0
  93. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/logrequest.py +0 -0
  94. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/logresponse.py +0 -0
  95. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/logstore_config_response.py +0 -0
  96. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/logtail_config_detail.py +0 -0
  97. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/logtail_config_response.py +0 -0
  98. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/machine_group_detail.py +0 -0
  99. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/machinegroup_response.py +0 -0
  100. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/odps_sink.py +0 -0
  101. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/oss_sink.py +0 -0
  102. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/pluralize.py +0 -0
  103. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/project_response.py +0 -0
  104. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/putlogsrequest.py +0 -0
  105. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/putlogsresponse.py +0 -0
  106. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/resource_params.py +0 -0
  107. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/resource_response.py +0 -0
  108. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/scheduled_sql.py +0 -0
  109. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/scheduled_sql_response.py +0 -0
  110. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/shard_response.py +0 -0
  111. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/shipper_config.py +0 -0
  112. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/shipper_response.py +0 -0
  113. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/sink.py +0 -0
  114. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/sql_instance_response.py +0 -0
  115. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/substore_config_response.py +0 -0
  116. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/tag_response.py +0 -0
  117. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/topostore_params.py +0 -0
  118. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun/log/topostore_response.py +0 -0
  119. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun_log_python_sdk.egg-info/dependency_links.txt +0 -0
  120. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun_log_python_sdk.egg-info/requires.txt +0 -0
  121. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/aliyun_log_python_sdk.egg-info/top_level.txt +0 -0
  122. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/setup.cfg +0 -0
  123. {aliyun-log-python-sdk-0.8.15 → aliyun-log-python-sdk-0.9.1}/setup.py +0 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 Alibaba Cloud
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,16 +1,9 @@
1
- Metadata-Version: 1.1
1
+ Metadata-Version: 2.1
2
2
  Name: aliyun-log-python-sdk
3
- Version: 0.8.15
3
+ Version: 0.9.1
4
4
  Summary: Aliyun log service Python client SDK
5
5
  Home-page: https://github.com/aliyun/aliyun-log-python-sdk
6
6
  Author: Aliyun
7
- Author-email: UNKNOWN
8
- License: UNKNOWN
9
- Description:
10
- Python SDK for Alicloud Log Service
11
- http://aliyun-log-python-sdk.readthedocs.io
12
-
13
- Platform: UNKNOWN
14
7
  Classifier: Development Status :: 5 - Production/Stable
15
8
  Classifier: License :: OSI Approved :: MIT License
16
9
  Classifier: Operating System :: OS Independent
@@ -22,3 +15,15 @@ Classifier: Programming Language :: Python :: 3.5
22
15
  Classifier: Programming Language :: Python :: 3.6
23
16
  Classifier: Programming Language :: Python :: 3.7
24
17
  Classifier: Programming Language :: Python :: Implementation :: PyPy
18
+ License-File: LICENSE
19
+ Requires-Dist: six
20
+ Requires-Dist: requests
21
+ Requires-Dist: python-dateutil
22
+ Requires-Dist: elasticsearch
23
+ Requires-Dist: jmespath
24
+ Requires-Dist: dateparser
25
+ Requires-Dist: protobuf<4.0.0,>3.4.0
26
+
27
+
28
+ Python SDK for Alicloud Log Service
29
+ http://aliyun-log-python-sdk.readthedocs.io
@@ -25,7 +25,7 @@ class LogHubConfig(object):
25
25
  cursor_position=None, heartbeat_interval=None, data_fetch_interval=None, in_order=False,
26
26
  cursor_start_time=None, security_token=None, max_fetch_log_group_size=None, worker_pool_size=None, shared_executor=None,
27
27
  cursor_end_time=None, credentials_refresher=None,
28
- auth_version=AUTH_VERSION_1, region=''):
28
+ auth_version=AUTH_VERSION_1, region='', query=None):
29
29
  """
30
30
 
31
31
  :param endpoint:
@@ -47,6 +47,7 @@ class LogHubConfig(object):
47
47
  :param cursor_end_time: cursor end time, default is None (never stop processing). could setting it as ISO time-format, when setting it as "end", it means process all logs received from start to the time when the consumer is started.
48
48
  :param auth_version: only support AUTH_VERSION_1 and AUTH_VERSION_4
49
49
  :param region: region of project
50
+ :param query: the SPL query, such as *| where a = 'xxx'
50
51
  """
51
52
  self.endpoint = endpoint
52
53
  self.accessKeyId = access_key_id
@@ -69,3 +70,4 @@ class LogHubConfig(object):
69
70
  self.credentials_refresher = credentials_refresher
70
71
  self.auth_version = auth_version
71
72
  self.region = region
73
+ self.query = query
@@ -27,7 +27,7 @@ class ConsumerClient(object):
27
27
  from .. import LogClient
28
28
 
29
29
  self.mclient = LogClient(endpoint, access_key_id, access_key, security_token, auth_version=auth_version, region=region)
30
- self.mclient.set_user_agent('%s-consumergroup-%s' % (USER_AGENT, consumer_group))
30
+ self.mclient.set_user_agent('%s-consumergroup-%s-%s' % (USER_AGENT, consumer_group, consumer))
31
31
  if credentials_refresher is not None:
32
32
  self.mclient.set_credentials_auto_refresher(credentials_refresher)
33
33
  self.mproject = project
@@ -100,5 +100,5 @@ class ConsumerClient(object):
100
100
  def get_end_cursor(self, shard_id):
101
101
  return self.mclient.get_end_cursor(self.mproject, self.mlogstore, shard_id).get_cursor()
102
102
 
103
- def pull_logs(self, shard_id, cursor, end_cursor=None, count=1000):
104
- return self.mclient.pull_logs(self.mproject, self.mlogstore, shard_id, cursor, count, compress=True, end_cursor=end_cursor)
103
+ def pull_logs(self, shard_id, cursor, end_cursor=None, count=1000, query=None):
104
+ return self.mclient.pull_logs(self.mproject, self.mlogstore, shard_id, cursor, count, compress=True, end_cursor=end_cursor,query=query)
@@ -30,7 +30,7 @@ class ShardConsumerWorkerLoggerAdapter(logging.LoggerAdapter):
30
30
 
31
31
  class ShardConsumerWorker(object):
32
32
  def __init__(self, log_client, shard_id, consumer_name, processor, cursor_position, cursor_start_time,
33
- max_fetch_log_group_size=1000, executor=None, cursor_end_time=None):
33
+ max_fetch_log_group_size=1000, executor=None, cursor_end_time=None, query=None):
34
34
  self.log_client = log_client
35
35
  self.shard_id = shard_id
36
36
  self.consumer_name = consumer_name
@@ -57,10 +57,13 @@ class ShardConsumerWorker(object):
57
57
  self.last_log_error_time = 0
58
58
  self.last_fetch_time = 0
59
59
  self.last_fetch_count = 0
60
+ self.last_fetch_size = 0
61
+ self.rawLogGroupCountBeforeQuery = 0
62
+ self.rawSizeBeforeQuery = 0
60
63
  self.last_success_fetch_time = 0
61
64
  self.last_success_fetch_time_with_data = 0
62
65
  self.save_last_checkpoint = False
63
-
66
+ self.query = query
64
67
  self.logger = ShardConsumerWorkerLoggerAdapter(
65
68
  logging.getLogger(__name__), {"shard_consumer_worker": self})
66
69
 
@@ -97,6 +100,9 @@ class ShardConsumerWorker(object):
97
100
  task_result.get_cursor())
98
101
  self.next_fetch_cursor = task_result.get_cursor()
99
102
  self.last_fetch_count = self.last_fetch_log_group.log_group_size
103
+ self.last_fetch_size = task_result.get_raw_size()
104
+ self.rawLogGroupCountBeforeQuery = task_result.get_raw_log_group_count_before_query()
105
+ self.rawSizeBeforeQuery = task_result.get_raw_size_before_query()
100
106
  if self.last_fetch_count > 0:
101
107
  self.last_success_fetch_time_with_data = time.time()
102
108
  self.save_last_checkpoint = False
@@ -113,22 +119,26 @@ class ShardConsumerWorker(object):
113
119
  if task_result is None or task_result.get_exception() is None:
114
120
  # flag to indicate if it's done
115
121
  is_generate_fetch_task = True
122
+ fetch_size = self.last_fetch_size
123
+ fetch_count = self.last_fetch_count
124
+ if self.query:
125
+ fetch_size = self.rawSizeBeforeQuery
126
+ fetch_count = self.rawLogGroupCountBeforeQuery
116
127
 
117
128
  # throttling control, similar as Java's SDK
118
- if self.last_fetch_count < 100:
129
+ if fetch_size < 1024 * 1024 and fetch_count < 100 and fetch_count < self.max_fetch_log_group_size:
119
130
  is_generate_fetch_task = (time.time() - self.last_fetch_time) > 0.5
120
- elif self.last_fetch_count < 500:
131
+ elif fetch_size < 2 * 1024 * 1024 and fetch_count < 500 and fetch_count < self.max_fetch_log_group_size:
121
132
  is_generate_fetch_task = (time.time() - self.last_fetch_time) > 0.2
122
- elif self.last_fetch_count < 1000:
133
+ elif fetch_size < 4 * 1024 * 1024 and fetch_count < 1000 and fetch_count < self.max_fetch_log_group_size:
123
134
  is_generate_fetch_task = (time.time() - self.last_fetch_time) > 0.05
124
-
125
135
  if is_generate_fetch_task:
126
136
  self.last_fetch_time = time.time()
127
137
  self.fetch_data_future = \
128
138
  self.executor.submit(consumer_fetch_task,
129
139
  self.log_client, self.shard_id, self.next_fetch_cursor,
130
140
  max_fetch_log_group_size=self.max_fetch_log_group_size,
131
- end_cursor=self.fetch_end_cursor)
141
+ end_cursor=self.fetch_end_cursor, query=self.query)
132
142
  else:
133
143
  self.fetch_data_future = None
134
144
  else:
@@ -112,10 +112,13 @@ class InitTaskResult(TaskResult):
112
112
 
113
113
 
114
114
  class FetchTaskResult(TaskResult):
115
- def __init__(self, fetched_log_group_list, cursor):
115
+ def __init__(self, fetched_log_group_list, cursor, raw_size , raw_size_before_query, raw_log_group_count_before_query):
116
116
  super(FetchTaskResult, self).__init__(None)
117
117
  self.fetched_log_group_list = fetched_log_group_list
118
118
  self.cursor = cursor
119
+ self.raw_size = raw_size
120
+ self.raw_size_before_query = raw_size_before_query
121
+ self.raw_log_group_count_before_query = raw_log_group_count_before_query
119
122
 
120
123
  def get_fetched_log_group_list(self):
121
124
  return self.fetched_log_group_list
@@ -123,6 +126,15 @@ class FetchTaskResult(TaskResult):
123
126
  def get_cursor(self):
124
127
  return self.cursor
125
128
 
129
+ def get_raw_size(self):
130
+ return self.raw_size
131
+
132
+ def get_raw_size_before_query(self):
133
+ return self.raw_size_before_query
134
+
135
+ def get_raw_log_group_count_before_query(self):
136
+ return self.raw_log_group_count_before_query
137
+
126
138
 
127
139
  def consumer_process_task(processor, log_groups, check_point_tracker):
128
140
  """
@@ -175,23 +187,31 @@ def consumer_initialize_task(processor, consumer_client, shard_id, cursor_positi
175
187
  return TaskResult(e)
176
188
 
177
189
 
178
- def consumer_fetch_task(loghub_client_adapter, shard_id, cursor, max_fetch_log_group_size=1000, end_cursor=None):
190
+ def consumer_fetch_task(loghub_client_adapter, shard_id, cursor, max_fetch_log_group_size=1000, end_cursor=None, query=None):
179
191
  exception = None
180
192
 
181
193
  for retry_times in range(3):
182
194
  try:
183
- response = loghub_client_adapter.pull_logs(shard_id, cursor, count=max_fetch_log_group_size, end_cursor=end_cursor)
195
+ response = loghub_client_adapter.pull_logs(shard_id, cursor, count=max_fetch_log_group_size, end_cursor=end_cursor, query=query)
184
196
  fetch_log_group_list = response.get_loggroup_list()
185
197
  next_cursor = response.get_next_cursor()
198
+ raw_size = response.get_raw_size()
199
+ raw_size_before_query = 0
200
+ raw_log_group_count_before_query = 0
201
+ if query:
202
+ raw_size_before_query = max(response.get_raw_size_before_query(), 0)
203
+ raw_log_group_count_before_query = max(response.get_raw_log_group_count_before_query(), 0)
186
204
  logger.debug("shard id = %s cursor = %s next cursor = %s size: %s",
187
205
  shard_id, cursor, next_cursor,
188
206
  response.get_log_count())
189
207
  if not next_cursor:
190
- return FetchTaskResult(fetch_log_group_list, cursor)
208
+ return FetchTaskResult(fetch_log_group_list, cursor, raw_size, raw_size_before_query, raw_log_group_count_before_query)
191
209
  else:
192
- return FetchTaskResult(fetch_log_group_list, next_cursor)
210
+ return FetchTaskResult(fetch_log_group_list, next_cursor, raw_size, raw_size_before_query, raw_log_group_count_before_query)
193
211
  except LogException as e:
194
212
  exception = e
213
+ if exception.get_resp_status() == 403:
214
+ time.sleep(5)
195
215
  except Exception as e1:
196
216
  logger.error(e1, exc_info=True)
197
217
  raise Exception(e1)
@@ -196,6 +196,7 @@ class ConsumerWorker(Thread):
196
196
  self.option.cursor_position, self.option.cursor_start_time,
197
197
  executor=self._executor,
198
198
  cursor_end_time=self.option.cursor_end_time,
199
- max_fetch_log_group_size=self.option.max_fetch_log_group_size)
199
+ max_fetch_log_group_size=self.option.max_fetch_log_group_size,
200
+ query=self.option.query)
200
201
  self.shard_consumers[shard_id] = consumer
201
202
  return consumer