Query a saved search

Updated at:

Calls the GetSavedSearch operation to query a specified saved search.

Prerequisites

Parameters

def get_savedsearch(self, project, entity):

Response parameters

For more information about the response parameters, see GetSavedSearch.

Sample code

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"

client = LogClient(endpoint, access_key_id, access_key_secret)

project = "proj-test-1"
entity = "savedsearch-1"


def main():
    # Query a saved search. 
    res = client.get_savedsearch(project, entity)
    res.log_print()


if __name__ == '__main__':
    main()

Sample response

header:  {'Server': 'AliyunSLS', 'Content-Type': 'application/json', 'Content-Length': '262', 'Connection': 'keep-alive', 'Access-Control-Allow-Origin': '*', 'Date': 'Tue, 15 Oct 2024 07:46:29 GMT', 'x-log-time': '1728978389', 'x-log-requestid': '670E1DD5541504C71CBD****'}
body:  {'displayName': 'savedsearch-1', 'filterjson': '{"filterJson":{"children":[]},"filterQuery":""}', 'logstore': 'logstore-1', 'savedsearchName': 'savedsearch-1', 'searchQuery': '* | SELECT status, count(*) AS PV GROUP BY status', 'topic': ''}

Process finished with exit code 0

References