in aliyun/log/logclient.py [0:0]
def pull_logs(self, project_name, logstore_name, shard_id, cursor, count=None, end_cursor=None, compress=None, query=None):
""" batch pull log data from log service
Unsuccessful operation will cause an LogException.
:type project_name: string
:param project_name: the Project name
:type logstore_name: string
:param logstore_name: the logstore name
:type shard_id: int
:param shard_id: the shard id
:type cursor: string
:param cursor: the start to cursor to get data
:type count: int
:param count: the required pull log package count, default 1000 packages
:type end_cursor: string
:param end_cursor: the end cursor position to get data
:type compress: boolean
:param compress: if use zip compress for transfer data, default is True
:type query: string
:param query: the SPL query, such as *| where a = 'xxx'
:return: PullLogResponse
:raise: LogException
"""
headers = {}
need_compress = compress is None or compress
if need_compress:
headers['Accept-Encoding'] = str(CompressType.default_compress_type())
else:
headers['Accept-Encoding'] = ''
headers['Accept'] = 'application/x-protobuf'
params = {}
resource = "/logstores/" + logstore_name + "/shards/" + str(shard_id)
params['type'] = 'log'
params['cursor'] = cursor
count = count or 1000
params['count'] = str(count)
if isinstance(query, str) and len(query.strip()) <= 0:
query = None
if query:
params['pullMode'] = "scan_on_stream"
params['query'] = query
if end_cursor:
params['end_cursor'] = end_cursor
(resp, header) = self._send("GET", project_name, None, resource, params, headers, "binary")
raw_size = int(Util.h_v_t(header, 'x-log-bodyrawsize'))
if raw_size <= 0:
return PullLogResponse(None, header)
raw_data = Compressor.decompress_response(header, resp)
return PullLogResponse(raw_data, header)