すべてのプロダクト
Search
ドキュメントセンター

Simple Log Service:ログストアの照会

最終更新日:Dec 11, 2024

GetLogStore APIを呼び出して、シャードの数、データ保持期間、およびログストアタイプなど、特定のログストアの詳細を取得します。

前提条件

パラメータ説明

def get_logstore(self, project_name, logstore_name):

リクエストパラメーター

パラメーター

必須 / 任意

説明

project_name

String

Simple Log Serviceプロジェクトの名前。 詳細については、「プロジェクトの管理」をご参照ください。

logstore_name

String

Simple Log Serviceログストアの名前。 Simple Log Serviceログストアは、ログの収集、保存、およびクエリに使用されます。 詳細については、「logstoreの管理」をご参照ください。

応答パラメーター

詳細については、「GetLogStore」をご参照ください。

サンプルコード

from aliyun.log import LogClient
import os


# In this example, the AccessKey ID and AccessKey secret are obtained from environment variables.
access_key_id = os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_ID', '')
access_key_secret = os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_SECRET', '')

# The Simple Log Service endpoint.
endpoint = "cn-hangzhou.log.aliyuncs.com"
# Create a Simple Log Service client.
client = LogClient(endpoint, access_key_id, access_key_secret)


project_name = 'slsproject-1'

logstore_name = "logstore-1"


def main():
    # Query the logstore information.
    res = client.get_logstore(project_name, logstore_name)
    res.log_print()


if __name__ == '__main__':
    main()

レスポンスの例

GetLogStoreResponse:
headers: {'Server': 'AliyunSLS', 'Content-Type': 'application/json', 'Content-Length': '311', 'Connection': 'keep-alive', 'Access-Control-Allow-Origin': '*', 'Date': 'Thu, 21 Nov 2024 10:22:20 GMT', 'x-log-time': '1732184540', 'x-log-requestid': '673F09DCC3900F943481****'}
logstore_name: logstore-1
shard_count: 2
ttl: 30
mode: standard

Process finished with exit code 0

関連ドキュメント