Skip to content

Commit 47fa201

Browse files
authored
feat(roles/logstash): add optional variables for setting up stack monitoring with Elastic agent (#235)
1 parent 217e941 commit 47fa201

5 files changed

Lines changed: 36 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616

1717
### Added
1818

19+
* **role:logstash**: Add optional variables `logstash__monitoring_cluster_uuid`, `logstash__monitoring_enabled`.
1920
* **role:elasticsearch**: Add optional variables `elasticsearch__cluster_routing_allocation_disk_watermark_flood_stage_frozen_max_headroom`, `elasticsearch__cluster_routing_allocation_disk_watermark_flood_stage_max_headroom`, `elasticsearch__cluster_routing_allocation_disk_watermark_high_max_headroom`, `elasticsearch__cluster_routing_allocation_disk_watermark_low_max_headroom`.
2021
* **role:elasticsearch**: Add optional variable `elasticsearch__cluster_routing_allocation_disk_watermark_flood_stage_frozen`.
2122
* **role:graylog_datanode**: Add optional variable `graylog_datanode__raw`.

roles/logstash/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,18 @@ If you use the [logstash playbook](https://github.com/Linuxfabrik/lfops/blob/mai
8484
* Type: String.
8585
* Default: `'info'`
8686

87+
`logstash__monitoring_cluster_uuid`
88+
89+
* Elasticsearch Cluster UUID. Binds the metrics of Logstash to this specific cluster.
90+
* Type: String.
91+
* Default: unset
92+
93+
`logstash__monitoring_enabled`
94+
95+
* Enables or disables default collection of Logstash monitoring data.
96+
* Type: Bool.
97+
* Default: `true`
98+
8799
`logstash__node_name`
88100

89101
* A descriptive name for the node.
@@ -218,6 +230,8 @@ logstash__grok_patterns__host_var:
218230
state: 'absent'
219231
logstash__java_opts: '-Djava.io.tmpdir={{ logstash__path_data }}/tmp'
220232
logstash__log_level: 'info'
233+
logstash__monitoring_cluster_uuid: 'zk-HjQtYQGyL3NFSSu7InA'
234+
logstash__monitoring_enabled: false
221235
logstash__node_name: '{{ ansible_facts["nodename"] }}'
222236
logstash__path_data: '/var/lib/logstash'
223237
logstash__path_logs: '/var/log/logstash'

roles/logstash/defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ logstash__java_opts: >
1414
-Xms{{ [((ansible_facts["memtotal_mb"] * 0.6) | int), 8192] | min }}m
1515
-Xmx{{ [((ansible_facts["memtotal_mb"] * 0.6) | int), 8192] | min }}m
1616
logstash__log_level: 'info'
17+
logstash__monitoring_enabled: true
1718
logstash__node_name: '{{ ansible_facts["nodename"] }}'
1819
logstash__path_data: '/var/lib/logstash'
1920
logstash__path_logs: '/var/log/logstash'

roles/logstash/tasks/main.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
- block:
2+
3+
- name: 'Ensure cluster uuid is valid'
4+
ansible.builtin.assert:
5+
that:
6+
- 'logstash__monitoring_cluster_uuid is ansible.builtin.regex("^[A-Za-z0-9_-]{22}$")'
7+
fail_msg: '`logstash__monitoring_cluster_uuid: {{ logstash__monitoring_cluster_uuid }}` is not a valid cluster uuid'
8+
when: 'logstash__monitoring_cluster_uuid is defined and logstash__monitoring_cluster_uuid | length > 0'
9+
10+
tags:
11+
- 'always'
12+
113
- block:
214

315
- name: 'Install logstash'

roles/logstash/templates/etc/logstash/logstash.yml.j2

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# {{ ansible_managed }}
2-
# 2026012801
2+
# 2026042801
33

44
# Settings file in YAML
55
#
@@ -374,6 +374,13 @@ path.logs: '{{ logstash__path_logs }}'
374374
#xpack.geoip.downloader.enabled: true
375375
#xpack.geoip.downloader.endpoint: "https://geoip.elastic.co/v1/database"
376376

377+
# Stack Monitoring
378+
# https://www.elastic.co/docs/reference/logstash/monitoring-with-elastic-agent
379+
monitoring.enabled: {{ logstash__monitoring_enabled | bool | string | lower }}
380+
{% if logstash__monitoring_cluster_uuid is defined and logstash__monitoring_cluster_uuid | length > 0 %}
381+
monitoring.cluster_uuid: '{{ logstash__monitoring_cluster_uuid }}'
382+
{% endif %}
383+
377384
{% if logstash__raw | length %}
378385
# raw
379386
{{ logstash__raw }}

0 commit comments

Comments
 (0)