Giter Site home page Giter Site logo

ofzhur / logstash-formula Goto Github PK

View Code? Open in Web Editor NEW

This project forked from saltstack-formulas/logstash-formula

0.0 3.0 0.0 36 KB

Home Page: http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html

License: MIT License

SaltStack 60.30% HTML 39.70%

logstash-formula's Introduction

logstash formula

Install and configure Logstash for Debian and RedHat based systems using pillar data.

Note

See the full Salt Formulas installation and usage instructions.

Logstash requires Java, either the Oracle implementation or OpenJDK. Since that is outside the scope of this formula, you must ensure that Java is installed before applying this formula.

Available states

Install the logstash package, set up input/filter/output configuration files, and enable the service. Compatible only with Salt 2014.1.10+, due to requirement for "mapping" test in jinja 2.6.

Usage

See pillar.example for an example configuration.

Example

The easiest way to understand the formula is to look at an example. The following is example pillar data:

logstash:
    inputs:
        -
            plugin_name: file
            path:
                - /var/log/syslog
                - /var/log/authlog
            type: syslog
    filters:
        -
            plugin_name: grok
            match:
                message: '%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}'
            add_field:
                received_at: '%{@timestamp}'
                received_from: '%{host}'
    outputs:
        -
            plugin_name: lumberjack
            hosts:
                - logs.example.com
            port: 5000
            ssl_certificate: /etc/ssl/certs/lumberjack.crt

That would result in this logstash config (the three separate files it would create are concatenated here):

input {
    file {
        path => [
            "/var/log/syslog",
            "/var/log/auth.log"
        ]
        type => "syslog"
    }
}
filter {
    grok {
        match => {
            message => "%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}"
        }
        add_field => {
            received_at => "%{@timestamp}"
            received_from => "%{host}"
        }
    }
}
output {
    lumberjack {
        hosts => [
            "logs.example.com"
        ]
        port => "5000"
        ssl_certificate => "/etc/ssl/certs/lumberjack.crt"
    }
}

For a more complicated example, including conditionals, see pillar.example.

Pillar Data Explained

The pillar data is structured as a dictionary with key 'logstash', followed by three optional keys:

  • inputs: A list of input plugins, to be rendered in-order to /etc/logstash/conf.d/01-inputs.conf
  • filters: A list of filter plugins, to be rendered in-order to /etc/logstash/conf.d/02-filters.conf
  • outputs: A list of output plugins, to be rendered in-order to /etc/logstash/conf.d/03-outputs.conf

Each list item for any of the three plugin types contains arbitrary attributes of type string, number, dictionary, or list which will be rendered into Logstash's configuration syntax. For a list of plugins and their configuration attributes,see <http://logstash.net/docs/1.4.2/>.

Using Conditionals

The only plugin attributes that are unique for this formula is the "cond" attribute, which is used to set up conditionals. For example you may want to filter a logstash entry only if it meets certain criteria, such as being of a certain type. This formula supports if/else if/else by embedding the conditional to be used in the "cond" attribute of the plugin. For this reason, this formula does not support nested conditionals at this time. See pillar.example for an example of the conditional functionality.

Overriding Defaults

This formula sets up certain defaults in map.jinja, specifically:

  • Name of the logstash package is logstash
  • Name of the logstash service is logstash
  • The latest version of logstash available will be installed and kept up to date, instead of a one-time install of the latest version (e.g. use states.pkg.latest instead of states.pkg.installed)
  • The configuration files will use an indentation of four spaces

These settings can be overridden by adding the appropriate keys to your pillar data, for example:

logstash:
    pkg: logstash-altversion
    svc: logstash-alterversion
    pkgstate: installed # instead of latest
    indent: 2

logstash-formula's People

Contributors

brandentimm avatar jcockhren avatar nmadhok avatar whiteinge avatar teepark avatar abednarik avatar

Watchers

James Cloos avatar Oleg Zhurko avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.