Skip to content

Commit 7ae73f3

Browse files
kareskarenzoneyaauie
authored
Feat: event_factory support + targets to aid ECS (#49)
Co-authored-by: Karen Metts <[email protected]> Co-authored-by: Ry Biesemeyer <[email protected]>
1 parent dbd5f40 commit 7ae73f3

File tree

8 files changed

+498
-91
lines changed

8 files changed

+498
-91
lines changed

.ci/run.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ env
55

66
set -ex
77

8-
export ACTIVEMQ_VERSION=5.15.9
8+
export ACTIVEMQ_VERSION=5.15.15
99
./setup_broker.sh
1010
bundle install
1111
bundle exec rspec

CHANGELOG.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 3.2.0
2+
- Feat: event_factory support + targets to aid ECS [#49](https://github.com/logstash-plugins/logstash-input-jms/pull/49)
3+
- Fix: when configured to add JMS headers to the event, headers whose value is not set no longer result in nil entries on the event
4+
- Fix: when adding the `jms_reply_to` header to an event, a string representation is set instead of an opaque object.
5+
16
## 3.1.2
27
- Docs: Added additional troubleshooting information [#38](https://github.com/logstash-plugins/logstash-input-jms/pull/38)
38

@@ -45,7 +50,7 @@
4550
- New dependency requirements for logstash-core for the 5.0 release
4651

4752
## 2.0.0
48-
- Plugins were updated to follow the new shutdown semantic, this mainly allows Logstash to instruct input plugins to terminate gracefully,
53+
- Plugins were updated to follow the new shutdown semantic, this mainly allows Logstash to instruct input plugins to terminate gracefully,
4954
instead of using Thread.raise on the plugins' threads. Ref: https://github.com/elastic/logstash/pull/3895
5055
- Dependency on logstash-core update to 2.0
5156

docs/index.asciidoc

+96-12
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ JMS configurations can be done either entirely in the Logstash configuration fil
3333
configurations, should also use the combination of yaml file and Logstash configuration.
3434

3535

36+
[id="plugins-{type}s-{plugin}-ecs"]
37+
==== Compatibility with the Elastic Common Schema (ECS)
38+
39+
JMS data is application specific. ECS compliance for fields depends on the use case.
40+
The plugin includes sensible defaults that change based on <<plugins-{type}s-{plugin}-ecs_compatibility,ECS compatibility mode>>.
41+
When ECS compatibility is disabled, headers, properties, and payload are targeted at the root level of the event to maintain compatibility with legacy usage of this plugin.
42+
When targeting an ECS version, headers and properties target `@metadata` sub-fields unless configured otherwise in order to avoid conflict with ECS fields.
43+
See <<plugins-{type}s-{plugin}-headers_target>>, <<plugins-{type}s-{plugin}-properties_target>> and <<plugins-{type}s-{plugin}-target>>.
3644

3745
==== Sample Configuration using Logstash Configuration Only
3846

@@ -60,7 +68,7 @@ The JMS plugin can also be configured using JNDI if desired.
6068
truststore => '/Users/logstash-user/security/truststore.jks'
6169
truststore_password => 'yet_another_secret'
6270
# Parts of the JMS message to be included <8>
63-
include_header => false
71+
include_headers => false
6472
include_properties => false
6573
include_body => true
6674
# Message selector
@@ -98,7 +106,7 @@ The JMS plugin can also be configured using JNDI if desired.
98106
input {
99107
jms {
100108
# Logstash Configuration Settings. <1>
101-
include_header => false
109+
include_headers => false
102110
include_properties => false
103111
include_body => true
104112
use_jms_timestamp => false
@@ -144,7 +152,7 @@ This section contains sample configurations for connecting to a JMS provider tha
144152
input {
145153
jms {
146154
# Logstash Configuration File Settings <1>
147-
include_header => false
155+
include_headers => false
148156
include_properties => false
149157
include_body => true
150158
use_jms_timestamp => false
@@ -205,7 +213,7 @@ This section contains sample configurations for connecting to a JMS provider tha
205213
input {
206214
jms {
207215
# Logstash specific configuration settings <1>
208-
include_header => false
216+
include_headers => false
209217
include_properties => false
210218
include_body => true
211219
use_jms_timestamp => false
@@ -379,10 +387,13 @@ This plugin supports the following configuration options plus the <<plugins-{typ
379387
| <<plugins-{type}s-{plugin}-durable_subscriber>> |<<boolean,boolean>>|No
380388
| <<plugins-{type}s-{plugin}-durable_subscriber_client_id>> |<<string,string>>|No
381389
| <<plugins-{type}s-{plugin}-durable_subscriber_name>> |<<string,string>>|No
390+
| <<plugins-{type}s-{plugin}-ecs_compatibility>> |<<string,string>>|No
382391
| <<plugins-{type}s-{plugin}-factory>> |<<string,string>>|No
383392
| <<plugins-{type}s-{plugin}-factory_settings>> |<<hash,hash>>|No
393+
| <<plugins-{type}s-{plugin}-headers_target>> |<<string,string>>|No
384394
| <<plugins-{type}s-{plugin}-include_body>> |<<boolean,boolean>>|No
385395
| <<plugins-{type}s-{plugin}-include_header>> |<<boolean,boolean>>|No
396+
| <<plugins-{type}s-{plugin}-include_headers>> |<<boolean,boolean>>|No
386397
| <<plugins-{type}s-{plugin}-include_properties>> |<<boolean,boolean>>|No
387398
| <<plugins-{type}s-{plugin}-interval>> |<<number,number>>|No
388399
| <<plugins-{type}s-{plugin}-jndi_context>> |<<hash,hash>>|No
@@ -391,13 +402,15 @@ This plugin supports the following configuration options plus the <<plugins-{typ
391402
| <<plugins-{type}s-{plugin}-keystore_password>> |<<password,password>>|No
392403
| <<plugins-{type}s-{plugin}-oracle_aq_buffered_messages>> |<<boolean,boolean>>|No
393404
| <<plugins-{type}s-{plugin}-password>> |<<string,string>>|No
405+
| <<plugins-{type}s-{plugin}-properties_target>> |<<string,string>>|No
394406
| <<plugins-{type}s-{plugin}-pub_sub>> |<<boolean,boolean>>|No
395407
| <<plugins-{type}s-{plugin}-require_jars>> |<<array,array>>|No
396408
| <<plugins-{type}s-{plugin}-runner>> |<<string,string>>|__Deprecated__
397409
| <<plugins-{type}s-{plugin}-selector>> |<<string,string>>|No
398410
| <<plugins-{type}s-{plugin}-skip_headers>> |<<array,array>>|No
399411
| <<plugins-{type}s-{plugin}-skip_properties>> |<<array,array>>|No
400412
| <<plugins-{type}s-{plugin}-system_properties>> |<<hash,hash>>|No
413+
| <<plugins-{type}s-{plugin}-target>> |<<string,string>>|No
401414
| <<plugins-{type}s-{plugin}-threads>> |<<number,number>>|No
402415
| <<plugins-{type}s-{plugin}-timeout>> |<<number,number>>|No
403416
| <<plugins-{type}s-{plugin}-truststore>> |a valid filesystem path|No
@@ -468,6 +481,21 @@ This represents the value of the client ID for a durable subscribtion, and is on
468481
This represents the value of the subscriber name for a durable subscribtion, and is only used if `durable_subscriber`
469482
is set to `true`. Please consult your JMS Provider documentation for constraints and requirements for this setting.
470483

484+
[id="plugins-{type}s-{plugin}-ecs_compatibility"]
485+
===== `ecs_compatibility`
486+
487+
* Value type is <<string,string>>
488+
* Supported values are:
489+
** `disabled`: does not use ECS-compatible field names (fields might be set at the root of the event)
490+
** `v1`, `v8`: avoids field names that might conflict with Elastic Common Schema (for example, JMS specific properties)
491+
* Default value depends on which version of Logstash is running:
492+
** When Logstash provides a `pipeline.ecs_compatibility` setting, its value is used as the default
493+
** Otherwise, the default value is `disabled`.
494+
495+
Controls this plugin's compatibility with the {ecs-ref}[Elastic Common Schema (ECS)].
496+
The value of this setting affects the _default_ value of <<plugins-{type}s-{plugin}-headers_target>> and
497+
<<plugins-{type}s-{plugin}-properties_target>>.
498+
471499
[id="plugins-{type}s-{plugin}-factory"]
472500
===== `factory`
473501

@@ -488,36 +516,71 @@ Hash of implementation specific configuration values to set on the connection fa
488516
`exclusive_consumer => true` would call `setExclusiveConsumer(true)` on the supplied connection factory.
489517
See your JMS provider documentation for implementation specific details.
490518

519+
[id="plugins-{type}s-{plugin}-headers_target"]
520+
===== `headers_target`
521+
522+
* Value type is <<string,string>>
523+
* Default value depends on whether <<plugins-{type}s-{plugin}-ecs_compatibility>> is enabled:
524+
** ECS Compatibility disabled: no default value for this setting
525+
** ECS Compatibility enabled: `"[@metadata][input][jms][headers]"
526+
527+
The name of the field under which JMS headers will be added, if <<plugins-{type}s-{plugin}-include_headers>> is set.
528+
491529
[id="plugins-{type}s-{plugin}-include_body"]
492530
===== `include_body`
493531

494532
* Value type is <<boolean,boolean>>
495533
* Default value is `true`
496534

497535
Include JMS Message Body in the event.
498-
Supports TextMessage, MapMessage and ByteMessage.
536+
Supports TextMessage, MapMessage and BytesMessage.
499537

500-
If the JMS Message is a TextMessage or ByteMessage, then the value will be in
538+
If the JMS Message is a TextMessage or BytesMessage, then the value will be in
501539
the "message" field of the event. If the JMS Message is a MapMessage, then all
502-
the key/value pairs will be added in the Hashmap of the event.
540+
the key/value pairs will be added at the top-level of the event by default.
541+
To avoid pollution of the top-level namespace, when receiving a MapMessage, use the <<plugins-{type}s-{plugin}-target>>.
503542

504543
StreamMessage and ObjectMessage are not supported.
505544

506545
[id="plugins-{type}s-{plugin}-include_header"]
507546
===== `include_header`
508547

548+
* Value type is <<boolean,boolean>>
549+
* This option is deprecated
550+
551+
Note: This option is deprecated and it will be removed in the next major version of Logstash.
552+
Use `include_headers` instead.
553+
554+
[id="plugins-{type}s-{plugin}-include_headers"]
555+
===== `include_headers`
556+
509557
* Value type is <<boolean,boolean>>
510558
* Default value is `true`
511559

512560
A JMS message has three parts:
513561

514-
* Message Headers (required)
515-
* Message Properties (optional)
516-
* Message Bodies (optional)
562+
* Message Headers (required)
563+
* Message Properties (optional)
564+
* Message Body (optional)
517565

518566
You can tell the input plugin which parts should be included in the event produced by Logstash.
519567

520-
Include JMS Message Header Field values in the event.
568+
Include standard JMS message header field values in the event.
569+
Example headers:
570+
[source,ruby]
571+
-----
572+
{
573+
"jms_message_id" => "ID:amqhost-39547-1636977297920-71:1:1:1:1",
574+
"jms_timestamp" => 1636977329102,
575+
"jms_expiration" => 0,
576+
"jms_delivery_mode" => "persistent",
577+
"jms_redelivered" => false,
578+
"jms_destination" => "topic://41ad5342149901ad",
579+
"jms_priority" => 4,
580+
"jms_type" => "sample",
581+
"jms_correlation_id" => "28d975cb-14ff-4285-841e-05ef1e0a7ab2"
582+
}
583+
-----
521584

522585
[id="plugins-{type}s-{plugin}-include_properties"]
523586
===== `include_properties`
@@ -590,6 +653,16 @@ Only for use with Oracle AQ
590653

591654
Password to use when connecting to the JMS provider.
592655

656+
[id="plugins-{type}s-{plugin}-properties_target"]
657+
===== `properties_target`
658+
659+
* Value type is <<string,string>>
660+
* Default value depends on whether <<plugins-{type}s-{plugin}-ecs_compatibility>> is enabled:
661+
** ECS Compatibility disabled: no default value for this setting
662+
** ECS Compatibility enabled: `"[@metadata][input][jms][properties]"
663+
664+
The name of the field under which JMS properties will be added, if <<plugins-{type}s-{plugin}-include_properties>> is set.
665+
593666
[id="plugins-{type}s-{plugin}-pub_sub"]
594667
===== `pub_sub`
595668

@@ -650,14 +723,25 @@ If `include_properties` is set, a list of properties to skip processing on can b
650723

651724
Any System properties that the JMS provider requires can be set either in a Hash here, or in `jvm.options`
652725

726+
[id="plugins-{type}s-{plugin}-target"]
727+
===== `target`
728+
729+
* Value type is <<string,string>>
730+
* There is no default value for this setting.
731+
732+
The name of the field to assign MapMessage data into.
733+
If not specified data will be stored in the root of the event.
734+
735+
NOTE: For TextMessage and BytesMessage the `target` has no effect. Use the codec setting instead
736+
e.g. `codec => json { target => "[jms]" }`.
653737

654738
[id="plugins-{type}s-{plugin}-threads"]
655739
===== `threads`
656740

657741
* Value type is <<number,number>>
658742
* Default value is `1`
659743

660-
* Note that if pub_sub is set to true, this value *must* be 1. A configuration error will be thrown otherwise
744+
NOTE: If pub_sub is set to `true`, this value *must* be `1`. A configuration error will be thrown otherwise!
661745

662746
[id="plugins-{type}s-{plugin}-timeout"]
663747
===== `timeout`

0 commit comments

Comments
 (0)