Skip to content

Instantly share code, notes, and snippets.

@xemoe
Last active July 15, 2016 06:53
Show Gist options
  • Save xemoe/f344c1a8b0af2f8c8eb91cd98d6d4d77 to your computer and use it in GitHub Desktop.
Save xemoe/f344c1a8b0af2f8c8eb91cd98d6d4d77 to your computer and use it in GitHub Desktop.
SSH Files inputs
@xemoe
Copy link
Author

xemoe commented Jul 13, 2016

10-files-forward.conf

input {
  file {
    path => "/mnt/sshfs/mainbox/logs/syslog"
    synced_path => "/opt/logstash/sincedb/mainbox.sincedb"
    start_position => "beginning"
    stat_interval => 1
    tags => [mainbox_syslog]
    type => "files_forward"
  }
}
output {
  if ([type] == "files_forward") {
    if "mainbox_syslog" in [tags] {
      file {
        path => "/backup/forwardlogs/%{+YYYY-MM-dd}/syslog_172.100.0.200.log"
        codec => { 
          line { format => "%{message}"} 
        }
      }
    }
  }
}

10-files-forward.conf.j2

{% if item.logstash_inputs.file is defined and item.logstash_inputs.file | length > 0 %}
{% if item.logstash_outputs.file is defined and item.logstash_outputs.file | length > 0 %}
input {
  file {
    path => "{{ item.logstash_inputs.file.from_file }}"
    synced_path => "{{ logstash_home }}/sincedb/{{ item.logstash_inputs.file.from_file | hash('sha1') }}.sincedb"
    start_position => "beginning"
    stat_interval => 1
    tags => {{ item.logstash_inputs.file.tags | to_yaml }}
    type => "{{ item.logstash_inputs.file.type | default("file_forward") }}"
  }
}
output {
    if ([type] == "{{ item.logstash_inputs.file.type }}") {
        if "{{ item.file_tag }}" in [tags] {
            file {
                path => "{{ item.backup_directory }}/%{+YYYY-MM-dd}/{{ item.logstash_outputs.file.to_file }}"
                codec => { line { format => "%{message}"} }
            }
        }
    }
}
{% endif %}
{% endif %}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment