elblog

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2023 License: MIT Imports: 8 Imported by: 0

README

elblog GoDoc

Build Status codecov

Library helps to parse ALB logs (but does not parse the classic version: ELB)

Elastic Load Balancing provides access logs that capture detailed information about requests sent to your load balancer. Each log contains information such as the time the request was received, the client's IP address, latencies, request paths, and server responses. You can use these access logs to analyze traffic patterns and to troubleshoot issues.

Example

package main

import (
	"os"
	"fmt"

	"github.com/piotrkowalczuk/elblog"
)

func main() {
    file, err := os.Open("data.log")
    if err != nil {
        fmt.Println(err.Error())
        os.Exit(1)
    }
    dec := elblog.NewDecoder(file)

    if dec.More() {
        log, err := dec.Decode()
        if err != nil {
            fmt.Println(err.Error())
            os.Exit(1)
        }
        fmt.Println(log)
    }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Decoder

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

Decoder ...

func NewDecoder

func NewDecoder(r io.Reader) *Decoder

NewDecoder allocates new Decoder object for given input.

func (*Decoder) Decode

func (d *Decoder) Decode() (*Log, error)

Decode scans input and parse into Log. It can return EOF if underlying scanner Scan method returns false.

func (*Decoder) More

func (d *Decoder) More() bool

More return true if token is not empty or underlying scanner Scan method will return true.

type Log

type Log struct {
	Type                   string
	Time                   time.Time
	Name                   string
	From, To               *net.TCPAddr
	RequestProcessingTime  time.Duration
	BackendProcessingTime  time.Duration
	ResponseProcessingTime time.Duration
	ELBStatusCode          int
	BackendStatusCode      string
	ReceivedBytes          int64
	SentBytes              int64
	Request                string
	UserAgent              string
	SSLCipher              string
	SSLProtocol            string
	TargetGroupARN         string
	TraceID                string
	DomainName             string
	ChosenCertARN          string
	MatchedRulePriority    string
	RequestCreationTime    string
	ActionsExecuted        string
	RedirectURL            string
	ErrorReason            string
	TargetPortList         string
	TargetStatusCodeList   string
	Classification         string
	ClassificationReason   string
	OtherFields            string
}

Log ...

func Parse

func Parse(b []byte) (log *Log, err error)

Parse ...

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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