filebeat

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigPath = "/etc/filebeat/filebeat.yml"
)

Variables

This section is empty.

Functions

func GetCurrentConfig

func GetCurrentConfig(logger *logger.Logger) (*client.RequestFilebeat, error)

GetCurrentConfig reads the current filebeat configuration

func GetServiceStatus

func GetServiceStatus(ctx context.Context, logger *logger.Logger, runner *cmdrunner.CommandsRunner) (*client.ServiceStatus, error)

GetServiceStatus returns the current filebeat service status using systemd package

func RenderConfig added in v1.6.1

func RenderConfig(config *client.RequestFilebeat) ([]byte, error)

RenderConfig builds the filebeat.yml content from the request. It is the single source of truth for the rendered file, shared by UpdateConfig and the reconcile loop (which compares it against the live file to detect drift), so the two can never diverge.

func RestartService

func RestartService(ctx context.Context, logger *logger.Logger, runner *cmdrunner.CommandsRunner) error

RestartService restarts the filebeat service

func ServiceControl

func ServiceControl(ctx context.Context, serviceName string, action client.SubCommandType, logger *logger.Logger, runner *cmdrunner.CommandsRunner) (*client.ServiceStatus, error)

ServiceControl performs service control operations (start/stop/restart/status)

func UpdateConfig

func UpdateConfig(ctx context.Context, config *client.RequestFilebeat, logger *logger.Logger, runner *cmdrunner.CommandsRunner) error

UpdateConfig renders the filebeat config, writes it atomically (validated), and restarts the service.

Types

type ElasticsearchOutputConfig

type ElasticsearchOutputConfig struct {
	Hosts               []string `yaml:"hosts"`
	Index               string   `yaml:"index,omitempty"` // Index pattern (e.g., "elchi-%{+yyyy.MM.dd}")
	Loadbalance         bool     `yaml:"loadbalance,omitempty"`
	SSLVerificationMode string   `yaml:"ssl.verification_mode,omitempty"` // "none" to skip SSL verify
	APIKey              string   `yaml:"api_key,omitempty"`
	Username            string   `yaml:"username,omitempty"`
	Password            string   `yaml:"password,omitempty"`
}

ElasticsearchOutputConfig represents elasticsearch output configuration

type FilebeatConfig

type FilebeatConfig struct {
	FilebeatInputs      []FilebeatInputConfig      `yaml:"filebeat.inputs"`
	Processors          []any                      `yaml:"processors"`
	OutputLogstash      *LogstashOutputConfig      `yaml:"output.logstash,omitempty"`
	OutputElasticsearch *ElasticsearchOutputConfig `yaml:"output.elasticsearch,omitempty"`
	SetupILM            *SetupILMConfig            `yaml:"setup.ilm,omitempty"`
	SetupTemplate       *SetupTemplateConfig       `yaml:"setup.template,omitempty"`
}

FilebeatConfig represents the full filebeat.yml structure

type FilebeatInputConfig

type FilebeatInputConfig struct {
	Type    string   `yaml:"type"`
	Enabled bool     `yaml:"enabled"`
	ID      string   `yaml:"id"`
	Paths   []string `yaml:"paths"`
}

FilebeatInputConfig represents a single filebeat input

type LogstashOutputConfig

type LogstashOutputConfig struct {
	Hosts       []string `yaml:"hosts"`
	Loadbalance bool     `yaml:"loadbalance"`
}

LogstashOutputConfig represents logstash output configuration

type SetupILMConfig

type SetupILMConfig struct {
	Enabled bool `yaml:"enabled"`
}

SetupILMConfig represents ILM (Index Lifecycle Management) configuration

type SetupTemplateConfig

type SetupTemplateConfig struct {
	Name    string `yaml:"name"`
	Pattern string `yaml:"pattern"`
}

SetupTemplateConfig represents index template configuration

Jump to

Keyboard shortcuts

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