Skip to content

Commit b21205a

Browse files
[pfsense] Generate processor tags and normalize error handler (#15566)
- Generate tags for processors missing tags - Normalize the pipeline error handler
1 parent 6c5559d commit b21205a

File tree

12 files changed

+198
-27
lines changed

12 files changed

+198
-27
lines changed

packages/pfsense/changelog.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
# newer versions go on top
2+
- version: "1.23.2"
3+
changes:
4+
- description: Generate processor tags and normalize error handler.
5+
type: enhancement
6+
link: https://github.com/elastic/integrations/pull/15566
27
- version: "1.23.1"
38
changes:
49
- description: Changed owners.

packages/pfsense/data_stream/log/elasticsearch/ingest_pipeline/default.yml

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,34 @@
22
description: Pipeline for PFsense
33
processors:
44
- set:
5+
tag: set_ecs_version_f5923549
56
field: ecs.version
67
value: '8.17.0'
78
- set:
9+
tag: set_observer_vendor_ad9d35cc
810
field: observer.vendor
911
value: netgate
1012
- set:
13+
tag: set_observer_type_5dddf3ba
1114
field: observer.type
1215
value: firewall
1316
- rename:
17+
tag: rename_message_to_event_original_56a77271
1418
field: message
1519
target_field: event.original
1620
ignore_missing: true
1721
if: ctx.event?.original == null
1822
- set:
23+
tag: set_event_kind_de80643c
1924
field: event.kind
2025
value: event
2126
- set:
27+
tag: set_event_timezone_4ca44cac
2228
field: event.timezone
2329
value: "{{{_tmp.tz_offset}}}"
2430
if: ctx._tmp?.tz_offset != null && ctx._tmp?.tz_offset != 'local'
2531
- grok:
32+
tag: grok_event_original_27d9c8c7
2633
description: Parse syslog header
2734
field: event.original
2835
patterns:
@@ -41,12 +48,14 @@ processors:
4148
BASEPATH: '[[[:alnum:]]_%!$@:.,+~-]+'
4249
META: '\[[^\]]*\]'
4350
- date:
51+
tag: date__tmp_timestamp8601_to_timestamp_6ac9d3ce
4452
if: ctx._tmp.timestamp8601 != null
4553
field: _tmp.timestamp8601
4654
target_field: '@timestamp'
4755
formats:
4856
- ISO8601
4957
- date:
58+
tag: date__tmp_timestamp_to_timestamp_f21e536e
5059
if: ctx.event?.timezone != null && ctx._tmp?.timestamp != null
5160
field: _tmp.timestamp
5261
target_field: '@timestamp'
@@ -56,74 +65,93 @@ processors:
5665
- MMM dd HH:mm:ss
5766
timezone: '{{{ event.timezone }}}'
5867
- grok:
68+
tag: grok_process_name_cef3d489
5969
description: Set Event Provider
6070
field: process.name
6171
patterns:
6272
- '^%{HYPHENATED_WORDS:event.provider}'
6373
pattern_definitions:
6474
HYPHENATED_WORDS: '\b[A-Za-z0-9_]+(-[A-Za-z_]+)*\b'
6575
- pipeline:
76+
tag: pipeline_e16851a7
6677
name: '{{ IngestPipeline "firewall" }}'
6778
if: ctx.event.provider == 'filterlog'
6879
- pipeline:
80+
tag: pipeline_828590b5
6981
name: '{{ IngestPipeline "openvpn" }}'
7082
if: ctx.event.provider == 'openvpn'
7183
- pipeline:
84+
tag: pipeline_9d37039c
7285
name: '{{ IngestPipeline "ipsec" }}'
7386
if: ctx.event.provider == 'charon'
7487
- pipeline:
88+
tag: pipeline_ad56bbca
7589
name: '{{ IngestPipeline "dhcp" }}'
7690
if: '["dhcpd", "dhclient", "dhcp6c"].contains(ctx.event.provider)'
7791
- pipeline:
92+
tag: pipeline_dd85553d
7893
name: '{{ IngestPipeline "unbound" }}'
7994
if: ctx.event.provider == 'unbound'
8095
- pipeline:
96+
tag: pipeline_720ed255
8197
name: '{{ IngestPipeline "haproxy" }}'
8298
if: ctx.event.provider == 'haproxy'
8399
- pipeline:
100+
tag: pipeline_456beba5
84101
name: '{{ IngestPipeline "php-fpm" }}'
85102
if: ctx.event.provider == 'php-fpm'
86103
- pipeline:
104+
tag: pipeline_a0d89375
87105
name: '{{ IngestPipeline "squid" }}'
88106
if: ctx.event.provider == 'squid'
89107
- pipeline:
108+
tag: pipeline_c2f1ed55
90109
name: '{{ IngestPipeline "snort" }}'
91110
if: ctx.event.provider == 'snort'
92111
- drop:
112+
tag: drop_9d7c46f8
93113
if: '!["filterlog", "openvpn", "charon", "dhcpd", "dhclient", "dhcp6c", "unbound", "haproxy", "php-fpm", "squid", "snort"].contains(ctx.event?.provider)'
94114
- append:
115+
tag: append_event_category_4780a983
95116
field: event.category
96117
value: network
97118
if: "ctx.network != null"
98119
- convert:
120+
tag: convert_source_address_to_source_ip_f5632a20
99121
field: source.address
100122
target_field: source.ip
101123
type: ip
102124
ignore_failure: true
103125
ignore_missing: true
104126
- convert:
127+
tag: convert_destination_address_to_destination_ip_f1388f0c
105128
field: destination.address
106129
target_field: destination.ip
107130
type: ip
108131
ignore_failure: true
109132
ignore_missing: true
110133
- set:
134+
tag: set_network_type_1f1d940a
111135
field: network.type
112136
value: ipv6
113137
if: 'ctx.source?.ip != null && ctx.source.ip.contains(":")'
114138
- set:
139+
tag: set_network_type_69deca38
115140
field: network.type
116141
value: ipv4
117142
if: 'ctx.source?.ip != null && ctx.source.ip.contains(".")'
118143
- geoip:
144+
tag: geoip_source_ip_to_source_geo_da2e41b2
119145
field: source.ip
120146
target_field: source.geo
121147
ignore_missing: true
122148
- geoip:
149+
tag: geoip_destination_ip_to_destination_geo_ab5e2968
123150
field: destination.ip
124151
target_field: destination.geo
125152
ignore_missing: true
126153
- geoip:
154+
tag: geoip_source_ip_to_source_as_28d69883
127155
ignore_missing: true
128156
database_file: GeoLite2-ASN.mmdb
129157
field: source.ip
@@ -132,6 +160,7 @@ processors:
132160
- asn
133161
- organization_name
134162
- geoip:
163+
tag: geoip_destination_ip_to_destination_as_8a007787
135164
database_file: GeoLite2-ASN.mmdb
136165
field: destination.ip
137166
target_field: destination.as
@@ -140,66 +169,81 @@ processors:
140169
- organization_name
141170
ignore_missing: true
142171
- rename:
172+
tag: rename_source_as_asn_to_source_as_number_a917047d
143173
field: source.as.asn
144174
target_field: source.as.number
145175
ignore_missing: true
146176
- rename:
177+
tag: rename_source_as_organization_name_to_source_as_organization_name_f1362d0b
147178
field: source.as.organization_name
148179
target_field: source.as.organization.name
149180
ignore_missing: true
150181
- rename:
182+
tag: rename_destination_as_asn_to_destination_as_number_3b459fcd
151183
field: destination.as.asn
152184
target_field: destination.as.number
153185
ignore_missing: true
154186
- rename:
187+
tag: rename_destination_as_organization_name_to_destination_as_organization_name_814bd459
155188
field: destination.as.organization_name
156189
target_field: destination.as.organization.name
157190
ignore_missing: true
158191
- community_id:
192+
tag: community_id_d2308e7a
159193
target_field: network.community_id
160194
ignore_failure: true
161195
- grok:
196+
tag: grok_observer_ingress_interface_name_968018d3
162197
field: observer.ingress.interface.name
163198
patterns:
164199
- "%{DATA}.%{NONNEGINT:observer.ingress.vlan.id}"
165200
ignore_missing: true
166201
ignore_failure: true
167202
- set:
203+
tag: set_network_vlan_id_efd4d96a
168204
field: network.vlan.id
169205
copy_from: observer.ingress.vlan.id
170206
ignore_empty_value: true
171207
- append:
208+
tag: append_related_ip_c1a6356b
172209
field: related.ip
173210
value: "{{{destination.ip}}}"
174211
allow_duplicates: false
175212
if: ctx.destination?.ip != null
176213
- append:
214+
tag: append_related_ip_8121c591
177215
field: related.ip
178216
value: "{{{source.ip}}}"
179217
allow_duplicates: false
180218
if: ctx.source?.ip != null
181219
- append:
220+
tag: append_related_ip_53b62ed8
182221
field: related.ip
183222
value: "{{{source.nat.ip}}}"
184223
allow_duplicates: false
185224
if: ctx.source?.nat?.ip != null
186225
- append:
226+
tag: append_related_hosts_6f162628
187227
field: related.hosts
188228
value: "{{{destination.domain}}}"
189229
if: "ctx.destination?.domain != null"
190230
- append:
231+
tag: append_related_user_c036eec2
191232
field: related.user
192233
value: "{{{user.name}}}"
193234
if: "ctx.user?.name != null"
194235
- set:
236+
tag: set_network_direction_cb1e3125
195237
field: network.direction
196238
value: "{{{network.direction}}}bound"
197239
if: ctx.network?.direction != null && ctx.network?.direction =~ /^(in|out)$/
198240
- remove:
241+
tag: remove_a82e20f2
199242
field:
200243
- _tmp
201244
ignore_failure: true
202245
- script:
246+
tag: script_a7f2c062
203247
lang: painless
204248
description: This script processor iterates over the whole document to remove fields with null values.
205249
source: |
@@ -233,4 +277,8 @@ on_failure:
233277
value: pipeline_error
234278
- append:
235279
field: error.message
236-
value: '{{{ _ingest.on_failure_message }}}'
280+
value: >-
281+
Processor '{{{ _ingest.on_failure_processor_type }}}'
282+
{{#_ingest.on_failure_processor_tag}}with tag '{{{ _ingest.on_failure_processor_tag }}}'
283+
{{/_ingest.on_failure_processor_tag}}in pipeline '{{{ _ingest.pipeline }}}'
284+
failed with message '{{{ _ingest.on_failure_message }}}'

packages/pfsense/data_stream/log/elasticsearch/ingest_pipeline/dhcp.yml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
description: Pipeline for PFsense DHCP logs
33
processors:
44
- grok:
5+
tag: grok_message_efb70afb
56
field: message
67
patterns:
78
- '%{DATA:_tmp.action}/%{INTERFACE:observer.ingress.interface.name}/%{MAC_ADDRESS:server.mac}/%{NOTSPACE:pfsense.dhcp.subnet}'
@@ -21,68 +22,83 @@ processors:
2122
MIDDLE: '(?:%{FROM}|%{ON}|%{FOR})'
2223
DUID: '(?i)[0-9a-f]{2}(:[0-9a-f]{2})+'
2324
- append:
25+
tag: append_event_type_c741503d
2426
field: event.type
25-
value:
27+
value:
2628
- connection
2729
- protocol
2830
- info
2931
allow_duplicates: false
3032
- set:
33+
tag: set_network_protocol_ea539779
3134
field: network.protocol
3235
value: dhcp
3336
- set:
37+
tag: set_network_protocol_98d42096
3438
field: network.protocol
3539
value: dhcpv6
3640
if: ctx.event.provider == 'dhcp6c' || (ctx.server?.address != null && ctx.server.address.contains(':')) || (ctx.client?.address != null && ctx.client.address.contains(':'))
3741
- set:
42+
tag: set_network_transport_a6cfd568
3843
field: network.transport
3944
value: udp
4045
- convert:
46+
tag: convert_client_address_to_client_ip_c718a334
4147
field: client.address
4248
target_field: client.ip
4349
type: ip
4450
ignore_failure: true
4551
ignore_missing: true
4652
- convert:
53+
tag: convert_server_address_to_server_ip_940441bc
4754
field: server.address
4855
target_field: server.ip
4956
type: ip
5057
ignore_failure: true
5158
ignore_missing: true
5259
- uppercase:
60+
tag: uppercase_client_mac_230df574
5361
field: client.mac
5462
ignore_missing: true
5563
- gsub:
64+
tag: gsub_client_mac_3eb17338
5665
field: client.mac
5766
pattern: '[:]'
5867
replacement: '-'
5968
ignore_missing: true
6069
- uppercase:
70+
tag: uppercase_server_mac_12d7a2a0
6171
field: server.mac
6272
ignore_missing: true
6373
- gsub:
74+
tag: gsub_server_mac_5d413db4
6475
field: server.mac
6576
pattern: '[:]'
6677
replacement: '-'
6778
ignore_missing: true
6879
- lowercase:
80+
tag: lowercase__tmp_action_5d4e19c7
6981
field: _tmp.action
7082
ignore_missing: true
7183
- gsub:
84+
tag: gsub__tmp_action_to_event_action_2c25be60
7285
field: _tmp.action
7386
target_field: event.action
7487
pattern: ' '
7588
replacement: '-'
7689
ignore_missing: true
7790
- set:
91+
tag: set_source_a194c11b
7892
field: source
7993
copy_from: client
8094
ignore_empty_value: true
8195
- set:
96+
tag: set_destination_bb802684
8297
field: destination
8398
copy_from: server
8499
ignore_empty_value: true
85100
- append:
101+
tag: append_related_hosts_8bba1f0b
86102
field: related.hosts
87103
value: "{{{pfsense.dhcp.hostname}}}"
88104
allow_duplicates: false
@@ -93,4 +109,8 @@ on_failure:
93109
value: pipeline_error
94110
- append:
95111
field: error.message
96-
value: '{{{ _ingest.on_failure_message }}}'
112+
value: >-
113+
Processor '{{{ _ingest.on_failure_processor_type }}}'
114+
{{#_ingest.on_failure_processor_tag}}with tag '{{{ _ingest.on_failure_processor_tag }}}'
115+
{{/_ingest.on_failure_processor_tag}}in pipeline '{{{ _ingest.pipeline }}}'
116+
failed with message '{{{ _ingest.on_failure_message }}}'

0 commit comments

Comments
 (0)