Create Stream Rule
Creates a new stream rule.
Required Permissions
Requires the ADMIN role or higher.
HTTP Request
POST /api/sonar/stream-rules
cURL Example
curl -H "Authorization: Bearer <API_KEY>" \
-d priority="HIGH" \
-d name="Access to known botnet networks" \
-d msg="Access to known botnet networks: $dst_ip" \
-d schema_code="session" \
-d commands="[{'template_id': 3, 'query': 'matchnet invert=t field=dst_ip guid=697393b6-aecf-4e9d-a32c-8724cd8f067e verify=f', 'field_name': 'dst_ip', 'args':{'subnet':'697393b6-aecf-4e9d-a32c-8724cd8f067e'}}]" \
-X POST \
https://HOSTNAME/api/sonar/stream-rules
Request Parameters
| Key | Required | Type | Description | Note |
|---|---|---|---|---|
| priority | Yes | String | Priority | LOW or MEDIUM or HIGH. |
| guid | No | String | Stream rule GUID | 36 characters |
| name | Yes | String | Stream rule name | Minimum 1 to maximum 255 characters |
| description | No | String | Stream rule description | Maximum 2,000 characters |
| msg | Yes | String | Message template | Minimum 1 to maximum 2,000 characters |
| enabled | No | Boolean | Whether the stream rule is enabled or not | true or false |
| category_guid | No | String | Stream rule category GUID | 36 characters |
| schema_code | Yes | String | Log schema code | Minimum 1 to maximum 50 characters |
| logger_guids | Yes | Array | Logger GUID list | |
| commands | Yes | Array | List of stream rules | At least one command required. Refer to the below description. |
| address_group_guid | No | String | Address group GUID | 36 characters |
| address_field | No | String | Address field | Address group field name. Maximum 50 characters. |
| ticket_repo_guid | No | String | Ticket repository GUID | 36 characters. If not specified, a ticket is not generated. |
| ticket_assignee_guid | No | String | Ticket assignee GUID | If specified, ticket is assigned automatically. |
| ticket_suppress_interval | No | 32-bit integer | Suppression period for duplicated ticket (in seconds) | If set to 0 or not specified, duplicate tickets are not merged. |
| event_suppress_interval | No | 32-bit integer | Suppression period for duplicated event (in seconds) | If set to 0 or not specified, duplicate events are not merged. |
| suppress_key | No | String | Suppress key field | Maximum 2,000 characters. Macro in $field format available. |
| keep_alive | No | Boolean | Whether to keep the suppression timer alive | true to keep the timer alive, false to reset it. |
| audit_category_guid | No | String | Audit category GUID | 36 characters. If not specified, an auto audit request is not sent. |
| auditor_guid | No | String | Auditor GUID | 36 characters. If not specified, the department head is assigned as default. |
| audit_days | No | 32-bit integer | Audit due date | Minimum 1 to maximum 365 days |
| employee_key_field | No | String | Employee number field | Maximum 50 characters. If not specified, an auto audit request is not sent. |
| alarm_group_guid | No | String | Alarm group GUID | 36 characters |
| field_order | No | String | Evidence field output order | Maximum 2,000 characters |
| source_type | No | String | Source type | LOGGER or LOGGER_MODEL. Default: LOGGER |
| logger_model_guids | No | String list | Logger model GUID list | Used when source_type is LOGGER_MODEL. Separated by , |
| reviewer_guid | No | String | Reviewer account GUID | 36 characters |
| user_note | No | String | Scenario summary |
Each array element in commands is defined as follows:
| Key | Required | Type | Description | Note |
|---|---|---|---|---|
| template_id | Yes | 32-bit integer | Stream rule command template ID | |
| query | Yes | String | Query string portion | |
| field_name | No | String | Target field name | |
| args | No | Map | Argument key/value | |
| invert | No | Boolean | Whether to use an invert match option |
Success Response
{
"guid": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
}
Error Responses
Required argument is missing
HTTP status code 400
{
"error_code": "null-argument",
"error_msg": "name should be not null"
}
Invalid argument length
HTTP status code 400
{
"error_code": "invalid-argument",
"error_msg": "'name' must be shorter than or equal to 255 characters."
}
Invalid priority value
HTTP status code 400
{
"error_code": "invalid-argument",
"error_msg": "priority should be one of 'LOW', 'MEDIUM', 'HIGH'."
}
Identifier is not in valid GUID format
HTTP status code 400
{
"error_code": "invalid-param-type",
"error_msg": "category_guid should be guid type."
}
The logger list is missing when the detection target is LOGGER
HTTP status code 400
{
"error_code": "null-argument",
"error_msg": "logger_guids should be not null"
}
The detection command list is not valid JSON
HTTP status code 400
{
"error_code": "invalid-argument",
"error_msg": "'commands' parameter should follow valid JSON syntax"
}
field_order contains a pipe character
HTTP status code 400
{
"error_code": "invalid-argument",
"error_msg": "field_order doesn't allow pipe characters."
}
No detection command is specified
HTTP status code 500
{
"error_code": "illegal-state",
"error_msg": "cannot create rule with empty command: Access to known botnet networks"
}
Log schema is not found
HTTP status code 500
{
"error_code": "illegal-state",
"error_msg": "schema not found: session"
}
Rule name is duplicated
HTTP status code 500
{
"error_code": "illegal-state",
"error_msg": "duplicated stream rule name: Access to known botnet networks"
}
Permission denied
HTTP status code 500
{
"error_code": "illegal-state",
"error_msg": "no-permission"
}