haproxy

package module
v0.0.0-...-942de43 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2020 License: MIT Imports: 8 Imported by: 2

README

haproxylog Build Status GoDoc

haproxylog is a go library that parses haproxy log messages.

Installation

Standard go get:

$ go get github.com/chrishoffman/haproxylog

Usage

package main

import (
	"fmt"

	"github.com/chrishoffman/haproxylog"
)

func main() {
	rawLog := `192.168.9.185:56276 [29/May/2015:10:36:47.766] Service1 Service1/host-1 2/0/0 423 -- 282/36/0/0/0 0/0`

	log, err := haproxy.NewLog(rawLog)
	if err != nil {
		panic(err)
	}

	fmt.Println("Frontend Name: ", log.FrontendName)
	fmt.Println("Backend Name: ", log.BackendName)
	fmt.Println("Stat Tt: ", log.Tt)
}

See GoDoc for complete documentation.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HttpRequest

type HttpRequest struct {
	Method  string
	URL     *url.URL
	Version string
}

type Log

type Log struct {

	// Common Fields
	ClientIP     string
	ClientPort   int64
	AcceptDate   time.Time
	FrontendName string

	// HTTP/TCP Fields
	BackendName      string
	ServerName       string
	Tw               int64
	Tc               int64
	Tt               int64
	BytesRead        int64
	TerminationState string
	ActConn          int64
	FeConn           int64
	BeConn           int64
	SrvConn          int64
	Retries          int64
	ServerQueue      int64
	BackendQueue     int64

	// HTTP Fields
	Tq                      int64
	Tr                      int64
	HTTPStatusCode          int64
	CapturedRequestCookie   string
	CapturedResponseCookie  string
	CapturedRequestHeaders  []string
	CapturedResponseHeaders []string
	HTTPRequest             *HttpRequest
	SslCipher               string
	SslVersion              string

	// Error Fields
	BindName string
	Message  string
	// contains filtered or unexported fields
}

Log contains all the available fields from the HAProxy logs. All fields from the HTTP, TCP, and Error log formats are available.

func NewLog

func NewLog(rawLog string) (*Log, error)

NewLog identifies the type and parses a raw HAProxy log line and returns a Log struct

func (*Log) GetFormat

func (l *Log) GetFormat() LogFormat

GetFormat returns the LogType for the log line

type LogFormat

type LogFormat int

LogFormat is an enumeration containing the available formats for HAProxy log messages

const (
	// HTTP log format
	HTTP LogFormat = iota
	// TCP log format
	TCP
	// Error log format
	Error
	// Unknown log format
	Unknown
)

Jump to

Keyboard shortcuts

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