blackbox

package module
v0.0.0-...-456f51a Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

README

blackbox

If you have any questions, or want to get attention for a PR or issue please reach out on the #logging-and-metrics channel in the cloudfoundry slack

About

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

This is currently used in syslog-release and windows-syslog-release.

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
  log_filename: false

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.

If log_filename is set to true then the filename is included in the tag. For example, new lines written to app1/stdout.log get sent to syslog tagged as app1/stdout.log.

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

Installation

go get -u code.cloudfoundry.org/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,
	logFilename bool,
	dynamicGroupClient grouper.DynamicClient,
	drain syslog.Drain,
	hostname string,
	maxMessageSize int,
	structuredData rfc5424.StructuredData,
	excludeFilePattern string,
) *fileWatcher

Types

type Config

type Config struct {
	Hostname          string            `yaml:"hostname"`
	StructuredDataID  string            `yaml:"structured_data_id"`
	StructuredDataMap map[string]string `yaml:"structured_data_map"`
	Syslog            SyslogConfig      `yaml:"syslog"`
	UseRFC3339        bool              `yaml:"use_rfc3339"`
	MaxMessageSize    int               `yaml:"max_message_size"`
}

func LoadConfig

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

type SyslogConfig

type SyslogConfig struct {
	Destination        syslog.Drain `yaml:"destination"`
	SourceDir          string       `yaml:"source_dir"`
	ExcludeFilePattern string       `yaml:"exclude_file_pattern"`
	LogFilename        bool         `yaml:"log_filename"`
}

type Tailer

type Tailer struct {
	Path    string
	Tag     string
	Drainer syslog.Drainer
	Logger  *log.Logger
}

func (*Tailer) Run

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

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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