logstash-input-heartbeat 3.0.3 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/CHANGELOG.md +16 -0
- data/LICENSE +199 -10
- data/README.md +1 -1
- data/docs/index.asciidoc +75 -4
- data/lib/logstash/inputs/heartbeat.rb +56 -22
- data/logstash-input-heartbeat.gemspec +5 -2
- data/spec/inputs/heartbeat_spec.rb +88 -7
- metadata +49 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 1d335bd56b5ab7b240316bd8348dd05ad386dc5956dab0ec518b956967f6b89a
|
|
4
|
+
data.tar.gz: 625150053c13c2d1ec751c981e0c9c7f41b19c326a8d304934a5ebbb26808cea
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 25027365f2339d553cc85d38ab5a1a28e149f1d933905bd840f4d2f0dbacdc1091f958858ae5644002c2a8764a176f157c809b50307497b4f29cd065cd0d0e0b
|
|
7
|
+
data.tar.gz: 88ce2b8e907b1ad815126736b219658456af1bb273a90f3b2f64264b1990ad87e4d996f83b982a7b3ee9ab77cc79df88217774b3b21ee18a3b8d71adc9ca4362
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
## 3.1.0
|
|
2
|
+
- Added new `sequence` setting to manage the type of sequence generator and added ECS
|
|
3
|
+
compatibility behavior [#18](https://github.com/logstash-plugins/logstash-input-heartbeat/pull/18)
|
|
4
|
+
|
|
5
|
+
## 3.0.7
|
|
6
|
+
- Fixed shutdown concurrency issues by simplifying shutdown signal handling [#15](https://github.com/logstash-plugins/logstash-input-heartbeat/pull/15)
|
|
7
|
+
|
|
8
|
+
## 3.0.6
|
|
9
|
+
- Docs: Set the default_codec doc attribute.
|
|
10
|
+
|
|
11
|
+
## 3.0.5
|
|
12
|
+
- Update gemspec summary
|
|
13
|
+
|
|
14
|
+
## 3.0.4
|
|
15
|
+
- Fix some documentation issues
|
|
16
|
+
|
|
1
17
|
## 3.0.2
|
|
2
18
|
- Relax constraint on logstash-core-plugin-api to >= 1.60 <= 2.99
|
|
3
19
|
|
data/LICENSE
CHANGED
|
@@ -1,13 +1,202 @@
|
|
|
1
|
-
Copyright (c) 2012–2016 Elasticsearch <http://www.elastic.co>
|
|
2
1
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
6
5
|
|
|
7
|
-
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2020 Elastic and contributors
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Logstash Plugin
|
|
2
2
|
|
|
3
|
-
[](https://travis-ci.com/logstash-plugins/logstash-input-heartbeat)
|
|
4
4
|
|
|
5
5
|
This is a plugin for [Logstash](https://github.com/elastic/logstash).
|
|
6
6
|
|
data/docs/index.asciidoc
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
:plugin: heartbeat
|
|
2
2
|
:type: input
|
|
3
|
+
:default_codec: plain
|
|
3
4
|
|
|
4
5
|
///////////////////////////////////////////
|
|
5
6
|
START - GENERATED VARIABLES, DO NOT EDIT!
|
|
@@ -12,7 +13,7 @@ START - GENERATED VARIABLES, DO NOT EDIT!
|
|
|
12
13
|
END - GENERATED VARIABLES, DO NOT EDIT!
|
|
13
14
|
///////////////////////////////////////////
|
|
14
15
|
|
|
15
|
-
[id="plugins-{type}-{plugin}"]
|
|
16
|
+
[id="plugins-{type}s-{plugin}"]
|
|
16
17
|
|
|
17
18
|
=== Heartbeat input plugin
|
|
18
19
|
|
|
@@ -25,6 +26,26 @@ Generate heartbeat messages.
|
|
|
25
26
|
The general intention of this is to test the performance and
|
|
26
27
|
availability of Logstash.
|
|
27
28
|
|
|
29
|
+
[id="plugins-{type}s-{plugin}-ecs"]
|
|
30
|
+
==== Elastic Common Schema (ECS)
|
|
31
|
+
|
|
32
|
+
This plugin could provide a field, originally named `clock`, to track `epoch` or `sequence` incremental numbers. When
|
|
33
|
+
<<plugins-{type}s-{plugin}-ecs_compatibility,ECS compatibility mode>> is enabled that value is now present in the
|
|
34
|
+
event's `[event][sequence]` subfield.
|
|
35
|
+
|
|
36
|
+
When <<plugins-{type}s-{plugin}-ecs_compatibility,ECS compatibility mode>> is enabled the use of `message` as
|
|
37
|
+
selector of sequence type is not available and only <<plugins-{type}s-{plugin}-sequence>> is considered. In this
|
|
38
|
+
case if `message` contains sequence selector strings it's ignored.
|
|
39
|
+
|
|
40
|
+
The existing `host` field is moved to `[host][name]` when ECS is enabled.
|
|
41
|
+
|
|
42
|
+
[cols="<l,<l,e,<e"]
|
|
43
|
+
|============================================================================================================
|
|
44
|
+
|`disabled` |`v1` |Availability |Description
|
|
45
|
+
|
|
46
|
+
|[host] |[host][name] |Always |Name or address of the host is running the plugin
|
|
47
|
+
|[clock] |[event][sequence] |When `sequence` setting enables it |Increment counter based on seconds or from local 0 based counter
|
|
48
|
+
|============================================================================================================
|
|
28
49
|
|
|
29
50
|
[id="plugins-{type}s-{plugin}-options"]
|
|
30
51
|
==== Heartbeat Input Configuration Options
|
|
@@ -35,8 +56,10 @@ This plugin supports the following configuration options plus the <<plugins-{typ
|
|
|
35
56
|
|=======================================================================
|
|
36
57
|
|Setting |Input type|Required
|
|
37
58
|
| <<plugins-{type}s-{plugin}-count>> |<<number,number>>|No
|
|
59
|
+
| <<plugins-{type}s-{plugin}-ecs_compatibility>> | <<string,string>>|No
|
|
38
60
|
| <<plugins-{type}s-{plugin}-interval>> |<<number,number>>|No
|
|
39
61
|
| <<plugins-{type}s-{plugin}-message>> |<<string,string>>|No
|
|
62
|
+
| <<plugins-{type}s-{plugin}-sequence>> |<<string,string>> one of `["none", "epoch", "sequence"]`|No
|
|
40
63
|
| <<plugins-{type}s-{plugin}-threads>> |<<number,number>>|No
|
|
41
64
|
|=======================================================================
|
|
42
65
|
|
|
@@ -54,6 +77,20 @@ input plugins.
|
|
|
54
77
|
How many times to iterate.
|
|
55
78
|
This is typically used only for testing purposes.
|
|
56
79
|
|
|
80
|
+
[id="plugins-{type}s-{plugin}-ecs_compatibility"]
|
|
81
|
+
===== `ecs_compatibility`
|
|
82
|
+
|
|
83
|
+
* Value type is <<string,string>>
|
|
84
|
+
* Supported values are:
|
|
85
|
+
** `disabled`: `clock` counter field added at root level
|
|
86
|
+
** `v1`: ECS compliant `[event][sequence]` counter field added to the event
|
|
87
|
+
* Default value depends on which version of Logstash is running:
|
|
88
|
+
** When Logstash provides a `pipeline.ecs_compatibility` setting, its value is used as the default
|
|
89
|
+
** Otherwise, the default value is `disabled`.
|
|
90
|
+
|
|
91
|
+
Controls this plugin's compatibility with the {ecs-ref}[Elastic Common Schema (ECS)].
|
|
92
|
+
Refer to <<plugins-{type}s-{plugin}-ecs>> in this topic for detailed information.
|
|
93
|
+
|
|
57
94
|
[id="plugins-{type}s-{plugin}-interval"]
|
|
58
95
|
===== `interval`
|
|
59
96
|
|
|
@@ -72,17 +109,49 @@ The default, `60`, means send a message every 60 seconds.
|
|
|
72
109
|
|
|
73
110
|
The message string to use in the event.
|
|
74
111
|
|
|
75
|
-
If you set this to `epoch
|
|
112
|
+
If you set this value to `epoch`, then this plugin will use the current
|
|
76
113
|
timestamp in unix timestamp (which is by definition, UTC). It will
|
|
77
114
|
output this value into a field called `clock`
|
|
78
115
|
|
|
79
|
-
If you set this to `sequence
|
|
116
|
+
If you set this value to `sequence`, then this plugin will send a sequence of
|
|
80
117
|
numbers beginning at 0 and incrementing each interval. It will
|
|
81
118
|
output this value into a field called `clock`
|
|
82
119
|
|
|
83
120
|
Otherwise, this value will be used verbatim as the event message. It
|
|
84
121
|
will output this value into a field called `message`
|
|
85
122
|
|
|
123
|
+
NOTE: Usage of `epoch` and `sequence` in `message` setting is deprecated.
|
|
124
|
+
Consider using <<plugins-{type}s-{plugin}-sequence>> settings, which takes precedence
|
|
125
|
+
over the usage of `message` setting as selector.
|
|
126
|
+
|
|
127
|
+
NOTE: If <<plugins-{type}s-{plugin}-ecs_compatibility,ECS compatibility mode>> is enabled
|
|
128
|
+
and `message` contains `epoch` or `sequence`, it is ignored and is not present as a field in
|
|
129
|
+
the generated event.
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
[id="plugins-{type}s-{plugin}-sequence"]
|
|
133
|
+
===== `sequence`
|
|
134
|
+
|
|
135
|
+
* Value can be any of: `none`, `epoch`, `sequence`
|
|
136
|
+
* Default value is `"none""`
|
|
137
|
+
|
|
138
|
+
If you set this value to `none`, then no sequence field is added.
|
|
139
|
+
|
|
140
|
+
If you set this value to `epoch`, then this plugin will use the current
|
|
141
|
+
timestamp in unix timestamp (which is by definition, UTC). It will
|
|
142
|
+
output this value into a field called `clock` if <<plugins-{type}s-{plugin}-ecs_compatibility,ECS compatibility mode>>
|
|
143
|
+
is disabled. Otherwise, the field name is `[event][sequence]`.
|
|
144
|
+
|
|
145
|
+
If you set this value to `sequence`, then this plugin will send a sequence of
|
|
146
|
+
numbers beginning at 0 and incrementing each interval. It will
|
|
147
|
+
output this value into a field called `clock` if <<plugins-{type}s-{plugin}-ecs_compatibility,ECS compatibility mode>>
|
|
148
|
+
is disabled. Otherwise, the field name is `[event][sequence]`
|
|
149
|
+
|
|
150
|
+
If `sequence` is defined, it takes precedence over `message` configuration.
|
|
151
|
+
If `message` doesn't have `epoch` or `sequence` values, it will be present in the generated event together with `clock`
|
|
152
|
+
field.
|
|
153
|
+
|
|
154
|
+
|
|
86
155
|
[id="plugins-{type}s-{plugin}-threads"]
|
|
87
156
|
===== `threads`
|
|
88
157
|
|
|
@@ -94,4 +163,6 @@ will output this value into a field called `message`
|
|
|
94
163
|
|
|
95
164
|
|
|
96
165
|
[id="plugins-{type}s-{plugin}-common-options"]
|
|
97
|
-
include::{include_path}/{type}.asciidoc[]
|
|
166
|
+
include::{include_path}/{type}.asciidoc[]
|
|
167
|
+
|
|
168
|
+
:default_codec!:
|
|
@@ -3,6 +3,9 @@ require "logstash/inputs/threadable"
|
|
|
3
3
|
require "logstash/namespace"
|
|
4
4
|
require "stud/interval"
|
|
5
5
|
require "socket" # for Socket.gethostname
|
|
6
|
+
require "logstash/plugin_mixins/deprecation_logger_support"
|
|
7
|
+
require "logstash/plugin_mixins/ecs_compatibility_support"
|
|
8
|
+
require 'logstash/plugin_mixins/event_support/event_factory_adapter'
|
|
6
9
|
|
|
7
10
|
# Generate heartbeat messages.
|
|
8
11
|
#
|
|
@@ -11,6 +14,10 @@ require "socket" # for Socket.gethostname
|
|
|
11
14
|
#
|
|
12
15
|
|
|
13
16
|
class LogStash::Inputs::Heartbeat < LogStash::Inputs::Threadable
|
|
17
|
+
include LogStash::PluginMixins::DeprecationLoggerSupport
|
|
18
|
+
include LogStash::PluginMixins::ECSCompatibilitySupport(:disabled, :v1, :v8 => :v1)
|
|
19
|
+
include LogStash::PluginMixins::EventSupport::EventFactoryAdapter
|
|
20
|
+
|
|
14
21
|
config_name "heartbeat"
|
|
15
22
|
|
|
16
23
|
default :codec, "plain"
|
|
@@ -38,37 +45,64 @@ class LogStash::Inputs::Heartbeat < LogStash::Inputs::Threadable
|
|
|
38
45
|
# This is typically used only for testing purposes.
|
|
39
46
|
config :count, :validate => :number, :default => -1
|
|
40
47
|
|
|
41
|
-
|
|
48
|
+
# Select the type of sequence, deprecating the 'epoch' and 'sequence' values in 'message'.
|
|
49
|
+
#
|
|
50
|
+
# If you set this to `epoch` then this plugin will use the current
|
|
51
|
+
# timestamp in unix timestamp (which is by definition, UTC).
|
|
52
|
+
#
|
|
53
|
+
# If you set this to `sequence` then this plugin will send a sequence of
|
|
54
|
+
# numbers beginning at 0 and incrementing each interval.
|
|
55
|
+
#
|
|
56
|
+
# If you set this to 'none' then no field is created
|
|
57
|
+
config :sequence, :validate => ["none", "epoch", "sequence"]
|
|
58
|
+
|
|
42
59
|
def register
|
|
43
60
|
@host = Socket.gethostname
|
|
44
|
-
|
|
61
|
+
@field_sequence = ecs_select[disabled: "clock", v1: "[event][sequence]"]
|
|
62
|
+
@field_host = ecs_select[disabled: "host", v1: "[host][name]"]
|
|
63
|
+
if sequence.nil? && ["epoch", "sequence"].include?(message)
|
|
64
|
+
logger.warn("message contains sequence type specification (epoch|sequence) for this purpose use the sequence option")
|
|
65
|
+
end
|
|
66
|
+
if ecs_compatibility == :disabled && @sequence.nil?
|
|
67
|
+
if %w(epoch sequence).include?(@message)
|
|
68
|
+
logger.debug("intercepting magic `message` to configure `sequence`: `#{@message}`")
|
|
69
|
+
@sequence, @message = @message, nil # legacy: intercept magic messages
|
|
70
|
+
deprecation_logger.deprecated("magic values of `message` to specify sequence type are deprecated; use separate `sequence` option instead.")
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
@sequence = "none" if @sequence.nil?
|
|
74
|
+
@sequence_selector = @sequence.to_sym
|
|
75
|
+
end
|
|
45
76
|
|
|
46
77
|
def run(queue)
|
|
47
|
-
|
|
48
|
-
|
|
78
|
+
sequence_count = 0
|
|
79
|
+
|
|
80
|
+
while !stop?
|
|
81
|
+
start = Time.now
|
|
49
82
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
event = generate_message(sequence)
|
|
83
|
+
sequence_count += 1
|
|
84
|
+
event = generate_message(sequence_count)
|
|
53
85
|
decorate(event)
|
|
54
86
|
queue << event
|
|
55
|
-
break if
|
|
56
|
-
end # loop
|
|
87
|
+
break if sequence_count == @count || stop?
|
|
57
88
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
public
|
|
61
|
-
def generate_message(sequence)
|
|
62
|
-
if @message == "epoch"
|
|
63
|
-
LogStash::Event.new("clock" => Time.now.to_i, "host" => @host)
|
|
64
|
-
elsif @message == "sequence"
|
|
65
|
-
LogStash::Event.new("clock" => sequence, "host" => @host)
|
|
66
|
-
else
|
|
67
|
-
LogStash::Event.new("message" => @message, "host" => @host)
|
|
89
|
+
sleep_for = @interval - (Time.now - start)
|
|
90
|
+
Stud.stoppable_sleep(sleep_for) { stop? } if sleep_for > 0
|
|
68
91
|
end
|
|
69
92
|
end
|
|
70
93
|
|
|
71
|
-
def
|
|
72
|
-
|
|
94
|
+
def generate_message(sequence_count)
|
|
95
|
+
if @sequence_selector == :none
|
|
96
|
+
evt = event_factory.new_event("message" => @message)
|
|
97
|
+
evt.set(@field_host, @host)
|
|
98
|
+
return evt
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
sequence_value = @sequence_selector == :epoch ? Time.now.to_i : sequence_count
|
|
102
|
+
evt = event_factory.new_event()
|
|
103
|
+
evt.set(@field_sequence, sequence_value)
|
|
104
|
+
evt.set(@field_host, @host)
|
|
105
|
+
evt.set("message", @message) unless @message.nil?
|
|
106
|
+
evt
|
|
73
107
|
end
|
|
74
|
-
end
|
|
108
|
+
end
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Gem::Specification.new do |s|
|
|
2
2
|
|
|
3
3
|
s.name = 'logstash-input-heartbeat'
|
|
4
|
-
s.version = '3.0
|
|
4
|
+
s.version = '3.1.0'
|
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
|
6
|
-
s.summary = "
|
|
6
|
+
s.summary = "Generates heartbeat events for testing"
|
|
7
7
|
s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
|
|
8
8
|
s.authors = ["Elastic"]
|
|
9
9
|
s.email = 'info@elastic.co'
|
|
@@ -23,6 +23,9 @@ Gem::Specification.new do |s|
|
|
|
23
23
|
s.add_runtime_dependency "logstash-core-plugin-api", ">= 1.60", "<= 2.99"
|
|
24
24
|
s.add_runtime_dependency 'logstash-codec-plain'
|
|
25
25
|
s.add_runtime_dependency 'stud'
|
|
26
|
+
s.add_runtime_dependency 'logstash-mixin-ecs_compatibility_support', '~>1.2'
|
|
27
|
+
s.add_runtime_dependency 'logstash-mixin-deprecation_logger_support', '~>1.0'
|
|
28
|
+
s.add_runtime_dependency 'logstash-mixin-event_support', '~> 1.0'
|
|
26
29
|
|
|
27
30
|
s.add_development_dependency 'logstash-devutils'
|
|
28
31
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
require "logstash/devutils/rspec/spec_helper"
|
|
2
|
+
require "logstash/devutils/rspec/shared_examples"
|
|
2
3
|
require "logstash/inputs/heartbeat"
|
|
4
|
+
require "logstash/plugin_mixins/ecs_compatibility_support/spec_helper"
|
|
3
5
|
|
|
4
6
|
describe LogStash::Inputs::Heartbeat do
|
|
5
7
|
|
|
@@ -7,6 +9,10 @@ describe LogStash::Inputs::Heartbeat do
|
|
|
7
9
|
let(:config) { { "interval" => 100 } }
|
|
8
10
|
end
|
|
9
11
|
|
|
12
|
+
before :each do
|
|
13
|
+
subject.register
|
|
14
|
+
end
|
|
15
|
+
|
|
10
16
|
sequence = 1
|
|
11
17
|
context "Default message test" do
|
|
12
18
|
subject { LogStash::Inputs::Heartbeat.new({}) }
|
|
@@ -25,7 +31,7 @@ describe LogStash::Inputs::Heartbeat do
|
|
|
25
31
|
end # context "Simple message test" do
|
|
26
32
|
|
|
27
33
|
context "Sequence test" do
|
|
28
|
-
subject { LogStash::Inputs::Heartbeat.new({"message" => "sequence"}) }
|
|
34
|
+
subject { LogStash::Inputs::Heartbeat.new({"message" => "sequence", "ecs_compatibility" => :disabled}) }
|
|
29
35
|
|
|
30
36
|
it "should return an event with the appropriate sequence value" do
|
|
31
37
|
expect(subject.generate_message(sequence).get("clock")).to eq(sequence)
|
|
@@ -33,23 +39,98 @@ describe LogStash::Inputs::Heartbeat do
|
|
|
33
39
|
end # context "Sequence test"
|
|
34
40
|
|
|
35
41
|
context "Epoch test" do
|
|
36
|
-
subject { LogStash::Inputs::Heartbeat.new({"message" => "epoch"}) }
|
|
42
|
+
subject { LogStash::Inputs::Heartbeat.new({"message" => "epoch", "ecs_compatibility" => :disabled}) }
|
|
37
43
|
|
|
38
44
|
it "should return an event with the current time (as epoch)" do
|
|
39
45
|
now = Time.now.to_i
|
|
40
46
|
# Give it a second, just in case
|
|
41
|
-
|
|
47
|
+
evt = subject.generate_message(sequence)
|
|
48
|
+
expect(evt.get("clock") - now).to be < 2
|
|
49
|
+
expect(evt).to_not include "message"
|
|
42
50
|
end # it "should return an event with the current time (as epoch)"
|
|
43
51
|
end # context "Epoch test"
|
|
44
52
|
|
|
53
|
+
context "Epoch test with ECS enabled" do
|
|
54
|
+
subject { LogStash::Inputs::Heartbeat.new({"sequence" => "epoch", "ecs_compatibility" => :v1}) }
|
|
55
|
+
|
|
56
|
+
it "should return an event with the current time (as epoch)" do
|
|
57
|
+
now = Time.now.to_i
|
|
58
|
+
# Give it a second, just in case
|
|
59
|
+
expect(subject.generate_message(sequence).get("[event][sequence]") - now).to be < 2
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
context "and message is defined with sequence selector" do
|
|
63
|
+
subject { LogStash::Inputs::Heartbeat.new({"sequence" => "epoch", "message" => "sequence", "ecs_compatibility" => :v1}) }
|
|
64
|
+
|
|
65
|
+
it "should return an event with the message field with the exact text provided but populating the sequence field as requested by 'sequence' setting" do
|
|
66
|
+
now = Time.now.to_i
|
|
67
|
+
# Give it a second, just in case
|
|
68
|
+
evt = subject.generate_message(sequence)
|
|
69
|
+
expect(evt.get("[event][sequence]") - now).to be < 2
|
|
70
|
+
#expect(evt).to_not include "message"
|
|
71
|
+
expect(evt.get("message")).to eq("sequence")
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
context "and message is defined with free text" do
|
|
76
|
+
subject { LogStash::Inputs::Heartbeat.new({"sequence" => "epoch", "message" => "funny message", "ecs_compatibility" => :v1}) }
|
|
77
|
+
|
|
78
|
+
it "should return an event without the message field but populating the sequence field as requested by 'sequence' setting" do
|
|
79
|
+
now = Time.now.to_i
|
|
80
|
+
# Give it a second, just in case
|
|
81
|
+
evt = subject.generate_message(sequence)
|
|
82
|
+
expect(evt.get("[event][sequence]") - now).to be < 2
|
|
83
|
+
expect(evt.get("message")).to eq("funny message")
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
45
88
|
context "with a fixed count" do
|
|
46
89
|
let(:events) { [] }
|
|
47
90
|
let(:count) { 4 }
|
|
48
|
-
subject { LogStash::Inputs::Heartbeat.new("interval" => 1, "message" => "sequence", "count" => count) }
|
|
49
91
|
|
|
50
|
-
|
|
51
|
-
subject.
|
|
52
|
-
|
|
92
|
+
context "ECS disabled" do
|
|
93
|
+
subject { LogStash::Inputs::Heartbeat.new("interval" => 1, "message" => "sequence", "count" => count, "ecs_compatibility" => :disabled) }
|
|
94
|
+
|
|
95
|
+
it "should generate a fixed number of events then stop" do
|
|
96
|
+
subject.run(events)
|
|
97
|
+
events.each_with_index{|event, i| expect(event.get("clock")).to eq(i + 1)}
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
context "ECS enabled" do
|
|
102
|
+
subject { LogStash::Inputs::Heartbeat.new("interval" => 1, "sequence" => "sequence", "count" => count, "ecs_compatibility" => :v1) }
|
|
103
|
+
|
|
104
|
+
it "should generate a fixed number of events then stop" do
|
|
105
|
+
subject.run(events)
|
|
106
|
+
events.each_with_index{|event, i| expect(event.get("[event][sequence]")).to eq(i + 1)}
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
context "sequence settings test" do
|
|
112
|
+
subject { LogStash::Inputs::Heartbeat.new({"sequence" => "epoch", "message" => "sequence", "ecs_compatibility" => :disabled}) }
|
|
113
|
+
|
|
114
|
+
it "should return an event giving sequence precedence over message" do
|
|
115
|
+
now = Time.now.to_i
|
|
116
|
+
# Give it a second, just in case
|
|
117
|
+
expect(subject.generate_message(sequence).get("clock") - now).to be < 2
|
|
118
|
+
end # it "should return an event with the current time (as epoch)"
|
|
119
|
+
end # context "Epoch test"
|
|
120
|
+
|
|
121
|
+
shared_examples "use hostname field with ECS" do |ecs_compatibility, field_name|
|
|
122
|
+
subject { LogStash::Inputs::Heartbeat.new({"ecs_compatibility" => ecs_compatibility}) }
|
|
123
|
+
|
|
124
|
+
before(:each) do
|
|
125
|
+
subject.register
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
it "should populate #{field_name}" do
|
|
129
|
+
evt = subject.generate_message(sequence)
|
|
130
|
+
expect(evt.get(field_name)).to eq(Socket.gethostname)
|
|
53
131
|
end
|
|
54
132
|
end
|
|
133
|
+
|
|
134
|
+
it_behaves_like "use hostname field with ECS", :disabled, "host"
|
|
135
|
+
it_behaves_like "use hostname field with ECS", :v1, "[host][name]"
|
|
55
136
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: logstash-input-heartbeat
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.0
|
|
4
|
+
version: 3.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Elastic
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2021-07-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -58,6 +58,48 @@ dependencies:
|
|
|
58
58
|
- - ">="
|
|
59
59
|
- !ruby/object:Gem::Version
|
|
60
60
|
version: '0'
|
|
61
|
+
- !ruby/object:Gem::Dependency
|
|
62
|
+
requirement: !ruby/object:Gem::Requirement
|
|
63
|
+
requirements:
|
|
64
|
+
- - "~>"
|
|
65
|
+
- !ruby/object:Gem::Version
|
|
66
|
+
version: '1.2'
|
|
67
|
+
name: logstash-mixin-ecs_compatibility_support
|
|
68
|
+
prerelease: false
|
|
69
|
+
type: :runtime
|
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
71
|
+
requirements:
|
|
72
|
+
- - "~>"
|
|
73
|
+
- !ruby/object:Gem::Version
|
|
74
|
+
version: '1.2'
|
|
75
|
+
- !ruby/object:Gem::Dependency
|
|
76
|
+
requirement: !ruby/object:Gem::Requirement
|
|
77
|
+
requirements:
|
|
78
|
+
- - "~>"
|
|
79
|
+
- !ruby/object:Gem::Version
|
|
80
|
+
version: '1.0'
|
|
81
|
+
name: logstash-mixin-deprecation_logger_support
|
|
82
|
+
prerelease: false
|
|
83
|
+
type: :runtime
|
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
85
|
+
requirements:
|
|
86
|
+
- - "~>"
|
|
87
|
+
- !ruby/object:Gem::Version
|
|
88
|
+
version: '1.0'
|
|
89
|
+
- !ruby/object:Gem::Dependency
|
|
90
|
+
requirement: !ruby/object:Gem::Requirement
|
|
91
|
+
requirements:
|
|
92
|
+
- - "~>"
|
|
93
|
+
- !ruby/object:Gem::Version
|
|
94
|
+
version: '1.0'
|
|
95
|
+
name: logstash-mixin-event_support
|
|
96
|
+
prerelease: false
|
|
97
|
+
type: :runtime
|
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
99
|
+
requirements:
|
|
100
|
+
- - "~>"
|
|
101
|
+
- !ruby/object:Gem::Version
|
|
102
|
+
version: '1.0'
|
|
61
103
|
- !ruby/object:Gem::Dependency
|
|
62
104
|
requirement: !ruby/object:Gem::Requirement
|
|
63
105
|
requirements:
|
|
@@ -72,7 +114,9 @@ dependencies:
|
|
|
72
114
|
- - ">="
|
|
73
115
|
- !ruby/object:Gem::Version
|
|
74
116
|
version: '0'
|
|
75
|
-
description: This gem is a Logstash plugin required to be installed on top of the
|
|
117
|
+
description: This gem is a Logstash plugin required to be installed on top of the
|
|
118
|
+
Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This
|
|
119
|
+
gem is not a stand-alone program
|
|
76
120
|
email: info@elastic.co
|
|
77
121
|
executables: []
|
|
78
122
|
extensions: []
|
|
@@ -111,9 +155,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
111
155
|
version: '0'
|
|
112
156
|
requirements: []
|
|
113
157
|
rubyforge_project:
|
|
114
|
-
rubygems_version: 2.
|
|
158
|
+
rubygems_version: 2.6.13
|
|
115
159
|
signing_key:
|
|
116
160
|
specification_version: 4
|
|
117
|
-
summary:
|
|
161
|
+
summary: Generates heartbeat events for testing
|
|
118
162
|
test_files:
|
|
119
163
|
- spec/inputs/heartbeat_spec.rb
|