gelf

package module
v0.0.0-...-ebe81b1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 8, 2022 License: MIT Imports: 14 Imported by: 0

README

Build status

Build Status

Logspout with GELF adapter and TCP+TLS support

A logspout docker image with TLS support.

This image contains Logspout which is compiled with [GELF adapter] and originally forked from https://github.com/karlvr/logspout-gelf so you can forward Docker logs in GELF to a Graylog server.

Docker hub images

Images are published in the following registry, ghcr.io/mictsi/logspout-gelf-tls/logspout-gelf-tls and https://hub.docker.com/r/kthse/logspout-gelf-tls.

Keep in mind that i am moving away from Docker Hub to Github Registry.

Usage

Modify the docker compose file to point to your graylogserver and run it with the docker-compose command.

Use gelf://my.log.server:12201 as protocol for gelf over udp and gelf+tls://my.log.server:12201 for gelf over TCP+TLS

CLI example for gelf over udp

docker run -d --name=logspout --restart=unless-stopped -h $(hostname -f) -v /var/run/docker.sock:/var/run/docker.sock ghcr.io/mictsi/logspout-gelf-tls/logspout-gelf-tls:latest gelf://my.log.server:12201

CLI example for gelf over TCP and with TLS encryption

docker run -d --name=logspout --restart=unless-stopped -h $(hostname -f) -v /var/run/docker.sock:/var/run/docker.sock ghcr.io/mictsi/logspout-gelf-tls/logspout-gelf-tls:latest gelf+tls://my.log.server:12201

Docker Compose example

You could use this image with the following docker-compose file for unencrypted gelf messages over udp:

version: '3'

services:
  logspout:
    image: ghcr.io/mictsi/logspout-gelf-tls/logspout-gelf-tls:latest
    hostname: my.message.source
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    command: gelf://my.log.server:12201
    restart: unless-stopped

or the following for sending gelf message over TLS+TCP:

version: '3'

services:
  logspout:
    image: ghcr.io/mictsi/logspout-gelf-tls/logspout-gelf-tls:latest
    hostname: my.message.source
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    command: gelf+tls://my.log.server:12201
    restart: unless-stopped

Disclaimer

This image is provided as-is and only with best effort. We try to update this image with the latest Logspout stable version.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewGelfAdapter

func NewGelfAdapter(route *router.Route) (router.LogAdapter, error)

NewGelfAdapter creates a GelfAdapter with UDP as the default transport.

Types

type GelfAdapter

type GelfAdapter struct {
	// contains filtered or unexported fields
}

GelfAdapter is an adapter that streams UDP JSON to Graylog

func (*GelfAdapter) Stream

func (a *GelfAdapter) Stream(logstream chan *router.Message)

Stream implements the router.LogAdapter interface.

type GelfMessage

type GelfMessage struct {
	Version      string  `json:"version"`
	Host         string  `json:"host,omitempty"`
	ShortMessage string  `json:"short_message"`
	FullMessage  string  `json:"full_message,omitempty"`
	Timestamp    float64 `json:"timestamp,omitempty"`
	Level        int32   `json:"level,omitempty"`

	ImageId       string `json:"_image_id,omitempty"`
	ImageName     string `json:"_image_name,omitempty"`
	ContainerId   string `json:"_container_id,omitempty"`
	ContainerName string `json:"_container_name,omitempty"`
	ContainerCmd  string `json:"_command,omitempty"`
	Created       string `json:"_created,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL