Skip to content

Commit fad7ed9

Browse files
authored
Allow unsafe shutdown in Logstash (#241)
Also: * Rearrange YAML code in pipelines.yml template so it's easier to maintain * Rename broken variable names * Activate new feature for molecule scenarios that use Logstash * Minimalistic docs for new feature fixes #239
1 parent 1a339f8 commit fad7ed9

File tree

7 files changed

+37
-16
lines changed

7 files changed

+37
-16
lines changed

docs/logstash-pipelines.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,10 @@ Here the `default` output only receives the events that haven't already been sen
203203

204204
Every Output can have a `congestion:` option with a numerical value. If the Redis key already holds more items than the value says, the output will stop.
205205

206+
### Unsafe shutdown ###
207+
208+
If you need unsafe Logstash shutdowns, e.g. for testing, you can set `logstash_pipeline_unsafe_shutdown` to `true`. If you want better controll over which pipeline is allowed to shutdown unsafely, there are `ansible_input_unsafe_shutdown`and `ansible_forwarder_unsafe_shutdown` for default pipelines. And every pipeline has it's own `unsafe_shutdown` setting. All three default to the value of `logstash_pipeline_unsafe_shutdown` which by itself defaults to `false`.
209+
206210
## Caveats ##
207211

208212
There are still some minor issues you need to keep in mind:

molecule/elasticstack_default/converge.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
elasticstack_release: "{{ lookup('env', 'ELASTIC_RELEASE') | int}}"
1616
elasticsearch_heap: "1"
1717
elasticstack_full_stack: true
18+
logstash_pipeline_unsafe_shutdown: true
1819
beats_filebeat_syslog_udp: true
1920
beats_filebeat_syslog_tcp: true
2021
beats_filebeat_modules:

molecule/logstash_full_stack-oss/converge.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
elasticstack_full_stack: true
1818
elasticstack_variant: oss
1919
logstash_security: false
20+
logstash_pipeline_unsafe_shutdown: true
2021
elasticstack_security: false
2122
beats_filebeat_syslog_udp: true
2223
beats_filebeat_syslog_tcp: true

molecule/logstash_pipelines/converge.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
key: forwarder
3030
logstash_pipeline_identifier_field_name: "[mytest][pipelines]"
3131
logstash_pipeline_identifier_defaults: true
32+
logstash_pipeline_unsafe_shutdown: true
3233
elasticstack_release: "{{ lookup('env', 'ELASTIC_RELEASE') | int}}"
3334
elasticstack_full_stack: false
3435
tasks:

molecule/logstash_specific_version/converge.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
logstash_logging_console: false
1313
logstash_logging_slow_file: false
1414
logstash_pipeline_identifier: false
15+
logstash_pipeline_unsafe_shutdown: true
1516
elasticstack_release: "{{ lookup('env', 'ELASTIC_RELEASE') | int}}"
1617
elasticstack_full_stack: false
1718
tasks:

roles/logstash/defaults/main.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ logstash_config_path_logs: /var/log/logstash
1717
# pipeline configuration #
1818
logstash_manage_pipelines: true
1919
logstash_queue_type: persisted
20+
logstash_pipeline_unsafe_shutdown: false
2021

2122
# this will deactivate all pipeline management
2223
logstash_no_pipelines: false
@@ -38,10 +39,10 @@ logstash_pipelines:
3839
logstash_elasticsearch_output: true
3940
logstash_validate_after_inactivity: '300'
4041
logstash_beats_input: true
41-
ansible_input_queue_type: memory
42-
ansible_input_queue_max_bytes: 1gb
43-
ansible_forwarder_queue_type: memory
44-
ansible_forwarder_queue_max_bytes: 1gb
42+
logstash_input_queue_type: memory
43+
logstash_input_queue_max_bytes: 1gb
44+
logstash_forwarder_queue_type: memory
45+
logstash_forwarder_queue_max_bytes: 1gb
4546
logstash_sniffing: false
4647

4748
# logstash security

roles/logstash/templates/pipelines.yml.j2

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,29 @@
1919
# Default beat input #
2020
# Autoconfigured Redis outputs: input
2121

22-
- pipeline.id: ansible-input
23-
path.config: "/etc/logstash/conf.d/ansible-input/*.conf"
24-
queue.type: {{ ansible_input_queue_type }}
25-
queue.max_bytes: {{ ansible_input_queue_max_bytes }}
22+
- pipeline
23+
id: ansible-input
24+
unsafe_shutdown: {{ ansible_input_unsafe_shutdown | default({{ logstash_pipeline_unsafe_shutdown }}) }}
25+
path
26+
config: "/etc/logstash/conf.d/ansible-input/*.conf"
27+
queue
28+
type: {{ logstash_input_queue_type }}
29+
max_bytes: {{ logstash_input_queue_max_bytes }}
2630

2731
{% endif %}
2832
{% if logstash_elasticsearch_output | bool %}
2933

3034
# Default elasticsearch output #
3135
# Autoconfigured Redis input: forwarder
3236

33-
- pipeline.id: ansible-forwarder
34-
path.config: "/etc/logstash/conf.d/ansible-forwarder/*.conf"
35-
queue.type: {{ ansible_forwarder_queue_type }}
36-
queue.max_bytes: {{ ansible_forwarder_queue_max_bytes }}
37+
- pipeline
38+
id: ansible-forwarder
39+
unsafe_shutdown: {{ ansible_forwarder_unsafe_shutdown | default({{ logstash_pipeline_unsafe_shutdown }}) }}
40+
path
41+
config: "/etc/logstash/conf.d/ansible-forwarder/*.conf"
42+
queue
43+
type: {{ logstash_forwarder_queue_type }}
44+
max_bytes: {{ logstash_forwarder_queue_max_bytes }}
3745

3846
{% endif %}
3947
{% if logstash_pipelines is defined %}
@@ -64,10 +72,14 @@
6472

6573
{% endif %}
6674

67-
- pipeline.id: {{ item.name }}
68-
path.config: "/etc/logstash/conf.d/{{ item.name }}/*.conf"
69-
queue.type: {{ item.queue_type | default('memory') }}
70-
queue.max_bytes: {{ item.queue_max_bytes | default('1gb') }}
75+
- pipeline
76+
id: {{ item.name }}
77+
unsafe_shutdown: {{ item.unsafe_shutdown | default({{ logstash_pipeline_unsafe_shutdown }}) }}
78+
path
79+
config: "/etc/logstash/conf.d/{{ item.name }}/*.conf"
80+
queue
81+
type: {{ item.queue_type | default('memory') }}
82+
max_bytes: {{ item.queue_max_bytes | default('1gb') }}
7183

7284
{% endfor %}
7385
{% endif %}

0 commit comments

Comments
 (0)