community.general.logstash callback – Sends events to Logstash

Note

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

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

Comments

format_version

string

added in 2.0.0 of community.general

Logging format

Choices:

  • v1 ← (default)

  • v2

Configuration:

  • INI entry:

    [callback_logstash]
    format_version = v1
    
  • Environment variable: LOGSTASH_FORMAT_VERSION

port

string

Port on which logstash is listening

Default: 5000

Configuration:

  • INI entry:

    [callback_logstash]
    port = 5000
    

    added in 1.0.0 of community.general

  • Environment variable: LOGSTASH_PORT

pre_command

string

added in 2.0.0 of community.general

Executes command before run and its result is added to the ansible_pre_command_output logstash field.

Configuration:

  • INI entry:

    [callback_logstash]
    pre_command = None
    
  • Environment variable: LOGSTASH_PRE_COMMAND

server

string

Address of the Logstash server

Default: “localhost”

Configuration:

  • INI entry:

    [callback_logstash]
    server = localhost
    

    added in 1.0.0 of community.general

  • Environment variable: LOGSTASH_SERVER

type

string

Message type

Default: “ansible”

Configuration:

  • INI entry:

    [callback_logstash]
    type = ansible
    

    added in 1.0.0 of community.general

  • Environment variable: LOGSTASH_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)

Hint

Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up.