Update Scheduled Query
Updates a specified scheduled query. Administrator privileges are required to call this API.
Required Permissions
Requires the ADMIN role or higher.
HTTP Request
PUT /api/sonar/scheduled-queries/:guid
cURL Example
curl -H "Authorization: Bearer <API_KEY>" \
-d name="test" \
-d query="table duration=1m sonar_cpu_logs | search idle <= 10" \
-d type="cron" \
-d cron_schedule="* * * * *" \
-X PUT https://HOSTNAME/api/sonar/scheduled-queries/95e17283-1d08-44f0-bac7-b734813d2dcd
Request Parameters
Path Parameters
| Key | Type | Description | Note |
|---|---|---|---|
| guid | String | Scheduled query GUID |
Request Body Parameters
| Key | Required | Type | Description | Note |
|---|---|---|---|---|
| name | Yes | String | Name | Maximum 255 characters |
| description | No | String | Description | Maximum 2,000 characters |
| enabled | No | Boolean | Whether the scheduled query is enabled or not | Default: false |
| query | Yes | String | Query string | |
| trigger_type | Yes | String | Query trigger type | Either cron(Run at predefined intervals or on a predetermined schedule) or workflow(Run based on the preceding query result) |
| cron_schedule | Yes | String | Cron schedule expression | Required when trigger_type is set to cron. |
| preceding_guid | No | String | GUID of preceding query | Required when trigger_type is set to workflow. |
| preceding_action | No | String | Preceding query status | Either succeeded, failed, or finished when trigger_type is set to workflow |
| node_types | No | List of strings | Node on which to run the query | Comma-separated list of control(control node) or data(data node) |
| output_parameter | No | Boolean | Whether to pass the last result row as query parameter(s) to the subsequent query | Default: false |
Success Response
{}
Error Responses
Required argument is missing
HTTP status code 400
{
"error_code": "null-argument",
"error_msg": "name should be not null"
}
name or description parameter length is invalid
HTTP status code 400
{
"error_code": "invalid-argument",
"error_msg": "'name' must be shorter than or equal to 255 characters."
}
trigger_type: invalid value
HTTP status code 400
{
"error_code": "invalid-argument",
"error_msg": "trigger_type value must be either 'cron' or 'workflow'."
}
cron_schedule is missing when trigger_type is cron
HTTP status code 400
{
"error_code": "null-argument",
"error_msg": "cron_schedule should be not null"
}
preceding_action is missing when trigger_type is workflow
HTTP status code 400
{
"error_code": "null-argument",
"error_msg": "preceding_action should be not null"
}
preceding_action: invalid value
HTTP status code 400
{
"error_code": "invalid-argument",
"error_msg": "preceding_action value must be one of 'finished', 'succeeded', 'failed'."
}
Scheduled query is not found
HTTP status code 500
{
"error_code": "illegal-state",
"error_msg": "scheduled query not found: a1b2c3d4-e5f6-7890-abcd-ef1234567890"
}
Duplicated query name
HTTP status code 500
{
"error_code": "illegal-state",
"error_msg": "duplicated scheduled query name: cpu-check"
}
Permission denied
HTTP status code 500
{
"error_code": "illegal-state",
"error_msg": "no-permission"
}