Get Stream Queries
Retrieves the list of stream queries. This operation requires administrator privileges.
Required Permissions
Requires the ADMIN role or higher.
HTTP Request
GET /api/sonar/stream-queries
cURL Example
curl -H "Authorization: Bearer <API_KEY>" \
"https://HOSTNAME/api/sonar/stream-queries?offset=0&limit=20"
Request Parameters
| Key | Required | Type | Description | Note |
|---|---|---|---|---|
| offset | O | 32-bit Integer | Number of records to skip | Integer greater than or equal to 0 |
| limit | O | 32-bit Integer | Maximum number of records | Integer greater than or equal to 0 |
| keywords | X | String | Search keywords | Search string for name, description, query |
Success Response
{
"total_count": 2,
"stream_queries": [
{
"guid": "6dc1c563-d01c-3047-9573-cc6c24374925",
"name": "example-code-1108",
"description": "Stream query example",
"source_type": "table",
"sources": ["TABLE1", "TABLE2"],
"interval": 60,
"query_string": "rename RESULT_CODE as RESULT_CODE | eval bucket = string(LOG_TIME, \"yyyyMMddHHmm\") | stats count by bucket,_host,RESULT_CODE,SVC_NAME,TO_SVC_NAME,CALLING_INTERFACE | rename SVC_NAME as group_field1 | rename TO_SVC_NAME as group_field2 | rename CALLING_INTERFACE as group_field3 | eval _time=date(bucket,\"yyyyMMddHHmm\") | fields _time,bucket,_host,group_field1,group_field2,group_field3,RESULT_CODE,count | import example-code-1108",
"is_enabled": true,
"is_async": false
},
{
"guid": "3fbedcfa-70f4-354e-a22c-d82007004657",
"name": "example-code-1111",
"description": "Stream query example",
"source_type": "table",
"sources": ["TABLE1"],
"interval": 60,
"query_string": "rename RESULT_CODE as RESULT_CODE | eval bucket = string(LOG_TIME, \"yyyyMMddHHmm\") | stats count by bucket,_host,RESULT_CODE,TO_SVC_NAME,CALLING_CONTENTS,CEK_EXTENSION_ID | rename TO_SVC_NAME as group_field1 | rename CALLING_CONTENTS as group_field2 | rename CEK_EXTENSION_ID as group_field3 | eval _time=date(bucket,\"yyyyMMddHHmm\") | fields _time,bucket,_host,group_field1,group_field2,group_field3,RESULT_CODE,count | import example-code-1111",
"is_enabled": true,
"is_async": false
}
]
}
- total_count (32-bit integer): Total number of stream queries
- stream_queries (array): Paginated list of stream queries
- guid (string): Stream query GUID
- name (string): Name
- description (string): Description
- source_type (string): Source type (one of
table,logger,stream) - sources (array): Source list
- interval (32-bit integer): Refresh interval in seconds
- query_string (string): Query string
- is_enabled (boolean): Enabled status
- is_async (boolean): Asynchronous mode status
Error Responses
Missing Required Parameters
HTTP Status Code 400
{
"error_code": "null-argument",
"error_msg": "offset should be not null"
}
offset, limit value is not an integer
HTTP Status Code 400
{
"error_code": "invalid-argument",
"error_msg": "'offset' parameter should be int type"
}
offset, limit value is negative
HTTP Status Code 400
{
"error_code": "invalid-argument",
"error_msg": "'offset' must be greater than or equal to 0."
}
No permission to retrieve stream query list
HTTP Status Code 500
{
"error_code": "illegal-state",
"error_msg": "no-permission"
}