List saved searches
Updated at:
Call the ListSavedSearch operation to get a list of saved searches.
Prerequisites
Ensure that you have completed the following operations:
Parameters
def list_savedsearch(self, project, offset=0, size=100):Request parameters
Parameter | Type | Required | Description |
project | String | Yes | The name of the project. A project is the basic resource management unit in Log Service and is the primary boundary for multi-user isolation and access control. For more information, see Manage projects. |
offset | int | No | The line from which to start returning entries. Default value: 0. |
size | int | No | The number of entries to return on each page. Default value: 100. Maximum value: 500. |
Response parameters
For details about the response parameters, see ListSavedSearch.
Sample code
from aliyun.log import LogClient
import os
# This example obtains the AccessKey ID and AccessKey Secret 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 Log Service endpoint. This example uses the China (Hangzhou) region endpoint.
endpoint = "cn-hangzhou.log.aliyuncs.com"
client = LogClient(endpoint, access_key_id, access_key_secret)
project = "proj-test-1"
def main():
# List saved searches.
res = client.list_savedsearch(project)
res.log_print()
if __name__ == '__main__':
main()
Sample response
ListResponse for savedsearches:
headers: {'Server': 'AliyunSLS', 'Content-Type': 'application/json', 'Content-Length': '470', 'Connection': 'keep-alive', 'Access-Control-Allow-Origin': '*', 'Date': 'Tue, 15 Oct 2024 07:42:23 GMT', 'x-log-time': '1728978143', 'x-log-requestid': '670E1CDFB20A45EE7ED5****'}
count: 5
total: 5
savedsearches ['savedsearch-1', 'savedsearch-5', 'savedsearch-4', 'savedsearch-3', 'savedsearch-2']
Process finished with exit code 0References
The following API operations are also available for managing saved searches:
For more sample code, see Aliyun Log Python SDK on GitHub.
Is this page helpful?