All Projects → looplab → Logspout Logstash

looplab / Logspout Logstash

Licence: apache-2.0
A minimalistic adapter for github.com/gliderlabs/logspout to write to Logstash

Programming Languages

go
31211 projects - #10 most used programming language

Labels

Projects that are alternatives of or similar to Logspout Logstash

elk-stack
ELK Stack (Elasticsearch, Logstash & Kibana)
Stars: ✭ 13 (-95.39%)
Mutual labels:  logstash
k8s-log
容器日志搜集套件。
Stars: ✭ 15 (-94.68%)
Mutual labels:  logstash
python-logstash-async
Python logging handler for sending log events asynchronously to Logstash.
Stars: ✭ 141 (-50%)
Mutual labels:  logstash
WAZUH-OSSEC
WAZUH - The Open Source Security Platform Installation
Stars: ✭ 79 (-71.99%)
Mutual labels:  logstash
logstash
Configurations of my logstash: logstash, filebeat, grok patterns: sshd, postfix, apache, sysdig, zimbra mailbox.log, zimbra zimbra.log, Datadog Dogstatsd, fail2ban
Stars: ✭ 89 (-68.44%)
Mutual labels:  logstash
kafkabeat
Kafka event forwarder build on top of Elastic Beats platform
Stars: ✭ 13 (-95.39%)
Mutual labels:  logstash
seahorse
ELKFH - Elastic, Logstash, Kibana, Filebeat and Honeypot (HTTP, HTTPS, SSH, RDP, VNC, Redis, MySQL, MONGO, SMB, LDAP)
Stars: ✭ 31 (-89.01%)
Mutual labels:  logstash
Helk
The Hunting ELK
Stars: ✭ 3,097 (+998.23%)
Mutual labels:  logstash
tsharkVM
tshark + ELK analytics virtual machine
Stars: ✭ 51 (-81.91%)
Mutual labels:  logstash
elastic-training-repo
A collection of datasets, docker-compose files, notes, and other stuff related to the Elastic stack.
Stars: ✭ 56 (-80.14%)
Mutual labels:  logstash
microservice-elk
Creating microservice using Spring Boot, Eureka, Zuul, Sleuth, Zipkin and ELK Stack
Stars: ✭ 19 (-93.26%)
Mutual labels:  logstash
logiq
Monitoring Web UI for Elastic Logstash
Stars: ✭ 34 (-87.94%)
Mutual labels:  logstash
docker-elk
ELK Stack on Docker
Stars: ✭ 43 (-84.75%)
Mutual labels:  logstash
TIL
Today I Learned
Stars: ✭ 43 (-84.75%)
Mutual labels:  logstash
StructuredLogging
A little demo of NLog logging to ELK using structured (JSON) log messages
Stars: ✭ 18 (-93.62%)
Mutual labels:  logstash
xelogstash
Send SQL Server Extended Events to Logstash, Elastic Search, or JSON
Stars: ✭ 22 (-92.2%)
Mutual labels:  logstash
jlogstash-input-plugin
java 版本 logstash input 插件
Stars: ✭ 20 (-92.91%)
Mutual labels:  logstash
Aliware Kafka Demos
提供各种客户端接入阿里云 消息队列 Kafka 的demo工程
Stars: ✭ 279 (-1.06%)
Mutual labels:  logstash
synesis lite syslog
Syslog collection with the Elastic Stack.
Stars: ✭ 31 (-89.01%)
Mutual labels:  logstash
logstash-plugin
Jenkins plugin to ship the console log off to Logstash
Stars: ✭ 61 (-78.37%)
Mutual labels:  logstash

GoDoc Go Report Card

logspout-logstash

A minimalistic adapter for github.com/gliderlabs/logspout to write to Logstash

Follow the instructions in https://github.com/gliderlabs/logspout/tree/master/custom on how to build your own Logspout container with custom modules. Basically just copy the contents of the custom folder and include:

package main

import (
  _ "github.com/looplab/logspout-logstash"
  _ "github.com/gliderlabs/logspout/transports/udp"
  _ "github.com/gliderlabs/logspout/transports/tcp"
)

in modules.go.

Use by setting a docker environment variable ROUTE_URIS=logstash://host:port to the Logstash server. The default protocol is UDP, but it is possible to change to TCP by adding +tcp after the logstash protocol when starting your container.

docker run --name="logspout" \
    --volume=/var/run/docker.sock:/var/run/docker.sock \
    -e ROUTE_URIS=logstash+tcp://logstash.home.local:5000 \
    localhost/logspout-logstash:v3.1

In your logstash config, set the input codec to json e.g:

input {
  udp {
    port  => 5000
    codec => json
  }
  tcp {
    port  => 5000
    codec => json
  }
}

Available configuration options

For example, to get into the Logstash event's @tags field, use the LOGSTASH_TAGS container environment variable. Multiple tags can be passed by using comma-separated values

  # Add any number of arbitrary tags to your event
  -e LOGSTASH_TAGS="docker,production"

The output into logstash should be like:

    "tags": [
      "docker",
      "production"
    ],

You can also add arbitrary logstash fields to the event using the LOGSTASH_FIELDS container environment variable:

  # Add any number of arbitrary fields to your event
  -e LOGSTASH_FIELDS="myfield=something,anotherfield=something_else"

The output into logstash should be like:

    "myfield": "something",
    "another_field": "something_else",

Both configuration options can be set for every individual container, or for the logspout-logstash container itself where they then become a default for all containers if not overridden there.

By setting the environment variable DOCKER_LABELS to a non-empty value, logspout-logstash will add all docker container labels as fields:

    "docker": {
        "hostname": "866e2ca94f5f",
        "id": "866e2ca94f5fe11d57add5a78232c53dfb6187f04f6e150ec15f0ae1e1737731",
        "image": "centos:7",
        "labels": {
            "a_label": "yes",
            "build-date": "20161214",
            "license": "GPLv2",
            "name": "CentOS Base Image",
            "pleasework": "okay",
            "some_label_with_dots": "more.dots",
            "vendor": "CentOS"
        },
        "name": "/ecstatic_murdock"

To be compatible with Elasticsearch, dots in labels will be replaced with underscores.

By setting INCLUDE_CONTAINERS you can specify a comma separated list of container names to only get logs from those containers. You can also set INCLUDE_CONTAINERS_REGEX to use regex to describe the containers to include.

Using Logspout-Logstash in a swarm

In a swarm, logspout is best deployed as a global service. To support this mode of deployment, the logstash adapter will look for the file /etc/host_hostname and, if the file exists and it is not empty, will configure the hostname field with the content of this file. You can then use a volume mount to map a file on the docker hosts with the file /etc/host_hostname in the container. The sample compose file below illustrates how this can be done:

version: "3"
services:
  logspout:
    image: localhost/logspout-logstash:latest
    volumes:
      # Logspout reads this in and attaches it to the log
      - /etc/hostname:/etc/host_hostname:ro
      - /var/run/docker.sock:/var/run/docker.sock
    environment:
      # IP and port for logstash host
      - ROUTE_URIS=logstash://host:port
      # Include all docker labels
      - DOCKER_LABELS=true
      # Add environment field to all logs sent to logstash
      - LOGSTASH_FIELDS=environment=${NODE_ENV}
    deploy:
      mode: global
      resources:
        limits:
          cpus: '0.20'
          memory: 256M
        reservations:
          cpus: '0.10'
          memory: 128M

Retrying

Two environment variables control the behaviour of Logspout when the Logstash target isn't available: RETRY_STARTUP causes Logspout to retry forever if Logstash isn't available at startup, and RETRY_SEND will retry sending log lines when Logstash becomes unavailable while Logspout is running. Note that RETRY_SEND will work only if UDP is used for the log transport and the destination doesn't change; in any other case RETRY_SEND should be disabled, restart and reconnect instead and let RETRY_STARTUP deal with the situation. With both retry options, log lines will be lost when Logstash isn't available. Set the environment variables to any nonempty value to enable retrying. The default is disabled.

This table shows all available configurations:

Environment Variable Input Type Default Value
LOGSTASH_TAGS array None
LOGSTASH_FIELDS map None
INCLUDE_CONTAINERS array None
DOCKER_LABELS any ""
RETRY_STARTUP any ""
RETRY_SEND any ""
DECODE_JSON_LOGS bool true
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].