update_savedsearch
Updates a saved search.
Usage notes
Before you run this command, make sure that the following requirements are met:
Simple Log Service CLI is installed and configured. For more information, see Install the CLI and Configure SLS CLI.
An AccessKey pair is created and obtained. For more information, see AccessKey pair.
The AccessKey pair of an Alibaba Cloud account has permissions on all API operations. Using these credentials to perform operations in Simple Log Service is a high-risk operation. We recommend that you use a Resource Access Management (RAM) user to call API operations or perform routine O&M. To create a RAM user, log on to the RAM console. Make sure that the RAM user has the management permissions on Simple Log Service resources. For more information, see Create a RAM user and grant permissions.
The information that is required to query logs is obtained. The information includes the name of the project to which the logs belong, the region of the project, and the name of the logstore to which the logs belong. For more information, see Manage projects and Manage a logstore.
Limits are imposed when you use Simple Log Service to query logs. We recommend that you specify query statements and query time ranges based on the limits. For more information, see Log search overview and Log analysis overview.
Command syntax
aliyunlog log update_savedsearch --project=<value> --detail=<value> [--access-id=<value>] [--access-key=<value>] [--sts-token=<value>] [--region-endpoint=<value>] [--client-name=<value>] [--jmes-filter=<value>] [--format-output=<value>] [--decode-output=<value>] [--profile=<value>]
Command parameters
The following table describes the parameters specific to this command.
|
Parameter |
Type |
Required |
Example |
Description |
|
--project |
String |
Yes |
ali-test-project |
The name of the project. |
|
--detail |
String |
Yes |
file://./savedsearch_config_update.json |
The path to the configuration file that contains the updated saved search settings. Create this file before you run the command. In the file, specify parameters such as the saved search name and the query statement. |
For information about the global parameters, see Global parameters.
Command examples
-
Create a file named savedsearch_config_update.json to specify the updated information, such as the Logstore name (logstore), saved search name (savedsearchName), and query statement (searchQuery). The following example queries the number of page views (PVs) per hour:
{ "project": "ali-test-project", "savedsearchName": "pv_in_minutes", "logstore": "nginx-moni", "searchQuery": "*|select date_format(__time__-__time__%3600, '%H:%i:%s') as time, COUNT(*) as pv group by time order by time", "tokenQuery": "", "tokens": [], "topic": "" } -
Update the saved search named pv_in_minutes.
-
Example command
aliyunlog log update_savedsearch --project="ali-test-project" --detail="file://./savedsearch_config_update.json" -
Example output
No output is returned on success. To verify the update, run the
aliyunlog log get_savedsearch --project="ali-test-project" --entity="pv_in_minutes" --format-output=json,no_escapecommand to query the saved search details.{ "displayName": "pv_in_minutes", "logstore": "nginx-moni", "project": "ali-test-project", "savedsearchName": "pv_in_minutes", "searchQuery": "*|select date_format(__time__-__time__%3600, '%H:%i:%s') as time, COUNT(*) as pv group by time order by time", "tokenQuery": "", "tokens": [], "topic": "" }You can also view the updated saved search in the Log Service console by choosing . Click the saved search to query and analyze data. When you run the
pv_in_minutessaved search on the Saved Search page in the Log Service console, the query result shows a total of 4,965 logs. The chart shows a time value of 11:00:00 and a pv value of 4965.
-
References
In addition to its native SDK, SLS also supports the common Alibaba Cloud SDKs. For more information, see Log Service_SDKcenter-Alibaba CloudOpenAPIDeveloper Portal.
-
For the API operation that corresponds to this command, see UpdateSavedSearch.