promtailreceiver

package module
v0.71.1 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

README

Deprecated Promtail Receiver

Status
Stability deprecated
Supported pipeline types logs
Distributions contrib

This receiver runs promtail client to scrape logs

Unsupported features

The Promtail receiver is meant to minimally be a drop-in replacement for Promtail Client. However, there are advanced features of Promtail that we don't support and thus explicitly will return an error for if the receiver's configuration YAML/code contains any of the following

Getting Started

This receiver is a drop-in replacement for getting Promtail to scrape your services. It supports the full set of Promtail configuration in scrape_configs. Just like you would write in a YAML configuration file before starting Promtail, such as with:

Note: Since the collector configuration supports env variable substitution $ characters in your prometheus configuration are interpreted as environment variables. If you want to use $ characters in your promtail configuration, you must escape them using $$.

promtail --config.file=prom.yaml

You can copy and paste that same configuration under:

receivers:
  promtail:
    config:

For example:

receivers:
    promtail:
      config:
        positions:
          filename: /tmp/positions.yaml
        scrape_configs:
          - job_name: varlogs
            static_configs:
              - labels:
                job: varlogs
                __path__: /var/log/*.log
          - job_name: loki_push
            server:
              http_listen_port: 3101
              grpc_listen_port: 3600
            labels:
              pushserver: push1
              use_incoming_timestamp: true
        target_config:
          sync_period: 5s

Promtail Journal support

Promtail receiver can receive logs from journal on Linux and CentOS. By default, Journal support is disabled since it requires CGO enabled. To turn on Journal support you should enable CGO, pass build flag tag protail_journal_enabled and install systemd headers.

With Journal support on Ubuntu, run with the following commands:

sudo apt install -y libsystemd-dev
CGO_ENABLED=1 go build ./cmd/otelcontribcol --tags=promtail_journal_enabled

With Journal support on CentOS, run with the following commands:

sudo yum install -y systemd-devel
CGO_ENABLED=1 go build ./cmd/otelcontribcol --tags=promtail_journal_enabled

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFactory

func NewFactory() receiver.Factory

NewFactory creates a factory for promtail receiver

Types

type Config

type Config struct {
	helper.InputConfig `mapstructure:",squash" yaml:",inline"`
	// Promtail input config is declared as nested key to allow custom unmarshalling
	// confmap doesn't call custom unmarshal for the top structure
	// see the implementation of unmarshalerHookFunc in https://github.com/open-telemetry/opentelemetry-collector:
	// https://github.com/open-telemetry/opentelemetry-collector/blob/c157b128e9ff32ed06e2913e2afa83c9abbed9ba/confmap/confmap.go#L269
	Input PromtailInputConfig `mapstructure:"config,omitempty" yaml:"config,omitempty"`
}

func NewConfigWithID

func NewConfigWithID(operatorID string) *Config

NewConfigWithID creates a new input config with default values

func (Config) Build

func (c Config) Build(logger *zap.SugaredLogger) (operator.Operator, error)

Build will build a promtail input operator from the supplied configuration

type PromtailConfig

type PromtailConfig struct {
	InputConfig        Config `mapstructure:",squash" yaml:",inline"`
	adapter.BaseConfig `mapstructure:",squash" yaml:",inline"`
}

PromtailConfig defines configuration for the promtail receiver

type PromtailInputConfig

type PromtailInputConfig struct {
	PositionsConfig positions.Config      `mapstructure:"positions,omitempty" yaml:"positions,omitempty"`
	ScrapeConfig    []scrapeconfig.Config `mapstructure:"scrape_configs,omitempty" yaml:"scrape_configs,omitempty"`
	TargetConfig    file.Config           `mapstructure:"target_config,omitempty" yaml:"target_config,omitempty"`
}

func (*PromtailInputConfig) Unmarshal

func (c *PromtailInputConfig) Unmarshal(componentParser *confmap.Conf) error

Unmarshal a config.Parser into the config struct.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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