pusher

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const VERSION = "0.3.6"

Variables

This section is empty.

Functions

func SaveAnyJSONLToElk

func SaveAnyJSONLToElk(file string, indexName string, project string)

func SaveAnyToElk

func SaveAnyToElk(file string, indexName string, project string)

func SaveInteractionToElk

func SaveInteractionToElk(file string, indexName string, project string, host string)

Types

type Config

type Config struct {
	ELKHost  string `yaml:"elk_host"`
	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 {
	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 {
	InputFile string
	Project   string
	Index     string
	Host      string
	Type      string
}

func FromConfig

func FromConfig(config elasticsearch.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

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