Skip to content

Commit 1376f62

Browse files
authored
Add identification field for Logstash instance (NETWAYS#138)
* Add identification field for Logstash instance * Make ident field name configurable fixes NETWAYS#137
1 parent e762b50 commit 1376f62

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ Aside from `logstash.yml` we can manage Logstashs pipelines.
5050
* *logstash_pipelines*: List of pipelines with optional URL to repo (see docs/pipelines.md for details)
5151
* *logstash_global_ecs*: Set ECS compatibilty mode (default: none. Possible values: `disabled` or `v1`)
5252
* *logstash_elasticsearch_output*: Enable default pipeline to Elasticsearch (default: `true`)
53+
* *logstash_ident*: Add a field identifying the node that processed an event (default: `true`)
54+
* *logstash_ident_field_name*: Name of the identifying the instance (default: `"[netways][instance]"`)
5355
* *logstash_beats_input*: Enable default pipeline with `beats` input (default: `true`)
5456
* *logstash_beats_input_congestion*: Optional congestion threshold for the beats input pipeline
5557
* *logstash_beats_tls*: Activate TLS for the beats input pipeline (default: none but `true` with full stack setup if not set)

defaults/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ logstash_logging_file: true
5151
logstash_logging_slow_console: true
5252
logstash_logging_slow_file: true
5353

54+
logstash_ident: true
55+
logstash_ident_field_name: "[netways][instance]"
5456
logstash_pipeline_identifier: true
5557
logstash_pipeline_identifier_field_name: "[netways][pipeline]"
5658
logstash_pipeline_identifier_defaults: false

templates/elasticsearch-output.conf.j2

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ filter {
77
}
88
}
99

10+
{% endif %}
11+
{% if logstash_ident | bool %}
12+
filter {
13+
mutate {
14+
add_field => {
15+
"{{ logstash_ident_field_name }}" => "{{ ansible_hostname }}"
16+
}
17+
}
18+
}
19+
1020
{% endif %}
1121
output {
1222
elasticsearch {

0 commit comments

Comments
 (0)