Use id for doc id if it exists

This commit is contained in:
Josh Brower
2021-12-09 09:16:58 -05:00
parent 892899b7f9
commit 656ea974dc

View File

@@ -7,13 +7,30 @@
{%- set ES_PASS = salt['pillar.get']('elasticsearch:auth:users:so_elastic_user:pass', '') %} {%- set ES_PASS = salt['pillar.get']('elasticsearch:auth:users:so_elastic_user:pass', '') %}
output { output {
if "beat-ext" in [tags] and "import" not in [tags] and "filebeat" not in [metadata][pipeline] { if "beat-ext" in [tags] and "import" not in [tags] and "filebeat" not in [metadata][pipeline] {
if [metadata][_id] {
elasticsearch { elasticsearch {
pipeline => "beats.common" pipeline => "beats.common"
hosts => "{{ ES }}" hosts => "{{ ES }}"
{% if salt['pillar.get']('elasticsearch:auth:enabled') is sameas true %} {% if salt['pillar.get']('elasticsearch:auth:enabled') is sameas true %}
user => "{{ ES_USER }}" user => "{{ ES_USER }}"
password => "{{ ES_PASS }}" password => "{{ ES_PASS }}"
{% endif %} {% endif %}
index => "so-beats"
template_name => "so-beats"
template => "/templates/so-beats-template.json"
template_overwrite => true
ssl => true
ssl_certificate_verification => false
document_id => "%{[metadata][_id]}"
}
} else {
elasticsearch {
pipeline => "beats.common"
hosts => "{{ ES }}"
{% if salt['pillar.get']('elasticsearch:auth:enabled') is sameas true %}
user => "{{ ES_USER }}"
password => "{{ ES_PASS }}"
{% endif %}
index => "so-beats" index => "so-beats"
template_name => "so-beats" template_name => "so-beats"
template => "/templates/so-beats-template.json" template => "/templates/so-beats-template.json"
@@ -22,4 +39,5 @@ output {
ssl_certificate_verification => false ssl_certificate_verification => false
} }
} }
}
} }