Path: blob/main/component/loki/source/internal/kafkatarget/config.go
4096 views
package kafkatarget12import (3"github.com/Shopify/sarama"4"github.com/grafana/agent/component/common/loki"5"github.com/grafana/dskit/flagext"6promconfig "github.com/prometheus/common/config"7"github.com/prometheus/common/model"8"github.com/prometheus/prometheus/model/relabel"9)1011// Config describes a job to scrape.12type Config struct {13KafkaConfig TargetConfig `mapstructure:"kafka,omitempty" yaml:"kafka,omitempty"`14RelabelConfigs []*relabel.Config `mapstructure:"relabel_configs,omitempty" yaml:"relabel_configs,omitempty"`15// List of Docker service discovery configurations.16}1718type TargetConfig struct {19// Labels optionally holds labels to associate with each log line.20Labels model.LabelSet `yaml:"labels"`2122// UseIncomingTimestamp sets the timestamp to the incoming kafka messages23// timestamp if it's set.24UseIncomingTimestamp bool `yaml:"use_incoming_timestamp"`2526// The list of brokers to connect to kafka (Required).27Brokers []string `yaml:"brokers"`2829// The consumer group id (Required).30GroupID string `yaml:"group_id"`3132// Kafka Topics to consume (Required).33Topics []string `yaml:"topics"`3435// Kafka version. Default to 2.2.136Version string `yaml:"version"`3738// Rebalancing strategy to use. (e.g. sticky, roundrobin or range)39Assignor string `yaml:"assignor"`4041// Authentication strategy with Kafka brokers42Authentication Authentication `yaml:"authentication"`4344MessageParser MessageParser45}4647// AuthenticationType specifies method to authenticate with Kafka brokers48type AuthenticationType string4950const (51// AuthenticationTypeNone represents using no authentication52AuthenticationTypeNone = "none"53// AuthenticationTypeSSL represents using SSL/TLS to authenticate54AuthenticationTypeSSL = "ssl"55// AuthenticationTypeSASL represents using SASL to authenticate56AuthenticationTypeSASL = "sasl"57)5859// Authentication describe the configuration for authentication with Kafka brokers60type Authentication struct {61// Type is authentication type62// Possible values: none, sasl and ssl (defaults to none).63Type AuthenticationType `yaml:"type"`6465// TLSConfig is used for TLS encryption and authentication with Kafka brokers66TLSConfig promconfig.TLSConfig `yaml:"tls_config,omitempty"`6768// SASLConfig is used for SASL authentication with Kafka brokers69SASLConfig SASLConfig `yaml:"sasl_config,omitempty"`70}7172// TokenProviderType specifies the provider used for resolving the access token73type TokenProviderType string7475const (76// TokenProviderTypeAzure represents using the Azure as the token provider77TokenProviderTypeAzure TokenProviderType = "azure"78)7980// KafkaSASLConfig describe the SASL configuration for authentication with Kafka brokers81type SASLConfig struct {82// SASL mechanism. Supports PLAIN, SCRAM-SHA-256 and SCRAM-SHA-51283Mechanism sarama.SASLMechanism `yaml:"mechanism"`8485// SASL Username86User string `yaml:"user"`8788// SASL Password for the User89Password flagext.Secret `yaml:"password"`9091// UseTLS sets whether TLS is used with SASL92UseTLS bool `yaml:"use_tls"`9394// TLSConfig is used for SASL over TLS. It is used only when UseTLS is true95TLSConfig promconfig.TLSConfig `yaml:",inline"`9697// OAuthConfig is used for configuring the token provider98OAuthConfig OAuthConfig `yaml:"oauth_provider_config,omitempty"`99}100101type OAuthConfig struct {102// TokenProvider is used for resolving the OAuth access token103TokenProvider TokenProviderType `yaml:"token_provider,omitempty"`104105Scopes []string106}107108// MessageParser defines parsing for each incoming message109type MessageParser interface {110Parse(message *sarama.ConsumerMessage, labels model.LabelSet, relabels []*relabel.Config, useIncomingTimestamp bool) ([]loki.Entry, error)111}112113114