blackbox

package module
v0.0.0-...-5962cd0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2018 License: Apache-2.0 Imports: 12 Imported by: 0

README

blackbox

forward files on to syslog

Black Box Flight Recorder

About

Applications often provide only a limited ability to log to syslog and often don't log in a consistent format. I also think that syslog is an operational concern and the application should not know about where it is logging. Blackbox is an experiment to decouple syslogging from an application without messing about with syslog configuration (which is tricky on BOSH VMs).

Blackbox will tail all files in sub-directories of a specified source_dir, and forward any new lines to a syslog server.

Usage

blackbox -config config.yml

The configuration file schema is as follows:

hostname: this-host

syslog:
  destination:
    transport: udp
    address: logs.example.com:1234

  source_dir: /path/to/log-dir

Consider the case where log-dir has the following structure:

/path/to/log-dir
|-- app1
|   |-- stdout.log
|   `-- stderr.log
`-- app2
    |-- foo.log
    `-- bar.log

Any new lines written to app1/stdout.log and app1/stderr.log get sent to syslog tagged as app1, while new lines written to app2/foo.log and app2/bar.log get sent to syslog tagged as app2.

Currently the priority and facility are hardcoded to INFO and user.

Installation

go get -u github.com/concourse/blackbox/cmd/blackbox

Documentation

Index

Constants

View Source
const POLL_INTERVAL = 5 * time.Second

Variables

This section is empty.

Functions

func NewFileWatcher

func NewFileWatcher(
	logger *log.Logger,
	sourceDir string,
	dynamicGroupClient grouper.DynamicClient,
	drainerFactory syslog.DrainerFactory,
) *fileWatcher

Types

type Config

type Config struct {
	Hostname string `yaml:"hostname"`

	Syslog SyslogConfig `yaml:"syslog"`
}

func LoadConfig

func LoadConfig(path string) (*Config, error)

type Duration

type Duration time.Duration

func (*Duration) UnmarshalYAML

func (d *Duration) UnmarshalYAML(unmarshal func(interface{}) error) error

type SyslogConfig

type SyslogConfig struct {
	Destination syslog.Drain `yaml:"destination"`
	SourceDir   string       `yaml:"source_dir"`
}

type Tailer

type Tailer struct {
	Path    string
	Tag     string
	Drainer syslog.Drainer
}

func (*Tailer) Run

func (tailer *Tailer) Run(signals <-chan os.Signal, ready chan<- struct{}) error

Directories

Path Synopsis
cmd
syslogfakes
This file was generated by counterfeiter
This file was generated by counterfeiter

Jump to

Keyboard shortcuts

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