pusher

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2025 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const VERSION = "0.4.1"

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Host         string `yaml:"host"`
	ELKHost      string `yaml:"elk_host"`
	RequiresAuth bool   `yaml:"requiresAuth,omitempty"`
	Username     string `yaml:"username,omitempty"`
	Password     string `yaml:"password,omitempty"`
	APIKey       string `yaml:"apikey,omitempty"`
}

type Hook

type Hook struct {
	Pusher    *Pusher
	Formatter logrus.Formatter
	LogLevel  logrus.Level
}

Hook is a hook that writes logs of specified LogLevels to specified Writer

func (*Hook) Fire added in v0.3.1

func (hook *Hook) Fire(entry *logrus.Entry) error

Fire will be called when some logging function is called with current hook It will format log entry to string and write it to appropriate writer

func (*Hook) Levels added in v0.3.1

func (hook *Hook) Levels() []logrus.Level

Levels define on which log levels this hook would trigger

type Interaction

type Interaction struct {
	Timestamp             time.Time `json:"timestamp"`
	ProjectName           string    `json:"project"`
	HostName              string    `json:"host"`
	URL                   string    `json:"url"`
	Raw                   string    `json:"raw,omitempty"`
	ResponseHTTPVersion   string    `json:"responseHTTPVersion,omitempty"`
	ResponseStatusCode    string    `json:"responseStatusCode,omitempty"`
	ResponseStatusMessage string    `json:"responseStatusMessage,omitempty"`
	RequestHeader         string    `json:"requestHeader"`
	RequestBody           string    `json:"requestBody,omitempty"`
	ResponseHeader        string    `json:"responseHeader"`
	ResponseBody          string    `json:"responseBody"`
}

type LogEntry added in v0.3.2

type LogEntry struct {
	Timestamp   time.Time `json:"timestamp"`
	ProjectName string    `json:"project"`
	HostName    string    `json:"host"`
	Entry       string    `json:"entry"`
	Level       string    `json:"level"`
}

type Logger added in v0.3.6

type Logger struct{ *logrus.Logger }

func NewLogger

func NewLogger() *Logger

type Options

type Options struct {
	Consumer   string
	ConfigFile string
	InputFile  string
	Project    string
	Index      string
	Host       string
	Type       string
	Silent     bool
	Version    bool
	NoColor    bool
	Verbose    bool
}

func ParseOptions

func ParseOptions() *Options

ParseOptions parses the command line flags provided by a user

type Pusher

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

func FromConfig

func FromConfig(consumer string, config Config, index string, host string) (*Pusher, error)

func FromOptions

func FromOptions(options *Options) (*Pusher, error)

func (*Pusher) PushFile

func (p *Pusher) PushFile() error

func (*Pusher) PushLog added in v0.3.2

func (p *Pusher) PushLog(json string, level string) error

func (*Pusher) SaveAnyJSONLToELK added in v0.4.0

func (p *Pusher) SaveAnyJSONLToELK()

func (*Pusher) SaveAnyJSONLToGraylog added in v0.4.0

func (p *Pusher) SaveAnyJSONLToGraylog()

func (*Pusher) SaveAnyToElk added in v0.4.0

func (p *Pusher) SaveAnyToElk()

func (*Pusher) SaveAnyToGraylog added in v0.4.0

func (p *Pusher) SaveAnyToGraylog()

func (*Pusher) SaveInteractionToElk added in v0.4.0

func (p *Pusher) SaveInteractionToElk()

type Store

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

Store allows to index and search documents.

func NewStore

func NewStore(c StoreConfig) (*Store, error)

NewStore returns a new instance of the store.

func (*Store) CreateBulkFromData

func (s *Store) CreateBulkFromData(payload []byte) error

CreateBulkFromData takes a byte array and creates a BulkRequest from it and stores it at the defined index.

func (*Store) CreateFromData

func (s *Store) CreateFromData(payload []byte) error

CreateFromData takes a byte array and creates an IndexRequest from it and stores it at the defined index.

func (*Store) CreateFromObject

func (s *Store) CreateFromObject(item any) error

Create indexes a new document into store.

func (*Store) CreateIndex

func (s *Store) CreateIndex(mapping string) error

CreateIndex creates a new index with mapping.

type StoreConfig

type StoreConfig struct {
	Client      *elasticsearch.Client
	IndexName   string
	ProjectName string
}

StoreConfig configures the store.

Jump to

Keyboard shortcuts

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