From 2b65764a2e8360cc57b78fc32b6f0afecb29f7af Mon Sep 17 00:00:00 2001 From: Andrew Bonney Date: Fri, 27 May 2022 14:05:45 +0100 Subject: [PATCH] Enable cluster ID monitoring setting for beats using logstash Change-Id: I59e7c92ebd91ceca161577e73d9f24826abedda1 --- .../roles/elastic_auditbeat/templates/auditbeat.yml.j2 | 2 +- .../roles/elastic_filebeat/templates/filebeat.yml.j2 | 2 +- .../roles/elastic_heartbeat/templates/heartbeat.yml.j2 | 2 +- .../roles/elastic_journalbeat/templates/journalbeat.yml.j2 | 2 +- .../roles/elastic_metricbeat/templates/metricbeat.yml.j2 | 2 +- .../roles/elastic_packetbeat/templates/packetbeat.yml.j2 | 2 +- elk_metrics_7x/templates/_macros.j2 | 6 ++++-- 7 files changed, 10 insertions(+), 8 deletions(-) diff --git a/elk_metrics_7x/roles/elastic_auditbeat/templates/auditbeat.yml.j2 b/elk_metrics_7x/roles/elastic_auditbeat/templates/auditbeat.yml.j2 index e3cf7b75..101994c1 100644 --- a/elk_metrics_7x/roles/elastic_auditbeat/templates/auditbeat.yml.j2 +++ b/elk_metrics_7x/roles/elastic_auditbeat/templates/auditbeat.yml.j2 @@ -1155,7 +1155,7 @@ setup.ilm.policy_file: "{{ ilm_policy_file_location }}/{{ ilm_policy_filename }} {{ elk_macros.beat_logging('auditbeat', auditbeat_log_level) }} # ============================= X-Pack Monitoring ============================== -{{ elk_macros.xpack_monitoring_elasticsearch('auditbeat', inventory_hostname, elasticsearch_data_hosts, ansible_processor_count, beats_system_username) }} +{{ elk_macros.xpack_monitoring_elasticsearch('auditbeat', inventory_hostname, elasticsearch_data_hosts, ansible_processor_count, beats_system_username, elastic_cluster_uuid) }} # =============================== HTTP Endpoint ================================ diff --git a/elk_metrics_7x/roles/elastic_filebeat/templates/filebeat.yml.j2 b/elk_metrics_7x/roles/elastic_filebeat/templates/filebeat.yml.j2 index 24eeeb36..545123b6 100644 --- a/elk_metrics_7x/roles/elastic_filebeat/templates/filebeat.yml.j2 +++ b/elk_metrics_7x/roles/elastic_filebeat/templates/filebeat.yml.j2 @@ -2048,7 +2048,7 @@ setup.ilm.policy_file: "{{ ilm_policy_file_location }}/{{ ilm_policy_filename }} {{ elk_macros.beat_logging('filebeat', filebeat_log_level) }} # ============================= X-Pack Monitoring ============================== -{{ elk_macros.xpack_monitoring_elasticsearch('filebeat', inventory_hostname, elasticsearch_data_hosts, ansible_processor_count, beats_system_username) }} +{{ elk_macros.xpack_monitoring_elasticsearch('filebeat', inventory_hostname, elasticsearch_data_hosts, ansible_processor_count, beats_system_username, elastic_cluster_uuid) }} # =============================== HTTP Endpoint ================================ diff --git a/elk_metrics_7x/roles/elastic_heartbeat/templates/heartbeat.yml.j2 b/elk_metrics_7x/roles/elastic_heartbeat/templates/heartbeat.yml.j2 index f41c6b9a..41483cb3 100644 --- a/elk_metrics_7x/roles/elastic_heartbeat/templates/heartbeat.yml.j2 +++ b/elk_metrics_7x/roles/elastic_heartbeat/templates/heartbeat.yml.j2 @@ -1282,7 +1282,7 @@ setup.ilm.policy_file: "{{ ilm_policy_file_location }}/{{ ilm_policy_filename }} {{ elk_macros.beat_logging('heartbeat', heartbeat_log_level) }} # ============================= X-Pack Monitoring ============================== -{{ elk_macros.xpack_monitoring_elasticsearch('heartbeat', inventory_hostname, elasticsearch_data_hosts, ansible_processor_count, beats_system_username) }} +{{ elk_macros.xpack_monitoring_elasticsearch('heartbeat', inventory_hostname, elasticsearch_data_hosts, ansible_processor_count, beats_system_username, elastic_cluster_uuid) }} # =============================== HTTP Endpoint ================================ diff --git a/elk_metrics_7x/roles/elastic_journalbeat/templates/journalbeat.yml.j2 b/elk_metrics_7x/roles/elastic_journalbeat/templates/journalbeat.yml.j2 index f7ed0233..91671bb2 100644 --- a/elk_metrics_7x/roles/elastic_journalbeat/templates/journalbeat.yml.j2 +++ b/elk_metrics_7x/roles/elastic_journalbeat/templates/journalbeat.yml.j2 @@ -1019,7 +1019,7 @@ setup.ilm.policy_file: "{{ ilm_policy_file_location }}/{{ ilm_policy_filename }} {{ elk_macros.beat_logging('journalbeat', journalbeat_log_level) }} # ============================= X-Pack Monitoring ============================== -{{ elk_macros.xpack_monitoring_elasticsearch('journalbeat', inventory_hostname, elasticsearch_data_hosts, ansible_processor_count, beats_system_username) }} +{{ elk_macros.xpack_monitoring_elasticsearch('journalbeat', inventory_hostname, elasticsearch_data_hosts, ansible_processor_count, beats_system_username, elastic_cluster_uuid) }} # =============================== HTTP Endpoint ================================ diff --git a/elk_metrics_7x/roles/elastic_metricbeat/templates/metricbeat.yml.j2 b/elk_metrics_7x/roles/elastic_metricbeat/templates/metricbeat.yml.j2 index bd6311e4..27e713cc 100644 --- a/elk_metrics_7x/roles/elastic_metricbeat/templates/metricbeat.yml.j2 +++ b/elk_metrics_7x/roles/elastic_metricbeat/templates/metricbeat.yml.j2 @@ -1916,7 +1916,7 @@ setup.ilm.policy_file: "{{ ilm_policy_file_location }}/{{ ilm_policy_filename }} {{ elk_macros.beat_logging('metricbeat', metricbeat_log_level) }} # ============================= X-Pack Monitoring ============================== -{{ elk_macros.xpack_monitoring_elasticsearch('metricbeat', inventory_hostname, elasticsearch_data_hosts, ansible_processor_count, beats_system_username) }} +{{ elk_macros.xpack_monitoring_elasticsearch('metricbeat', inventory_hostname, elasticsearch_data_hosts, ansible_processor_count, beats_system_username, elastic_cluster_uuid) }} # =============================== HTTP Endpoint ================================ diff --git a/elk_metrics_7x/roles/elastic_packetbeat/templates/packetbeat.yml.j2 b/elk_metrics_7x/roles/elastic_packetbeat/templates/packetbeat.yml.j2 index 2cbff5dd..06a6c29d 100644 --- a/elk_metrics_7x/roles/elastic_packetbeat/templates/packetbeat.yml.j2 +++ b/elk_metrics_7x/roles/elastic_packetbeat/templates/packetbeat.yml.j2 @@ -1578,7 +1578,7 @@ setup.ilm.policy_file: "{{ ilm_policy_file_location }}/{{ ilm_policy_filename }} {{ elk_macros.beat_logging('packetbeat', packetbeat_log_level) }} # ============================= X-Pack Monitoring ============================== -{{ elk_macros.xpack_monitoring_elasticsearch('packetbeat', inventory_hostname, elasticsearch_data_hosts, ansible_processor_count, beats_system_username) }} +{{ elk_macros.xpack_monitoring_elasticsearch('packetbeat', inventory_hostname, elasticsearch_data_hosts, ansible_processor_count, beats_system_username, elastic_cluster_uuid) }} # =============================== HTTP Endpoint ================================ diff --git a/elk_metrics_7x/templates/_macros.j2 b/elk_metrics_7x/templates/_macros.j2 index d0b83938..0008bb22 100644 --- a/elk_metrics_7x/templates/_macros.j2 +++ b/elk_metrics_7x/templates/_macros.j2 @@ -532,7 +532,7 @@ logging.files: #logging.ecs: false {%- endmacro %} -{% macro xpack_monitoring_elasticsearch(beat_name, host, data_hosts, processors, username) -%} +{% macro xpack_monitoring_elasticsearch(beat_name, host, data_hosts, processors, username, uuid) -%} # {{ beat_name | capitalize }} can export internal metrics to a central Elasticsearch monitoring # cluster. This requires xpack monitoring to be enabled in Elasticsearch. The # reporting is disabled by default. @@ -543,7 +543,9 @@ monitoring.enabled: true # Sets the UUID of the Elasticsearch cluster under which monitoring data for this # {{ beat_name | capitalize }} instance will appear in the Stack Monitoring UI. If output.elasticsearch # is enabled, the UUID is derived from the Elasticsearch cluster referenced by output.elasticsearch. -#monitoring.cluster_uuid: +{% if uuid is defined %} +monitoring.cluster_uuid: {{ uuid }} +{% endif %} # Uncomment to send the metrics to Elasticsearch. Most settings from the # Elasticsearch output are accepted here as well.