klog-sdk


Nameklog-sdk JSON
Version 0.9.2 PyPI version JSON
download
home_pagehttps://gitee.com/klogsdk/klog-python-sdk
SummaryKingsoft Log Service SDK
upload_time2023-10-19 12:28:37
maintainer
docs_urlNone
authorKLog Developers
requires_python>=2.7
licenseMIT
keywords klog klog-sdk kingsoft-cloud klog-python-sdk
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 金山云日志服务(KLog) SDK for python使用指南

+ [金山云日志服务产品简介](https://www.ksyun.com/nv/product/KLog.html)
+ [金山云日志服务产品文档](https://docs.ksyun.com/products/123)

## 安装
有两种安装方式,通常情况下,使用在线安装即可。支持`python 2.7`和`python 3.x`。

### 在线安装
```shell
pip install klog-sdk
```

`pip install klog-sdk`会自动安装`lz4`和`protobuf`这两个依赖。如果自动安装依赖出现问题,可以尝试手动安装依赖:
```shell
pip install lz4
# python 3可使用protobuf的最新版本
# python 2.7可使用的protobuf版本最高为3.17.3
pip install protobuf==3.17.3
```

### 本地安装
```shell 
# 通过git下载SDK到本地
git clone https://gitee.com/klogsdk/klog-python-sdk.git

# 进入klog-python-sdk目录
cd klog-python-sdk

# 安装SDK
python setup.py install
```

## 使用方法
### 初始化KLog客户端
KLog客户端是线程安全的。在整个进程内您可以只创建一个KLog客户端,并重复使用。
```python
from klog import Client

# 您在金山云的主账户或子账户的 ACCESS KEY ID
access_key = "your secret_key"

# 您在金山云的主账户或子账户的 SECRET KEY ID
secret_key = "your secret_key"

# 您的日志项目所在地区的入口地址,该地址可以在金山云控制台日志服务的项目概览中查到。
# 支持 http 和 https
endpoint = "https://klog-cn-beijing.ksyun.com"

# 创建KLog客户端
client = Client(endpoint, access_key, secret_key)
```

### 上传文本类型日志
```python
# 异步发送一条文本日志
client.push("your_project_name", "your_pool_name", "your_hostname", "your_log_file_path", "your log message")
```

### 上传dict类型日志
KLog支持dict类型的日志。注意:同一日志池各条日志的dict数据结构应该保持一致。
```python
# 异步发送一条dict日志
client.push("your_project_name", "your_pool_name", "your_hostname", "your_log_file_path", {"k1": "value1", "k2": "value2"})
```

### 异步发送
KLog客户端默认是异步发送数据的,客户端内部的发送间隔为每2秒,或每批达到3MB,或每批达到4096条。 这样的好处有:
+ 客户端内部自动将最近的多条日志一起压缩并批量发送。
+ 不会阻塞其它逻辑(除非发送缓冲队列满了)
+ 可以配置各种发送策略

注意:
+ 程序退出时,需调用一次`Client.flush()`。

```python
# 立即发送客户端缓冲队列中还未发送的日志。
# 参数timeout可以为等待秒数或None。
# timeout为None时,表示阻塞到发送成功或发送结束为止。这种情况下的发送失败重试策略与Client的构造参数一致。
client.flush(timeout=10)
```

### 同步发送
+ 在调用`Client.push()`之后调用`Client.flush()`,可实现同步发送。

## 管理端接口使用方法

### 说明
1. 所有的返回对象都继承了`klog.cli.models.KlogResponse`。 
   1. 可以通过`get_data()`获取response body的dict, 某些接口可能为`None`。
   2. 可以通过`get_request_id()`获取请求的`request_id`。
   3. 可以通过`get_status()`获取请求操作的状态。
```python
class Serializer(object):
    def serialize(self):
        pass

    def deserialize(self):
        pass


class KlogResponse(Serializer):
    def __init__(self, data=None, request_id="", status="success"):
        self.request_id = request_id
        self._data = data
        self.status = status

    def __str__(self):
        d = {} if self.get_data() is None else self.get_data()
        return "request_id: {} data: {} status: {}".format(self.request_id, d, self.status)

    def get_data(self):
        return self._data

    def get_request_id(self):
        return self.request_id

    def get_status(self):
        return self.status
```
2. 所有的返回值都可以像使用对象字段那样使用返回值的字段。
3. 以下的例子可以适用于所有接口。

### 日志查询
```python
from klog import client
from klog.cli import models

c = client.Client()

# 创建日志查询对象
# 如果是多日志池的查询,则log_pool_name使用逗号分隔开
req = models.GetLogsRequest(project_name="project_name", log_pool_name="pool1,pool2,pool3",
                            start_time=(datetime.now() - timedelta(minutes=15)).timestamp() * 1000,
                            end_time=datetime.now().timestamp() * 1000)

res = c.GetLogs(req)
# 可选操作, 序列化是 将 request_id、http response body、操作状态,序列化成dict
print(res.serialize())

# 获取http response body的dict
print(res.get_data())

# 也可以直接使用对象
for l in res.Logs:
    # l 也是一个对象, l中的字段就是日志中的字段, 字段可以参照 klog 官网文档
    print(l.serialize())

```

### 获取工程列表
```python
from klog import client
from klog.cli import models

c = client.Client()

# 创建获取工程列表对象
req = models.ListProjectsRequest(0, 10)

# 执行对应操作
res = c.ListProjects(req)

# 可选操作, 序列化是 将 request_id、http response body、操作状态,序列化成dict
print(res.serialize())

# 获取http response body的dict
print(res.get_data())

# 也可使用对象
for project in res.Projects:
    # project 也是对象, 所以有ProjectName等属性
    print(project.ProjectName)
```

## 参数说明
### Client(endpoint, access_key, secret_key, queue_size=2000, drop_when_queue_is_full=False, rate_limit=0, down_sample_rate=1, max_retries=-1, retry_interval=-1, external_logger=None, logger_level=logging.WARNING)
创建一个KLog客户端,参数如下:
+ `endpoint` 必填。您的日志项目所在地区的入口地址,该地址可以在金山云控制台日志服务的项目概览中查到。支持`http`和`https`。
+ `access_key` 必填。您在金山云的主账户或子账户的`ACCESS KEY ID`。
+ `secret_key` 必填。您在金山云的主账户或子账户的`SECRET KEY ID`。
+ `queue_size` 客户端内部缓冲队列长度。默认为2000条日志。
+ `drop_when_queue_is_full` 默认情况下,当缓冲队列满时,`client.push()`会阻塞并等待空位。如果设置为`True`,则不等待,直接丢弃日志。默认为`False`
+ `rate_limit` 限制发送速率为每秒多少条。此项配置可降低CPU使用率,但会降低发送速率,在日志较多时,缓冲队列可能会满。默认为0,即不限制。
+ `down_sample_rate` 降采样率。例如设置为0.15时,将只发送15%的日志,其余丢弃。此项配置可降低CPU使用率。默认为1,即发送所有日志。
+ `max_retries` 发送失败后的重试次数,达到次数后如果仍然失败则丢弃日志。默认为-1,即永远重试。
+ `retry_interval` 发送失败后的重试间隔秒数。支持浮点数。默认为-1,即逐步增加重试间隔(但不会超过60秒)。
+ `external_logger` 设置客户端输出自身运行状态的日志对象。默认为None,即使用logging模块并打印到stdout。
+ `logger_level` 客户端内部日志打印level。默认为logging.WARNING。

### Client.push(project_name, log_pool_name, source, filename, data, timestamp=None)
上传一条日志。参数如下:
+ `project_name` 必填。项目名称
+ `log_pool_name` 必填。日志池名称
+ `source` 日志来源,如主机名、ip等,用于进行日志上下文查询
+ `filename` 日志文件路径,用于进行日志上下文查询
+ `data` 必填。日志数据,字符串或dict类型。
+ `timestamp` 日志时间戳(毫秒值整数)。默认取当前时间。

### Client.flush(timeout=None)
立即发送客户端缓冲队列中还未发送的日志。参数如下:
+ `timeout` 最大等待秒数,可以是小数。为None时,表示阻塞到发送成功或发送结束为止。这种情况下的发送失败重试策略与Client的构造参数一致。默认为None。

            

Raw data

            {
    "_id": null,
    "home_page": "https://gitee.com/klogsdk/klog-python-sdk",
    "name": "klog-sdk",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=2.7",
    "maintainer_email": "",
    "keywords": "klog,klog-sdk,kingsoft-cloud,klog-python-sdk",
    "author": "KLog Developers",
    "author_email": "ksc-klog@kingsoft.com",
    "download_url": "https://files.pythonhosted.org/packages/f7/21/959c76fef02b9dff4930ee1422537f6ef5b8868f962605886984dc9e763c/klog-sdk-0.9.2.tar.gz",
    "platform": null,
    "description": "# \u91d1\u5c71\u4e91\u65e5\u5fd7\u670d\u52a1(KLog) SDK for python\u4f7f\u7528\u6307\u5357\r\n\r\n+ [\u91d1\u5c71\u4e91\u65e5\u5fd7\u670d\u52a1\u4ea7\u54c1\u7b80\u4ecb](https://www.ksyun.com/nv/product/KLog.html)\r\n+ [\u91d1\u5c71\u4e91\u65e5\u5fd7\u670d\u52a1\u4ea7\u54c1\u6587\u6863](https://docs.ksyun.com/products/123)\r\n\r\n## \u5b89\u88c5\r\n\u6709\u4e24\u79cd\u5b89\u88c5\u65b9\u5f0f\uff0c\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u4f7f\u7528\u5728\u7ebf\u5b89\u88c5\u5373\u53ef\u3002\u652f\u6301`python 2.7`\u548c`python 3.x`\u3002\r\n\r\n### \u5728\u7ebf\u5b89\u88c5\r\n```shell\r\npip install klog-sdk\r\n```\r\n\r\n`pip install klog-sdk`\u4f1a\u81ea\u52a8\u5b89\u88c5`lz4`\u548c`protobuf`\u8fd9\u4e24\u4e2a\u4f9d\u8d56\u3002\u5982\u679c\u81ea\u52a8\u5b89\u88c5\u4f9d\u8d56\u51fa\u73b0\u95ee\u9898\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u624b\u52a8\u5b89\u88c5\u4f9d\u8d56\uff1a\r\n```shell\r\npip install lz4\r\n# python 3\u53ef\u4f7f\u7528protobuf\u7684\u6700\u65b0\u7248\u672c\r\n# python 2.7\u53ef\u4f7f\u7528\u7684protobuf\u7248\u672c\u6700\u9ad8\u4e3a3.17.3\r\npip install protobuf==3.17.3\r\n```\r\n\r\n### \u672c\u5730\u5b89\u88c5\r\n```shell \r\n# \u901a\u8fc7git\u4e0b\u8f7dSDK\u5230\u672c\u5730\r\ngit clone https://gitee.com/klogsdk/klog-python-sdk.git\r\n\r\n# \u8fdb\u5165klog-python-sdk\u76ee\u5f55\r\ncd klog-python-sdk\r\n\r\n# \u5b89\u88c5SDK\r\npython setup.py install\r\n```\r\n\r\n## \u4f7f\u7528\u65b9\u6cd5\r\n### \u521d\u59cb\u5316KLog\u5ba2\u6237\u7aef\r\nKLog\u5ba2\u6237\u7aef\u662f\u7ebf\u7a0b\u5b89\u5168\u7684\u3002\u5728\u6574\u4e2a\u8fdb\u7a0b\u5185\u60a8\u53ef\u4ee5\u53ea\u521b\u5efa\u4e00\u4e2aKLog\u5ba2\u6237\u7aef\uff0c\u5e76\u91cd\u590d\u4f7f\u7528\u3002\r\n```python\r\nfrom klog import Client\r\n\r\n# \u60a8\u5728\u91d1\u5c71\u4e91\u7684\u4e3b\u8d26\u6237\u6216\u5b50\u8d26\u6237\u7684 ACCESS KEY ID\r\naccess_key = \"your secret_key\"\r\n\r\n# \u60a8\u5728\u91d1\u5c71\u4e91\u7684\u4e3b\u8d26\u6237\u6216\u5b50\u8d26\u6237\u7684 SECRET KEY ID\r\nsecret_key = \"your secret_key\"\r\n\r\n# \u60a8\u7684\u65e5\u5fd7\u9879\u76ee\u6240\u5728\u5730\u533a\u7684\u5165\u53e3\u5730\u5740\uff0c\u8be5\u5730\u5740\u53ef\u4ee5\u5728\u91d1\u5c71\u4e91\u63a7\u5236\u53f0\u65e5\u5fd7\u670d\u52a1\u7684\u9879\u76ee\u6982\u89c8\u4e2d\u67e5\u5230\u3002\r\n# \u652f\u6301 http \u548c https\r\nendpoint = \"https://klog-cn-beijing.ksyun.com\"\r\n\r\n# \u521b\u5efaKLog\u5ba2\u6237\u7aef\r\nclient = Client(endpoint, access_key, secret_key)\r\n```\r\n\r\n### \u4e0a\u4f20\u6587\u672c\u7c7b\u578b\u65e5\u5fd7\r\n```python\r\n# \u5f02\u6b65\u53d1\u9001\u4e00\u6761\u6587\u672c\u65e5\u5fd7\r\nclient.push(\"your_project_name\", \"your_pool_name\", \"your_hostname\", \"your_log_file_path\", \"your log message\")\r\n```\r\n\r\n### \u4e0a\u4f20dict\u7c7b\u578b\u65e5\u5fd7\r\nKLog\u652f\u6301dict\u7c7b\u578b\u7684\u65e5\u5fd7\u3002\u6ce8\u610f\uff1a\u540c\u4e00\u65e5\u5fd7\u6c60\u5404\u6761\u65e5\u5fd7\u7684dict\u6570\u636e\u7ed3\u6784\u5e94\u8be5\u4fdd\u6301\u4e00\u81f4\u3002\r\n```python\r\n# \u5f02\u6b65\u53d1\u9001\u4e00\u6761dict\u65e5\u5fd7\r\nclient.push(\"your_project_name\", \"your_pool_name\", \"your_hostname\", \"your_log_file_path\", {\"k1\": \"value1\", \"k2\": \"value2\"})\r\n```\r\n\r\n### \u5f02\u6b65\u53d1\u9001\r\nKLog\u5ba2\u6237\u7aef\u9ed8\u8ba4\u662f\u5f02\u6b65\u53d1\u9001\u6570\u636e\u7684\uff0c\u5ba2\u6237\u7aef\u5185\u90e8\u7684\u53d1\u9001\u95f4\u9694\u4e3a\u6bcf2\u79d2\uff0c\u6216\u6bcf\u6279\u8fbe\u52303MB\uff0c\u6216\u6bcf\u6279\u8fbe\u52304096\u6761\u3002 \u8fd9\u6837\u7684\u597d\u5904\u6709\uff1a\r\n+ \u5ba2\u6237\u7aef\u5185\u90e8\u81ea\u52a8\u5c06\u6700\u8fd1\u7684\u591a\u6761\u65e5\u5fd7\u4e00\u8d77\u538b\u7f29\u5e76\u6279\u91cf\u53d1\u9001\u3002\r\n+ \u4e0d\u4f1a\u963b\u585e\u5176\u5b83\u903b\u8f91(\u9664\u975e\u53d1\u9001\u7f13\u51b2\u961f\u5217\u6ee1\u4e86)\r\n+ \u53ef\u4ee5\u914d\u7f6e\u5404\u79cd\u53d1\u9001\u7b56\u7565\r\n\r\n\u6ce8\u610f\uff1a\r\n+ \u7a0b\u5e8f\u9000\u51fa\u65f6\uff0c\u9700\u8c03\u7528\u4e00\u6b21`Client.flush()`\u3002\r\n\r\n```python\r\n# \u7acb\u5373\u53d1\u9001\u5ba2\u6237\u7aef\u7f13\u51b2\u961f\u5217\u4e2d\u8fd8\u672a\u53d1\u9001\u7684\u65e5\u5fd7\u3002\r\n# \u53c2\u6570timeout\u53ef\u4ee5\u4e3a\u7b49\u5f85\u79d2\u6570\u6216None\u3002\r\n# timeout\u4e3aNone\u65f6\uff0c\u8868\u793a\u963b\u585e\u5230\u53d1\u9001\u6210\u529f\u6216\u53d1\u9001\u7ed3\u675f\u4e3a\u6b62\u3002\u8fd9\u79cd\u60c5\u51b5\u4e0b\u7684\u53d1\u9001\u5931\u8d25\u91cd\u8bd5\u7b56\u7565\u4e0eClient\u7684\u6784\u9020\u53c2\u6570\u4e00\u81f4\u3002\r\nclient.flush(timeout=10)\r\n```\r\n\r\n### \u540c\u6b65\u53d1\u9001\r\n+ \u5728\u8c03\u7528`Client.push()`\u4e4b\u540e\u8c03\u7528`Client.flush()`\uff0c\u53ef\u5b9e\u73b0\u540c\u6b65\u53d1\u9001\u3002\r\n\r\n## \u7ba1\u7406\u7aef\u63a5\u53e3\u4f7f\u7528\u65b9\u6cd5\r\n\r\n### \u8bf4\u660e\r\n1. \u6240\u6709\u7684\u8fd4\u56de\u5bf9\u8c61\u90fd\u7ee7\u627f\u4e86`klog.cli.models.KlogResponse`\u3002 \r\n   1. \u53ef\u4ee5\u901a\u8fc7`get_data()`\u83b7\u53d6response body\u7684dict, \u67d0\u4e9b\u63a5\u53e3\u53ef\u80fd\u4e3a`None`\u3002\r\n   2. \u53ef\u4ee5\u901a\u8fc7`get_request_id()`\u83b7\u53d6\u8bf7\u6c42\u7684`request_id`\u3002\r\n   3. \u53ef\u4ee5\u901a\u8fc7`get_status()`\u83b7\u53d6\u8bf7\u6c42\u64cd\u4f5c\u7684\u72b6\u6001\u3002\r\n```python\r\nclass Serializer(object):\r\n    def serialize(self):\r\n        pass\r\n\r\n    def deserialize(self):\r\n        pass\r\n\r\n\r\nclass KlogResponse(Serializer):\r\n    def __init__(self, data=None, request_id=\"\", status=\"success\"):\r\n        self.request_id = request_id\r\n        self._data = data\r\n        self.status = status\r\n\r\n    def __str__(self):\r\n        d = {} if self.get_data() is None else self.get_data()\r\n        return \"request_id: {} data: {} status: {}\".format(self.request_id, d, self.status)\r\n\r\n    def get_data(self):\r\n        return self._data\r\n\r\n    def get_request_id(self):\r\n        return self.request_id\r\n\r\n    def get_status(self):\r\n        return self.status\r\n```\r\n2. \u6240\u6709\u7684\u8fd4\u56de\u503c\u90fd\u53ef\u4ee5\u50cf\u4f7f\u7528\u5bf9\u8c61\u5b57\u6bb5\u90a3\u6837\u4f7f\u7528\u8fd4\u56de\u503c\u7684\u5b57\u6bb5\u3002\r\n3. \u4ee5\u4e0b\u7684\u4f8b\u5b50\u53ef\u4ee5\u9002\u7528\u4e8e\u6240\u6709\u63a5\u53e3\u3002\r\n\r\n### \u65e5\u5fd7\u67e5\u8be2\r\n```python\r\nfrom klog import client\r\nfrom klog.cli import models\r\n\r\nc = client.Client()\r\n\r\n# \u521b\u5efa\u65e5\u5fd7\u67e5\u8be2\u5bf9\u8c61\r\n# \u5982\u679c\u662f\u591a\u65e5\u5fd7\u6c60\u7684\u67e5\u8be2\uff0c\u5219log_pool_name\u4f7f\u7528\u9017\u53f7\u5206\u9694\u5f00\r\nreq = models.GetLogsRequest(project_name=\"project_name\", log_pool_name=\"pool1,pool2,pool3\",\r\n                            start_time=(datetime.now() - timedelta(minutes=15)).timestamp() * 1000,\r\n                            end_time=datetime.now().timestamp() * 1000)\r\n\r\nres = c.GetLogs(req)\r\n# \u53ef\u9009\u64cd\u4f5c, \u5e8f\u5217\u5316\u662f \u5c06 request_id\u3001http response body\u3001\u64cd\u4f5c\u72b6\u6001\uff0c\u5e8f\u5217\u5316\u6210dict\r\nprint(res.serialize())\r\n\r\n# \u83b7\u53d6http response body\u7684dict\r\nprint(res.get_data())\r\n\r\n# \u4e5f\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\u5bf9\u8c61\r\nfor l in res.Logs:\r\n    # l \u4e5f\u662f\u4e00\u4e2a\u5bf9\u8c61, l\u4e2d\u7684\u5b57\u6bb5\u5c31\u662f\u65e5\u5fd7\u4e2d\u7684\u5b57\u6bb5, \u5b57\u6bb5\u53ef\u4ee5\u53c2\u7167 klog \u5b98\u7f51\u6587\u6863\r\n    print(l.serialize())\r\n\r\n```\r\n\r\n### \u83b7\u53d6\u5de5\u7a0b\u5217\u8868\r\n```python\r\nfrom klog import client\r\nfrom klog.cli import models\r\n\r\nc = client.Client()\r\n\r\n# \u521b\u5efa\u83b7\u53d6\u5de5\u7a0b\u5217\u8868\u5bf9\u8c61\r\nreq = models.ListProjectsRequest(0, 10)\r\n\r\n# \u6267\u884c\u5bf9\u5e94\u64cd\u4f5c\r\nres = c.ListProjects(req)\r\n\r\n# \u53ef\u9009\u64cd\u4f5c, \u5e8f\u5217\u5316\u662f \u5c06 request_id\u3001http response body\u3001\u64cd\u4f5c\u72b6\u6001\uff0c\u5e8f\u5217\u5316\u6210dict\r\nprint(res.serialize())\r\n\r\n# \u83b7\u53d6http response body\u7684dict\r\nprint(res.get_data())\r\n\r\n# \u4e5f\u53ef\u4f7f\u7528\u5bf9\u8c61\r\nfor project in res.Projects:\r\n    # project \u4e5f\u662f\u5bf9\u8c61, \u6240\u4ee5\u6709ProjectName\u7b49\u5c5e\u6027\r\n    print(project.ProjectName)\r\n```\r\n\r\n## \u53c2\u6570\u8bf4\u660e\r\n### Client(endpoint, access_key, secret_key, queue_size=2000, drop_when_queue_is_full=False, rate_limit=0, down_sample_rate=1, max_retries=-1, retry_interval=-1, external_logger=None, logger_level=logging.WARNING)\r\n\u521b\u5efa\u4e00\u4e2aKLog\u5ba2\u6237\u7aef\uff0c\u53c2\u6570\u5982\u4e0b\uff1a\r\n+ `endpoint` \u5fc5\u586b\u3002\u60a8\u7684\u65e5\u5fd7\u9879\u76ee\u6240\u5728\u5730\u533a\u7684\u5165\u53e3\u5730\u5740\uff0c\u8be5\u5730\u5740\u53ef\u4ee5\u5728\u91d1\u5c71\u4e91\u63a7\u5236\u53f0\u65e5\u5fd7\u670d\u52a1\u7684\u9879\u76ee\u6982\u89c8\u4e2d\u67e5\u5230\u3002\u652f\u6301`http`\u548c`https`\u3002\r\n+ `access_key` \u5fc5\u586b\u3002\u60a8\u5728\u91d1\u5c71\u4e91\u7684\u4e3b\u8d26\u6237\u6216\u5b50\u8d26\u6237\u7684`ACCESS KEY ID`\u3002\r\n+ `secret_key` \u5fc5\u586b\u3002\u60a8\u5728\u91d1\u5c71\u4e91\u7684\u4e3b\u8d26\u6237\u6216\u5b50\u8d26\u6237\u7684`SECRET KEY ID`\u3002\r\n+ `queue_size` \u5ba2\u6237\u7aef\u5185\u90e8\u7f13\u51b2\u961f\u5217\u957f\u5ea6\u3002\u9ed8\u8ba4\u4e3a2000\u6761\u65e5\u5fd7\u3002\r\n+ `drop_when_queue_is_full` \u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5f53\u7f13\u51b2\u961f\u5217\u6ee1\u65f6\uff0c`client.push()`\u4f1a\u963b\u585e\u5e76\u7b49\u5f85\u7a7a\u4f4d\u3002\u5982\u679c\u8bbe\u7f6e\u4e3a`True`\uff0c\u5219\u4e0d\u7b49\u5f85\uff0c\u76f4\u63a5\u4e22\u5f03\u65e5\u5fd7\u3002\u9ed8\u8ba4\u4e3a`False`\r\n+ `rate_limit` \u9650\u5236\u53d1\u9001\u901f\u7387\u4e3a\u6bcf\u79d2\u591a\u5c11\u6761\u3002\u6b64\u9879\u914d\u7f6e\u53ef\u964d\u4f4eCPU\u4f7f\u7528\u7387\uff0c\u4f46\u4f1a\u964d\u4f4e\u53d1\u9001\u901f\u7387\uff0c\u5728\u65e5\u5fd7\u8f83\u591a\u65f6\uff0c\u7f13\u51b2\u961f\u5217\u53ef\u80fd\u4f1a\u6ee1\u3002\u9ed8\u8ba4\u4e3a0\uff0c\u5373\u4e0d\u9650\u5236\u3002\r\n+ `down_sample_rate` \u964d\u91c7\u6837\u7387\u3002\u4f8b\u5982\u8bbe\u7f6e\u4e3a0.15\u65f6\uff0c\u5c06\u53ea\u53d1\u900115%\u7684\u65e5\u5fd7\uff0c\u5176\u4f59\u4e22\u5f03\u3002\u6b64\u9879\u914d\u7f6e\u53ef\u964d\u4f4eCPU\u4f7f\u7528\u7387\u3002\u9ed8\u8ba4\u4e3a1\uff0c\u5373\u53d1\u9001\u6240\u6709\u65e5\u5fd7\u3002\r\n+ `max_retries` \u53d1\u9001\u5931\u8d25\u540e\u7684\u91cd\u8bd5\u6b21\u6570\uff0c\u8fbe\u5230\u6b21\u6570\u540e\u5982\u679c\u4ecd\u7136\u5931\u8d25\u5219\u4e22\u5f03\u65e5\u5fd7\u3002\u9ed8\u8ba4\u4e3a-1\uff0c\u5373\u6c38\u8fdc\u91cd\u8bd5\u3002\r\n+ `retry_interval` \u53d1\u9001\u5931\u8d25\u540e\u7684\u91cd\u8bd5\u95f4\u9694\u79d2\u6570\u3002\u652f\u6301\u6d6e\u70b9\u6570\u3002\u9ed8\u8ba4\u4e3a-1\uff0c\u5373\u9010\u6b65\u589e\u52a0\u91cd\u8bd5\u95f4\u9694(\u4f46\u4e0d\u4f1a\u8d85\u8fc760\u79d2)\u3002\r\n+ `external_logger` \u8bbe\u7f6e\u5ba2\u6237\u7aef\u8f93\u51fa\u81ea\u8eab\u8fd0\u884c\u72b6\u6001\u7684\u65e5\u5fd7\u5bf9\u8c61\u3002\u9ed8\u8ba4\u4e3aNone\uff0c\u5373\u4f7f\u7528logging\u6a21\u5757\u5e76\u6253\u5370\u5230stdout\u3002\r\n+ `logger_level` \u5ba2\u6237\u7aef\u5185\u90e8\u65e5\u5fd7\u6253\u5370level\u3002\u9ed8\u8ba4\u4e3alogging.WARNING\u3002\r\n\r\n### Client.push(project_name, log_pool_name, source, filename, data, timestamp=None)\r\n\u4e0a\u4f20\u4e00\u6761\u65e5\u5fd7\u3002\u53c2\u6570\u5982\u4e0b\uff1a\r\n+ `project_name` \u5fc5\u586b\u3002\u9879\u76ee\u540d\u79f0\r\n+ `log_pool_name` \u5fc5\u586b\u3002\u65e5\u5fd7\u6c60\u540d\u79f0\r\n+ `source` \u65e5\u5fd7\u6765\u6e90\uff0c\u5982\u4e3b\u673a\u540d\u3001ip\u7b49\uff0c\u7528\u4e8e\u8fdb\u884c\u65e5\u5fd7\u4e0a\u4e0b\u6587\u67e5\u8be2\r\n+ `filename` \u65e5\u5fd7\u6587\u4ef6\u8def\u5f84\uff0c\u7528\u4e8e\u8fdb\u884c\u65e5\u5fd7\u4e0a\u4e0b\u6587\u67e5\u8be2\r\n+ `data` \u5fc5\u586b\u3002\u65e5\u5fd7\u6570\u636e\uff0c\u5b57\u7b26\u4e32\u6216dict\u7c7b\u578b\u3002\r\n+ `timestamp` \u65e5\u5fd7\u65f6\u95f4\u6233(\u6beb\u79d2\u503c\u6574\u6570)\u3002\u9ed8\u8ba4\u53d6\u5f53\u524d\u65f6\u95f4\u3002\r\n\r\n### Client.flush(timeout=None)\r\n\u7acb\u5373\u53d1\u9001\u5ba2\u6237\u7aef\u7f13\u51b2\u961f\u5217\u4e2d\u8fd8\u672a\u53d1\u9001\u7684\u65e5\u5fd7\u3002\u53c2\u6570\u5982\u4e0b\uff1a\r\n+ `timeout` \u6700\u5927\u7b49\u5f85\u79d2\u6570\uff0c\u53ef\u4ee5\u662f\u5c0f\u6570\u3002\u4e3aNone\u65f6\uff0c\u8868\u793a\u963b\u585e\u5230\u53d1\u9001\u6210\u529f\u6216\u53d1\u9001\u7ed3\u675f\u4e3a\u6b62\u3002\u8fd9\u79cd\u60c5\u51b5\u4e0b\u7684\u53d1\u9001\u5931\u8d25\u91cd\u8bd5\u7b56\u7565\u4e0eClient\u7684\u6784\u9020\u53c2\u6570\u4e00\u81f4\u3002\u9ed8\u8ba4\u4e3aNone\u3002\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Kingsoft Log Service SDK",
    "version": "0.9.2",
    "project_urls": {
        "Homepage": "https://gitee.com/klogsdk/klog-python-sdk"
    },
    "split_keywords": [
        "klog",
        "klog-sdk",
        "kingsoft-cloud",
        "klog-python-sdk"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e59b352f33431d251e20c0ac80ff907f089c50e78a6d813f807766062faae0a9",
                "md5": "76b869e91beab6265634fc9cacbb5728",
                "sha256": "47367fd1a7e41836942bbb162a2af6239e92f8d1af3421b33b3a86cbad270348"
            },
            "downloads": -1,
            "filename": "klog_sdk-0.9.2-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "76b869e91beab6265634fc9cacbb5728",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=2.7",
            "size": 46528,
            "upload_time": "2023-10-19T12:28:34",
            "upload_time_iso_8601": "2023-10-19T12:28:34.996212Z",
            "url": "https://files.pythonhosted.org/packages/e5/9b/352f33431d251e20c0ac80ff907f089c50e78a6d813f807766062faae0a9/klog_sdk-0.9.2-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f721959c76fef02b9dff4930ee1422537f6ef5b8868f962605886984dc9e763c",
                "md5": "24f9ea553bc677aea649583d0c0a8552",
                "sha256": "abc9408999f887b701e753b77f07c96e1fd3089fdb4c3bb1e73a0a0ef2a8ad2a"
            },
            "downloads": -1,
            "filename": "klog-sdk-0.9.2.tar.gz",
            "has_sig": false,
            "md5_digest": "24f9ea553bc677aea649583d0c0a8552",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=2.7",
            "size": 41514,
            "upload_time": "2023-10-19T12:28:37",
            "upload_time_iso_8601": "2023-10-19T12:28:37.984532Z",
            "url": "https://files.pythonhosted.org/packages/f7/21/959c76fef02b9dff4930ee1422537f6ef5b8868f962605886984dc9e763c/klog-sdk-0.9.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-19 12:28:37",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "klog-sdk"
}
        
Elapsed time: 0.39138s