community.general.logstash – Sends events to Logstash

Note

This plugin is part of the community.general collection (version 3.8.1).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install community.general.

To use it in a playbook, specify: community.general.logstash.

Synopsis

Requirements

The below requirements are needed on the local controller node that executes this callback.

  • whitelisting in configuration
  • logstash (python library)

Parameters

Parameter Choices/Defaults Configuration Comments
format_version
string
added in 2.0.0 of community.general
    Choices:
  • v1
  • v2
ini entries:

[callback_logstash]
format_version = v1

env:LOGSTASH_FORMAT_VERSION
Logging format
port
string
Default:
5000
ini entries:

[callback_logstash]
port = 5000

added in 1.0.0 of community.general
env:LOGSTASH_PORT
Port on which logstash is listening
pre_command
string
added in 2.0.0 of community.general
ini entries:

[callback_logstash]
pre_command = None

env:LOGSTASH_PRE_COMMAND
Executes command before run and result put to ansible_pre_command_output field.
server
string
Default:
"localhost"
ini entries:

[callback_logstash]
server = localhost

added in 1.0.0 of community.general
env:LOGSTASH_SERVER
Address of the Logstash server
type
string
Default:
"ansible"
ini entries:

[callback_logstash]
type = ansible

added in 1.0.0 of community.general
env:LOGSTASH_TYPE
Message type

Examples

ansible.cfg: |
    # Enable Callback plugin
    [defaults]
        callback_whitelist = community.general.logstash

    [callback_logstash]
        server = logstash.example.com
        port = 5000
        pre_command = git rev-parse HEAD
        type = ansible

11-input-tcp.conf: |
    # Enable Logstash TCP Input
    input {
            tcp {
                port => 5000
                codec => json
                add_field => { "[@metadata][beat]" => "notify" }
                add_field => { "[@metadata][type]" => "ansible" }
            }
        }

Authors

  • Yevhen Khmelenko (@ujenmr)

© 2012–2018 Michael DeHaan
© 2018–2021 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/latest/collections/community/general/logstash_callback.html