Skip to content

Commit 602ae72

Browse files
Resolve review comments.
1. Update descriptions of config parameters. 2. Add saved search in dashboard. 3. Update query parameter in data collection, moved it to the request body. 4. Preserve event.original value from message field. 5. Update readme.
1 parent 6b677d0 commit 602ae72

File tree

17 files changed

+200
-69
lines changed

17 files changed

+200
-69
lines changed

packages/elastic_security/_dev/build/docs/README.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
## Overview
44

5-
Elastic Security Alerts are triggered when detection rules identify suspicious or malicious activity. They provide detailed context like rule name, impacted entities, timestamps, and other necessary details. Alerts can be investigated in Kibana using tools like Timeline. They support custom actions such as notifications or automated responses. These alerts help prioritize and manage security threats efficiently.
5+
Elastic Security is a free and open solution that helps detect, investigate, and respond to threats using data from endpoints, cloud, and network sources. It offers SIEM and endpoint protection with powerful search, correlation, and visualization features in Kibana.
6+
It enables security teams to streamline investigations and strengthen their overall security posture.
67

78
## Data streams
89

9-
This integration collects the following logs:
10+
The Elastic Security integration collects the following events:
1011

11-
`alert`: - Retrieve alerts from Elastic Instance.
12+
`alert`: - Retrieve alerts from Elasticsearch Instance using Elasticsearch [_search](https://www.elastic.co/docs/api/doc/elasticsearch/group/endpoint-search) API.
1213

1314
## Requirements
1415

@@ -26,17 +27,21 @@ Elastic Agent must be installed. For more details, check the Elastic Agent [inst
2627

2728
### To collect data from the Elastic API:
2829

29-
To collect data from the Elastic API, you will need the following information:
30+
You will need the following information:
3031

3132
1. The URL for the Elasticsearch instance.
32-
2. Authentication credentials such as username, password, API key, or bearer token depend on the selected authentication type.
33+
2. Authentication credentials such as username, password, API key, or bearer token depending on the selected authentication type.
34+
35+
Note:
36+
1. Users must have read index privileges on the `.alerts-security.alerts*` indices to access and query security alerts.
37+
2. To learn how to create authentication credentials and use the appropriate authentication type, refer to the Elasticsearch Authentication [Documentation](https://www.elastic.co/docs/api/doc/elasticsearch/authentication).
3338

3439
### Enable the integration in Elastic
3540

3641
1. In Kibana navigate to **Management** > **Integrations**.
3742
2. In the search top bar, type **Elastic Security**.
3843
3. Select the **Elastic Security** integration and add it.
39-
4. Add all the required integration configuration parameters such as username, password, API key, or bearer token depend on the selected authentication type to enable data collection.
44+
4. Add all the required integration configuration parameters such as username, password, API key, or bearer token depending on the selected authentication type to enable data collection.
4045
5. Select "Save and continue" to save the integration.
4146

4247
## Logs reference

packages/elastic_security/_dev/deploy/docker/files/config.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
rules:
2-
- path: /.internal.alerts-security.alerts*/_search
2+
- path: /.alerts-security.alerts*/_search
33
methods: ['GET']
44
query_params:
55
size: 1
6-
q: "{q:@timestamp:{2025.*}}"
76
request_headers:
87
Authorization:
98
- "Apikey xxxx"
9+
request_body: /.*2025.*/
1010
responses:
1111
- status_code: 200
1212
body: |-
@@ -1133,14 +1133,14 @@ rules:
11331133
}
11341134
}
11351135
`}}
1136-
- path: /.internal.alerts-security.alerts*/_search
1136+
- path: /.alerts-security.alerts*/_search
11371137
methods: ['GET']
11381138
query_params:
11391139
size: 1
1140-
q: "{q:@timestamp:{2060.*}}"
11411140
request_headers:
11421141
Authorization:
11431142
- "Apikey xxxx"
1143+
request_body: /.*2060.*/
11441144
responses:
11451145
- status_code: 200
11461146
body: |-
@@ -1149,8 +1149,8 @@ rules:
11491149
"hits": {
11501150
"hits": [
11511151
{
1152-
"_index": "abcd-1234",
1153-
"_id": "fghiabcd",
1152+
"_index": "xyz-1234",
1153+
"_id": "xyz1234",
11541154
"_source": {
11551155
"kibana.alert.start": "2024-06-09T13:56:03.235Z",
11561156
"kibana.alert.last_detected": "2024-06-09T13:56:03.235Z",
@@ -2267,14 +2267,14 @@ rules:
22672267
}
22682268
}
22692269
`}}
2270-
- path: /.internal.alerts-security.alerts*/_search
2270+
- path: /.alerts-security.alerts*/_search
22712271
methods: ['GET']
22722272
query_params:
22732273
size: 1
2274-
q: "{q:@timestamp:{2070.*}}"
22752274
request_headers:
22762275
Authorization:
22772276
- "Apikey xxxx"
2277+
request_body: /.*2070.*/
22782278
responses:
22792279
- status_code: 200
22802280
body: |-

packages/elastic_security/data_stream/alert/_dev/test/pipeline/test-alert.log

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

packages/elastic_security/data_stream/alert/_dev/test/pipeline/test-alert.log-expected.json

Lines changed: 5 additions & 4 deletions
Large diffs are not rendered by default.

packages/elastic_security/data_stream/alert/_dev/test/system/test-default-config.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@ data_stream:
88
initial_interval: 24h
99
batch_size: 1
1010
preserve_original_event: true
11-
preserve_duplicate_custom_fields: true
1211
assert:
1312
hit_count: 2

packages/elastic_security/data_stream/alert/agent/stream/cel.yml.hbs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ state:
2020
user: {{username}}
2121
password: {{password}}
2222
bearer_token: {{bearer_token}}
23-
index: .internal.alerts-security.alerts*
23+
index: .alerts-security.alerts*
2424
batch_size: {{batch_size}}
2525
initial_interval: {{initial_interval}}
2626
redact:
@@ -38,8 +38,17 @@ program: |
3838
state.url.trim_right("/") + "/" + state.index + "/_search?" + {
3939
"sort": ["@timestamp:asc"],
4040
"size": [string(state.batch_size)],
41-
"q": ["@timestamp:{" + state.start_time + " TO now}"],
42-
}.format_query()
41+
}.format_query(),
42+
{
43+
"query": {
44+
"range": {
45+
"@timestamp": {
46+
"gt": state.start_time,
47+
"lte": "now"
48+
}
49+
}
50+
}
51+
}.encode_json()
4352
).with({
4453
"Header":{
4554
"Content-Type": ["application/json"],

packages/elastic_security/data_stream/alert/elasticsearch/ingest_pipeline/default.yml

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
---
22
description: Pipeline for processing Alert logs.
33
processors:
4-
- fail:
4+
- terminate:
55
tag: data_collection_error
66
if: ctx.error?.message != null && ctx.message == null && ctx.event?.original == null
7-
message: error message set and no data to process.
7+
description: error message set and no data to process.
8+
- set:
9+
field: event.original
10+
tag: set_event_original
11+
copy_from: message
12+
ignore_empty_value: true
813
- json:
914
field: message
1015
tag: json_message
@@ -14,6 +19,19 @@ processors:
1419
- append:
1520
field: error.message
1621
value: 'Processor {{{_ingest.on_failure_processor_type}}} with tag {{{_ingest.on_failure_processor_tag}}} in pipeline {{{_ingest.on_failure_pipeline}}} failed with message: {{{_ingest.on_failure_message}}}'
22+
- script:
23+
lang: painless
24+
description: Script to remove message.
25+
tag: script_remove_message
26+
if: ctx.event?.original != null && ctx.message != null
27+
source: |-
28+
if(ctx.event.original == ctx.message) {
29+
ctx.remove('message');
30+
}
31+
on_failure:
32+
- append:
33+
field: error.message
34+
value: 'Processor {{{_ingest.on_failure_processor_type}}} with tag {{{_ingest.on_failure_processor_tag}}} in pipeline {{{_ingest.on_failure_pipeline}}} failed with message: {{{_ingest.on_failure_message}}}'
1735
- remove:
1836
field:
1937
- organization
@@ -25,24 +43,13 @@ processors:
2543
description: >-
2644
Removes the fields added by Agentless as metadata,
2745
as they can collide with ECS fields.
28-
- rename:
29-
field: message
30-
tag: rename_message_to_event_original
31-
target_field: event.original
32-
ignore_missing: true
33-
description: Renames the original `message` field to `event.original` to store a copy of the original message. The `event.original` field is not touched if the document already has one; it may happen when Logstash sends the document.
34-
if: ctx.event?.original == null
35-
- remove:
36-
field: message
37-
tag: remove_message
38-
ignore_missing: true
39-
description: The `message` field is no longer required if the document has an `event.original` field.
40-
if: ctx.event?.original != null
4146
- dot_expander:
4247
field: "*"
48+
tag: dot_expander_source_fields
4349
ignore_failure: true
4450
- uppercase:
4551
field: host.mac
52+
tag: uppercase_host_mac
4653
ignore_missing: true
4754
- convert:
4855
field: user.id
@@ -54,11 +61,6 @@ processors:
5461
tag: convert_group_id
5562
type: string
5663
ignore_missing: true
57-
- append:
58-
field: tags
59-
value: preserve_original_event
60-
allow_duplicates: false
61-
if: ctx.error?.message != null
6264
- set:
6365
field: event.kind
6466
tag: set_event_kind

packages/elastic_security/data_stream/alert/fields/fields.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
fields:
77
- name: id
88
type: keyword
9+
# Kibana-specific fields
910
- name: kibana
1011
type: group
1112
fields:
@@ -261,6 +262,7 @@
261262
type: keyword
262263
- name: version
263264
type: keyword
265+
# Endpoint-specific fields
264266
- name: Endpoint
265267
type: group
266268
fields:
@@ -731,8 +733,6 @@
731733
fields:
732734
- name: ancestry
733735
type: keyword
734-
- name: args
735-
type: keyword
736736
- name: args_count
737737
type: long
738738
- name: command_line

packages/elastic_security/data_stream/alert/manifest.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ streams:
2020
- text: Bearer Auth
2121
value: bearer_auth
2222
default: api_auth
23-
description: Provide the type of authentication to be used for the request.
23+
description: Type of authentication to be used for the Elasticsearch API requests. See [documentation](https://www.elastic.co/docs/api/doc/elasticsearch/authentication) for details.
2424
- name: url
2525
type: url
2626
title: URL
27-
description: URL of Elasticsearch instance.
27+
description: URL of the Elasticsearch instance. Example `https://<host>:<port>`.
2828
required: true
2929
show_user: true
3030
- name: username
@@ -65,7 +65,7 @@ streams:
6565
required: true
6666
show_user: true
6767
default: 24h
68-
description: How far back to pull the logs from Elasticsearch API. Supported units for this parameter are h/m/s.
68+
description: How far back to pull the events from Elasticsearch API. Supported units for this parameter are h/m/s. Example `72h`.
6969
- name: interval
7070
type: text
7171
title: Interval

packages/elastic_security/data_stream/alert/sample_event.json

Lines changed: 5 additions & 4 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)