scanner

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package scanner parses log files

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(
	cfg *server.Config, store store.Store, registry *prometheus.Registry, scheduler *gocron.Scheduler,
) server.Server

New returns a server that manages scanners.

Types

type CRDBv2AuthParser

type CRDBv2AuthParser struct{}

CRDBv2AuthParser is a parser for cockroach-sql-auth logs.

func (*CRDBv2AuthParser) Parse

func (c *CRDBv2AuthParser) Parse(line []byte, metric *Metric) error

Parse implements Parser.

type CRDBv2Parser

type CRDBv2Parser struct{}

CRDBv2Parser parses CockroachDB logs.

func (*CRDBv2Parser) Parse

func (c *CRDBv2Parser) Parse(line []byte, metric *Metric) error

Parse implements Parser.

type Config

type Config struct {
	Follow        bool
	FromBeginning bool
	Poll          bool
	Reopen        bool
}

Config defines the behavior of the scanner

type Metric

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

Metric defines the prometheus counter to increment when a line matches the regular expression.

func (*Metric) Match

func (m *Metric) Match(line []byte) bool

Match checks if the line satisfies the regex.

type Parser

type Parser interface {
	// Parse a single line and produce a metric if the line satisfy the metric filter.
	Parse([]byte, *Metric) error
}

Parser implements the custom logic to parse a specific log file type.

type Scanner

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

Scanner scans a log file to extract the given metrics.

func FromConfig

func FromConfig(
	scan *store.Scan, config *Config, registerer prometheus.Registerer,
) (*Scanner, error)

FromConfig creates a new scanner, based on the configuration provided.

func (*Scanner) GetLastModified

func (s *Scanner) GetLastModified() time.Time

GetLastModified returns the last time the scanner configuration was updated.

func (*Scanner) Start

func (s *Scanner) Start(ctx *stopper.Context) error

Start scanning the log

func (*Scanner) Stop

func (s *Scanner) Stop() error

Stop stops the scanning activity.

Jump to

Keyboard shortcuts

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