aliyun.sls package¶
Submodules¶
aliyun.sls.gethistogramsrequest module¶
-
class
aliyun.sls.gethistogramsrequest.
GetHistogramsRequest
(project=None, logstore=None, fromTime=None, toTime=None, topic=None, query=None)[source]¶ Bases:
aliyun.sls.slsrequest.SLSRequest
The request used to get histograms of a query from sls.
Parameters: - project (string) – project name
- logstore (string) – logstore name
- fromTime (int) – the begin time
- toTime (int) – the end time
- topic (string) – topic name of logs
- query (string) – user defined query
aliyun.sls.gethistogramsresponse module¶
-
class
aliyun.sls.gethistogramsresponse.
GetHistogramsResponse
(resp, header)[source]¶ Bases:
aliyun.sls.slsresponse.SLSResponse
The response of the GetHistograms API from sls.
Parameters: - resp (dict) – GetHistogramsResponse HTTP response body
- header (dict) – GetHistogramsResponse HTTP response header
-
get_histograms
()[source]¶ Get histograms on the requested time range: [from, to)
Returns: Histogram list, histograms on the requested time range: [from, to)
-
get_total_count
()[source]¶ Get total logs’ count that current query hits
Returns: int, total logs’ count that current query hits
aliyun.sls.getlogsrequest module¶
-
class
aliyun.sls.getlogsrequest.
GetLogsRequest
(project=None, logstore=None, fromTime=None, toTime=None, topic=None, query=None, line=None, offset=None, reverse=None)[source]¶ Bases:
aliyun.sls.slsrequest.SLSRequest
The request used to get logs by a query from sls.
Parameters: - project (string) – project name
- logstore (string) – logstore name
- fromTime (int) – the begin time
- toTime (int) – the end time
- topic (string) – topic name of logs
- query (string) – user defined query
- line (int) – max line number of return logs
- offset (int) – line offset of return logs
- reverse (bool) – if reverse is set to true, the query will return the latest logs first
-
set_line
(line)[source]¶ Set max line number of return logs
Parameters: line (int) – max line number of return logs
aliyun.sls.getlogsresponse module¶
-
class
aliyun.sls.getlogsresponse.
GetLogsResponse
(resp, header)[source]¶ Bases:
aliyun.sls.slsresponse.SLSResponse
The response of the GetLog API from sls.
Parameters: - resp (dict) – GetLogsResponse HTTP response body
- header (dict) – GetLogsResponse HTTP response header
aliyun.sls.histogram module¶
-
class
aliyun.sls.histogram.
Histogram
(fromTime, toTime, count, progress)[source]¶ The class used to present the result of log histogram status. For every log histogram, it contains : from/to time range, hit log count and query completed status.
Parameters: - fromTime (int) – the begin time
- toTime (int) – the end time
- count (int) – log count of histogram that query hits
- progress (string) – histogram query status(Complete or InComplete)
-
get_count
()[source]¶ Get log count of histogram that query hits
Returns: int, log count of histogram that query hits
aliyun.sls.listlogstoresrequest module¶
-
class
aliyun.sls.listlogstoresrequest.
ListLogstoresRequest
(project=None)[source]¶ Bases:
aliyun.sls.slsrequest.SLSRequest
The request used to list log store from sls.
Parameters: project (string) – project name
aliyun.sls.listlogstoresresponse module¶
-
class
aliyun.sls.listlogstoresresponse.
ListLogstoresResponse
(resp, header)[source]¶ Bases:
aliyun.sls.slsresponse.SLSResponse
The response of the ListLogstores API from sls.
Parameters: - resp (dict) – ListLogstoresResponse HTTP response body
- header (dict) – ListLogstoresResponse HTTP response header
aliyun.sls.listtopicsrequest module¶
-
class
aliyun.sls.listtopicsrequest.
ListTopicsRequest
(project=None, logstore=None, token=None, line=None)[source]¶ Bases:
aliyun.sls.slsrequest.SLSRequest
The request used to get topics of a query from sls.
Parameters: - project (string) – project name
- logstore (string) – logstore name
- token (string) – the start token to list topics
- line (int) – max topic counts to return
aliyun.sls.listtopicsresponse module¶
-
class
aliyun.sls.listtopicsresponse.
ListTopicsResponse
(resp, header)[source]¶ Bases:
aliyun.sls.slsresponse.SLSResponse
The response of the ListTopic API from sls.
Parameters: - resp (dict) – ListTopicsResponse HTTP response body
- header (dict) – ListTopicsResponse HTTP response header
-
get_count
()[source]¶ Get the number of all the topics from the response
Returns: int, the number of all the topics from the response
aliyun.sls.logitem module¶
-
class
aliyun.sls.logitem.
LogItem
(timestamp=None, contents=None)[source]¶ LogItem used to present a log, it contains log time and multiple key/value pairs to present the log contents.
Parameters: - timestamp (int) – time of the log item, the default time is the now time.
- contents (tuple(key-value) list) – the data of the log item, including many (key,value) pairs.
-
push_back
(key, value)[source]¶ Append a key/value pair as a log content to the log
Parameters: - key (string) – log content key
- value (string) – log content value
aliyun.sls.putlogsrequest module¶
-
class
aliyun.sls.putlogsrequest.
PutLogsRequest
(project=None, logstore=None, topic=None, source=None, logitems=None)[source]¶ Bases:
aliyun.sls.slsrequest.SLSRequest
The request used to send data to sls.
Parameters: - project (string) – project name
- logstore (string) – logstore name
- topic (string) – topic name
- source (string) – source of the logs
- logitems (list<LogItem>) – log data
aliyun.sls.putlogsresponse module¶
-
class
aliyun.sls.putlogsresponse.
PutLogsResponse
(header)[source]¶ Bases:
aliyun.sls.slsresponse.SLSResponse
The response of the PutLogs API from sls.
Parameters: header (dict) – PutLogsResponse HTTP response header
aliyun.sls.queriedlog module¶
aliyun.sls.sls_logs_pb2 module¶
-
class
aliyun.sls.sls_logs_pb2.
Log
(**kwargs)[source]¶ Bases:
google.protobuf.message.Message
-
ByteSize
()¶
-
CONTENTS_FIELD_NUMBER
= 2¶
-
Clear
()¶
-
ClearField
(field_name)¶
-
class
Content
(**kwargs)[source]¶ Bases:
google.protobuf.message.Message
-
ByteSize
()¶
-
Clear
()¶
-
ClearField
(field_name)¶
-
DESCRIPTOR
= <google.protobuf.descriptor.Descriptor object at 0x0391AF70>¶
-
FindInitializationErrors
()¶ Finds required fields which are not initialized.
- Returns:
- A list of strings. Each string is a path to an uninitialized field from the top-level message, e.g. “foo.bar[5].baz”.
-
static
FromString
(s)¶
-
HasField
(field_name)¶
-
IsInitialized
(errors=None)¶ Checks if all required fields of a message are set.
- Args:
- errors: A list which, if provided, will be populated with the field
- paths of all missing required fields.
- Returns:
- True iff the specified message has all required fields set.
-
KEY_FIELD_NUMBER
= 1¶
-
Key
¶ Magic attribute generated for “Key” proto field.
-
ListFields
()¶
-
MergeFrom
(msg)¶
-
MergeFromString
(serialized)¶
-
static
RegisterExtension
(extension_handle)¶
-
SerializePartialToString
()¶
-
SerializeToString
()¶
-
SetInParent
()¶ Sets the _cached_byte_size_dirty bit to true, and propagates this to our listener iff this was a state change.
-
VALUE_FIELD_NUMBER
= 2¶
-
Value
¶ Magic attribute generated for “Value” proto field.
-
WhichOneof
(oneof_name)¶ Returns the name of the currently set field inside a oneof, or None.
-
-
Log.
Contents
¶ Magic attribute generated for “Contents” proto field.
-
Log.
DESCRIPTOR
= <google.protobuf.descriptor.Descriptor object at 0x0391AFD0>¶
-
Log.
FindInitializationErrors
()¶ Finds required fields which are not initialized.
- Returns:
- A list of strings. Each string is a path to an uninitialized field from the top-level message, e.g. “foo.bar[5].baz”.
-
static
Log.
FromString
(s)¶
-
Log.
HasField
(field_name)¶
-
Log.
IsInitialized
(errors=None)¶ Checks if all required fields of a message are set.
- Args:
- errors: A list which, if provided, will be populated with the field
- paths of all missing required fields.
- Returns:
- True iff the specified message has all required fields set.
-
Log.
ListFields
()¶
-
Log.
MergeFrom
(msg)¶
-
Log.
MergeFromString
(serialized)¶
-
static
Log.
RegisterExtension
(extension_handle)¶
-
Log.
SerializePartialToString
()¶
-
Log.
SerializeToString
()¶
-
Log.
SetInParent
()¶ Sets the _cached_byte_size_dirty bit to true, and propagates this to our listener iff this was a state change.
-
Log.
TIME_FIELD_NUMBER
= 1¶
-
Log.
Time
¶ Magic attribute generated for “Time” proto field.
-
Log.
WhichOneof
(oneof_name)¶ Returns the name of the currently set field inside a oneof, or None.
-
-
class
aliyun.sls.sls_logs_pb2.
LogGroup
(**kwargs)[source]¶ Bases:
google.protobuf.message.Message
-
ByteSize
()¶
-
Clear
()¶
-
ClearField
(field_name)¶
-
DESCRIPTOR
= <google.protobuf.descriptor.Descriptor object at 0x0391F090>¶
-
FindInitializationErrors
()¶ Finds required fields which are not initialized.
- Returns:
- A list of strings. Each string is a path to an uninitialized field from the top-level message, e.g. “foo.bar[5].baz”.
-
static
FromString
(s)¶
-
HasField
(field_name)¶
-
IsInitialized
(errors=None)¶ Checks if all required fields of a message are set.
- Args:
- errors: A list which, if provided, will be populated with the field
- paths of all missing required fields.
- Returns:
- True iff the specified message has all required fields set.
-
LOGS_FIELD_NUMBER
= 1¶
-
ListFields
()¶
-
Logs
¶ Magic attribute generated for “Logs” proto field.
-
MergeFrom
(msg)¶
-
MergeFromString
(serialized)¶
-
RESERVED_FIELD_NUMBER
= 2¶
-
static
RegisterExtension
(extension_handle)¶
-
Reserved
¶ Magic attribute generated for “Reserved” proto field.
-
SOURCE_FIELD_NUMBER
= 4¶
-
SerializePartialToString
()¶
-
SerializeToString
()¶
-
SetInParent
()¶ Sets the _cached_byte_size_dirty bit to true, and propagates this to our listener iff this was a state change.
-
Source
¶ Magic attribute generated for “Source” proto field.
-
TOPIC_FIELD_NUMBER
= 3¶
-
Topic
¶ Magic attribute generated for “Topic” proto field.
-
WhichOneof
(oneof_name)¶ Returns the name of the currently set field inside a oneof, or None.
-
aliyun.sls.slsclient module¶
-
class
aliyun.sls.slsclient.
SLSClient
(endpoint, accessKeyId, accessKey)[source]¶ Bases:
object
Construct the SLSClient with endpoint, accessKeyId, accessKey.
Parameters: - endpoint (string) – SLS host name, for example, http://ch-hangzhou.sls.aliyuncs.com
- accessKeyId (string) – aliyun accessKeyId
- accessKey (string) – aliyun accessKey
-
Version
= '0.4.0'¶
-
get_histograms
(request)[source]¶ Get histograms of requested query from SLS. Unsuccessful opertaion will cause an SLSException.
Parameters: request (GetHistogramsRequest) – the GetHistograms request parameters class. Returns: GetHistogramsResponse Raise: SLSException
-
get_logs
(request)[source]¶ Get logs from SLS. Unsuccessful opertaion will cause an SLSException.
Parameters: request (GetLogsRequest) – the GetLogs request parameters class. Returns: GetLogsResponse Raise: SLSException
-
list_logstores
(request)[source]¶ List all logstores of requested project. Unsuccessful opertaion will cause an SLSException.
Parameters: request (ListLogstoresRequest) – the ListLogstores request parameters class. Returns: ListLogStoresResponse Raise: SLSException
-
list_topics
(request)[source]¶ List all topics in a logstore. Unsuccessful opertaion will cause an SLSException.
Parameters: request (ListTopicsRequest) – the ListTopics request parameters class. Returns: ListTopicsResponse Raise: SLSException
-
put_logs
(request)[source]¶ Put logs to SLS. Unsuccessful opertaion will cause an SLSException.
Parameters: request (PutLogsRequest) – the PutLogs request parameters class Returns: PutLogsResponse Raise: SLSException
-
aliyun.sls.slsclient.
USER_AGENT
= 'sls-python-sdk-v-0.4.6'¶ SlsClient class is the main class in the SDK. It can be used to communicate with SLS server to put/get data.
Author: sls_dev
aliyun.sls.slsexception module¶
-
exception
aliyun.sls.slsexception.
SLSException
(errorCode, errorMessage, requestId='')[source]¶ Bases:
exceptions.Exception
The Exception of the sls request & response.
Parameters: - errorCode (string) – SLS error code
- errorMessage (string) – detailed information for the exception
- requestId (string) – the request id of the response, ‘’ is set if client error
aliyun.sls.slsrequest module¶
aliyun.sls.slsresponse module¶
-
class
aliyun.sls.slsresponse.
SLSResponse
(headers)[source]¶ The base response class of all sls response.
Parameters: headers (dict) – HTTP response header -
get_header
(key)[source]¶ Get specified http header of the response, ‘’ will be return if not set.
Parameters: key (string) – the key to get header Returns: string, response header
-