Skip to content

Commit

Permalink
Fixed syntax for syntax check
Browse files Browse the repository at this point in the history
TIL:

* Logstash can read YAML. Logstash config check CAN NOT.
* Logstash documentation lists per-pipeline and global options in the
  same list. Config check does not allow to mix them
* Sometimes it just sucks to be alive

Damn, that cost a lot of time and local debugging in test hosts.
  • Loading branch information
widhalmt committed Aug 23, 2023
1 parent e18849d commit a5c88d4
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 30 deletions.
2 changes: 1 addition & 1 deletion docs/logstash-pipelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ Every Output can have a `congestion:` option with a numerical value. If the Redi

### Unsafe shutdown ###

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`.
If you need unsafe Logstash shutdowns, e.g. for testing, you can set `logstash_pipeline_unsafe_shutdown` to `true`. The variable doesn't have a default so Logstash falls back to its internal default of `false`.

## Caveats ##

Expand Down
1 change: 1 addition & 0 deletions molecule/elasticstack_default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
elasticsearch_heap: "2"
elasticstack_full_stack: true
logstash_pipeline_unsafe_shutdown: true
logstash_password_hash: false
beats_filebeat_syslog_udp: true
beats_filebeat_syslog_tcp: true
beats_filebeat_modules:
Expand Down
4 changes: 0 additions & 4 deletions molecule/elasticstack_default/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
elasticstack_initial_passwords: /usr/share/elasticsearch/initial_passwords
tasks:

- name: Give some time for tools to connect
ansible.builtin.wait_for:
timeout: 120

- name: Run Logstash syntax check
ansible.builtin.command: "/usr/share/logstash/bin/logstash --path.settings=/etc/logstash -t"
when: "'logstash' in group_names"
Expand Down
1 change: 0 additions & 1 deletion roles/logstash/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ logstash_config_path_logs: /var/log/logstash
# pipeline configuration #
logstash_manage_pipelines: true
logstash_queue_type: persisted
logstash_pipeline_unsafe_shutdown: false

# this will deactivate all pipeline management
logstash_no_pipelines: false
Expand Down
3 changes: 3 additions & 0 deletions roles/logstash/templates/logstash.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ http.port: {{ logstash_http_port }}
{% if logstash_global_ecs is defined %}
pipeline.ecs_compatibility: {{ logstash_global_ecs }}
{% endif %}
{% if pipeline.unsafe_shutdown is defined %}
pipeline.unsafe_shutdown: {{ logstash_pipeline_unsafe_shutdown }}
{% endif %}
{% if logstash_legacy_monitoring | bool and elasticstack_full_stack | bool and elasticstack_variant == "elastic" and elasticstack_release | int < 8 %}
xpack.monitoring.enabled: true
xpack.monitoring.elasticsearch.hosts: [ {% for host in logstash_elasticsearch %}"https://{{ host }}:{{ elasticstack_elasticsearch_http_port }}"{% if not loop.last %},{% endif %}{% endfor %} ]
Expand Down
36 changes: 12 additions & 24 deletions roles/logstash/templates/pipelines.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,21 @@
# Default beat input #
# Autoconfigured Redis outputs: input

- pipeline:
id: ansible-input
unsafe_shutdown: {{ ansible_input_unsafe_shutdown | default( logstash_pipeline_unsafe_shutdown ) }}
path:
config: "/etc/logstash/conf.d/ansible-input/*.conf"
queue:
type: {{ logstash_input_queue_type }}
max_bytes: {{ logstash_input_queue_max_bytes }}
- pipeline.id: ansible-input
path.config: "/etc/logstash/conf.d/ansible-input/*.conf"
queue.type: {{ logstash_input_queue_type }}
queue.max_bytes: {{ logstash_input_queue_max_bytes }}

{% endif %}
{% if logstash_elasticsearch_output | bool %}

# Default elasticsearch output #
# Autoconfigured Redis input: forwarder

- pipeline:
id: ansible-forwarder
unsafe_shutdown: {{ ansible_forwarder_unsafe_shutdown | default( logstash_pipeline_unsafe_shutdown ) }}
path:
config: "/etc/logstash/conf.d/ansible-forwarder/*.conf"
queue:
type: {{ logstash_forwarder_queue_type }}
max_bytes: {{ logstash_forwarder_queue_max_bytes }}
- pipeline.id: ansible-forwarder
path.config: "/etc/logstash/conf.d/ansible-forwarder/*.conf"
queue.type: {{ logstash_forwarder_queue_type }}
queue.max_bytes: {{ logstash_forwarder_queue_max_bytes }}

{% endif %}
{% if logstash_pipelines is defined %}
Expand Down Expand Up @@ -72,14 +64,10 @@

{% endif %}

- pipeline:
id: {{ item.name }}
unsafe_shutdown: {{ item.unsafe_shutdown | default( logstash_pipeline_unsafe_shutdown ) }}
path:
config: "/etc/logstash/conf.d/{{ item.name }}/*.conf"
queue:
type: {{ item.queue_type | default('memory') }}
max_bytes: {{ item.queue_max_bytes | default('1gb') }}
- pipeline.id: {{ item.name }}
path.config: "/etc/logstash/conf.d/{{ item.name }}/*.conf"
queue.type: {{ item.queue_type | default('memory') }}
queue.max_bytes: {{ item.queue_max_bytes | default('1gb') }}

{% endfor %}
{% endif %}

0 comments on commit a5c88d4

Please sign in to comment.