Documentation ¶
Overview ¶
Copyright (c) F5, Inc.
This source code is licensed under the Apache License, Version 2.0 license found in the LICENSE file in the root directory of this source tree.
Copyright (c) F5, Inc.
This source code is licensed under the Apache License, Version 2.0 license found in the LICENSE file in the root directory of this source tree.
Index ¶
- Constants
- Variables
- func DefaultAllowedDirectories() []string
- func DefaultFeatures() []string
- func Execute(ctx context.Context) error
- func Init(version, commit string)
- func RegisterConfigFile() error
- func RegisterRunner(r func(cmd *cobra.Command, args []string))
- func ToCommandProto(cmd *Command) *mpi.CommandServer
- type APIDetails
- type AccessLog
- type Action
- type Attribute
- type AuthConfig
- type Batch
- type CPUScraper
- type Client
- type Collector
- type Command
- type CommonSettings
- type Config
- type DataPlaneConfig
- type DebugExporter
- type DiskScraper
- type Exporters
- type Extensions
- type File
- type FileWatcher
- type FilesystemScraper
- type GRPC
- type Header
- type HeadersSetter
- type Health
- type HostMetrics
- type HostMetricsScrapers
- type InstanceHealthWatcher
- type InstanceWatcher
- type Log
- type MemoryScraper
- type NetworkScraper
- type NginxDataPlaneConfig
- type NginxPlusReceiver
- type NginxReceiver
- type Operator
- type OtlpExporter
- type OtlpReceiver
- type OtlpTLSConfig
- type Processors
- type PrometheusExporter
- type Receivers
- type Resource
- type ResourceAttribute
- type ServerConfig
- type ServerType
- type TLSConfig
- type TcplogReceiver
- type Watchers
Constants ¶
const ( ConfigFileName = "nginx-agent.conf" EnvPrefix = "NGINX_AGENT" KeyDelimiter = "_" )
const ( DefGracefulShutdownPeriod = 5 * time.Second DefNginxReloadMonitoringPeriod = 10 * time.Second DefTreatErrorsAsWarnings = false DefCommandServerHostKey = "" DefCommandServerPortKey = 0 DefCommandServerTypeKey = "grpc" DefCommandAuthTokenKey = "" DefCommandTLSCertKey = "" DefCommandTLSKeyKey = "" DefCommandTLSCaKey = "" DefCommandTLSSkipVerifyKey = false DefCommandTLServerNameKey = "" DefMaxMessageSize = 0 // 0 = unset DefMaxMessageRecieveSize = 4194304 // default 4 MB DefMaxMessageSendSize = math.MaxInt32 // Backoff defaults DefBackoffInitialInterval = 50 * time.Millisecond DefBackoffRandomizationFactor = 0.1 // the value is 0 <= and < 1 DefBackoffMultiplier = 1.5 DefBackoffMaxInterval = 200 * time.Millisecond DefBackoffMaxElapsedTime = 3 * time.Second // Watcher defaults DefInstanceWatcherMonitoringFrequency = 5 * time.Second DefInstanceHealthWatcherMonitoringFrequency = 5 * time.Second DefFileWatcherMonitoringFrequency = 5 * time.Second // Collector defaults DefCollectorConfigPath = "/etc/nginx-agent/opentelemetry-collector-agent.yaml" DefCollectorLogLevel = "INFO" DefCollectorLogPath = "/var/log/nginx-agent/opentelemetry-collector-agent.log" DefCollectorTLSCertPath = "/var/lib/nginx-agent/cert.pem" DefCollectorTLSKeyPath = "/var/lib/nginx-agent/key.pem" DefCollectorTLSCAPath = "/var/lib/nginx-agent/ca.pem" DefCollectorTLSSANNames = "127.0.0.1,::1,localhost" DefCollectorBatchProcessorSendBatchSize = 8192 DefCollectorBatchProcessorSendBatchMaxSize = 0 DefCollectorBatchProcessorTimeout = 200 * time.Millisecond DefCollectorExtensionsHealthServerHost = "localhost" DefCollectorExtensionsHealthServerPort = 13133 DefCollectorExtensionsHealthPath = "/" DefCollectorExtensionsHealthTLSCertPath = "" DefCollectorExtensionsHealthTLSKeyPath = "" DefCollectorExtensionsHealthTLSCAPath = "" DefCollectorExtensionsHealthTLSSkipVerify = false DefCollectorExtensionsHealthTLServerNameKey = "" )
const ( ClientRootKey = "client" AllowedDirectoriesKey = "allowed_directories" ConfigPathKey = "path" CommandRootKey = "command" DataPlaneConfigRootKey = "data_plane_config" LogLevelRootKey = "log" CollectorRootKey = "collector" VersionKey = "version" UUIDKey = "uuid" FeaturesKey = "features" InstanceWatcherMonitoringFrequencyKey = "watchers_instance_watcher_monitoring_frequency" InstanceHealthWatcherMonitoringFrequencyKey = "watchers_instance_health_watcher_monitoring_frequency" FileWatcherMonitoringFrequencyKey = "watchers_file_watcher_monitoring_frequency" )
Variables ¶
var ( // child flags saved as vars to enable easier prefixing. ClientPermitWithoutStreamKey = pre(ClientRootKey) + "permit_without_stream" ClientTimeKey = pre(ClientRootKey) + "time" ClientTimeoutKey = pre(ClientRootKey) + "timeout" ClientMaxMessageSendSizeKey = pre(ClientRootKey) + "max_message_send_size" ClientMaxMessageReceiveSizeKey = pre(ClientRootKey) + "max_message_receive_size" ClientMaxMessageSizeKey = pre(ClientRootKey) + "max_message_size" CollectorConfigPathKey = pre(CollectorRootKey) + "config_path" CollectorExportersKey = pre(CollectorRootKey) + "exporters" CollectorAttributeProcessorKey = pre(CollectorProcessorsKey) + "attribute" CollectorDebugExporterKey = pre(CollectorExportersKey) + "debug" CollectorPrometheusExporterKey = pre(CollectorExportersKey) + "prometheus_exporter" CollectorPrometheusExporterServerHostKey = pre(CollectorPrometheusExporterKey) + "server_host" CollectorPrometheusExporterServerPortKey = pre(CollectorPrometheusExporterKey) + "server_port" CollectorPrometheusExporterTLSKey = pre(CollectorPrometheusExporterKey) + "tls" CollectorPrometheusExporterTLSCertKey = pre(CollectorPrometheusExporterTLSKey) + "cert" CollectorPrometheusExporterTLSKeyKey = pre(CollectorPrometheusExporterTLSKey) + "key" CollectorPrometheusExporterTLSCaKey = pre(CollectorPrometheusExporterTLSKey) + "ca" CollectorPrometheusExporterTLSSkipVerifyKey = pre(CollectorPrometheusExporterTLSKey) + "skip_verify" CollectorPrometheusExporterTLSServerNameKey = pre(CollectorPrometheusExporterTLSKey) + "server_name" CollectorOtlpExportersKey = pre(CollectorExportersKey) + "otlp_exporters" CollectorProcessorsKey = pre(CollectorRootKey) + "processors" CollectorBatchProcessorKey = pre(CollectorProcessorsKey) + "batch" CollectorBatchProcessorSendBatchSizeKey = pre(CollectorBatchProcessorKey) + "send_batch_size" CollectorBatchProcessorSendBatchMaxSizeKey = pre(CollectorBatchProcessorKey) + "send_batch_max_size" CollectorBatchProcessorTimeoutKey = pre(CollectorBatchProcessorKey) + "timeout" CollectorExtensionsKey = pre(CollectorRootKey) + "extensions" CollectorExtensionsHealthKey = pre(CollectorExtensionsKey) + "health" CollectorExtensionsHealthServerHostKey = pre(CollectorExtensionsHealthKey) + "server_host" CollectorExtensionsHealthServerPortKey = pre(CollectorExtensionsHealthKey) + "server_port" CollectorExtensionsHealthPathKey = pre(CollectorExtensionsHealthKey) + "path" CollectorExtensionsHealthTLSKey = pre(CollectorExtensionsHealthKey) + "tls" CollectorExtensionsHealthTLSCaKey = pre(CollectorExtensionsHealthTLSKey) + "ca" CollectorExtensionsHealthTLSCertKey = pre(CollectorExtensionsHealthTLSKey) + "cert" CollectorExtensionsHealthTLSKeyKey = pre(CollectorExtensionsHealthTLSKey) + "key" CollectorExtensionsHealthTLSServerNameKey = pre(CollectorExtensionsHealthTLSKey) + "server_name" CollectorExtensionsHealthTLSSkipVerifyKey = pre(CollectorExtensionsHealthTLSKey) + "skip_verify" CollectorExtensionsHeadersSetterKey = pre(CollectorExtensionsKey) + "headers_setter" CollectorReceiversKey = pre(CollectorRootKey) + "receivers" CollectorLogKey = pre(CollectorRootKey) + "log" CollectorLogLevelKey = pre(CollectorLogKey) + "level" CollectorLogPathKey = pre(CollectorLogKey) + "path" CommandAuthKey = pre(CommandRootKey) + "auth" CommandAuthTokenKey = pre(CommandAuthKey) + "token" CommandServerHostKey = pre(CommandServerKey) + "host" CommandServerKey = pre(CommandRootKey) + "server" CommandServerPortKey = pre(CommandServerKey) + "port" CommandServerTypeKey = pre(CommandServerKey) + "type" CommandTLSKey = pre(CommandRootKey) + "tls" CommandTLSCaKey = pre(CommandTLSKey) + "ca" CommandTLSCertKey = pre(CommandTLSKey) + "cert" CommandTLSKeyKey = pre(CommandTLSKey) + "key" CommandTLSServerNameKey = pre(CommandTLSKey) + "server_name" CommandTLSSkipVerifyKey = pre(CommandTLSKey) + "skip_verify" LogLevelKey = pre(LogLevelRootKey) + "level" LogPathKey = pre(LogLevelRootKey) + "path" NginxReloadMonitoringPeriodKey = pre(DataPlaneConfigRootKey, "nginx") + "reload_monitoring_period" NginxTreatWarningsAsErrorsKey = pre(DataPlaneConfigRootKey, "nginx") + "treat_warnings_as_errors" NginxExcludeLogsKey = pre(DataPlaneConfigRootKey, "nginx") + "exclude_logs" )
var CompletionCommand = &cobra.Command{ Use: "completion [bash|zsh|fish]", Short: "Generate completion script.", Long: `To load completions: Bash: $ source <(nginx-agent completion bash) # To load completions for each session, execute once: Linux: $ nginx-agent completion bash > /etc/bash_completion.d/nginx-agent MacOS: $ nginx-agent completion bash > /usr/local/etc/bash_completion.d/nginx-agent Zsh: # If shell completion is not already enabled in your environment you will need # to enable it. You can execute the following once: $ echo "autoload -U compinit; compinit" >> ~/.zshrc # To load completions for each session, execute once: $ nginx-agent completion zsh > "${fpath[1]}/_nginx-agent" # You will need to start a new shell for this setup to take effect. Fish: $ nginx-agent completion fish | source # To load completions for each session, execute once: $ nginx-agent completion fish > ~/.config/fish/completions/nginx-agent.fish `, DisableFlagsInUseLine: true, ValidArgs: []string{"bash", "zsh", "fish"}, Args: cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs), Run: func(cmd *cobra.Command, args []string) { var err error switch args[0] { case "bash": err = cmd.Root().GenBashCompletion(os.Stdout) case "zsh": err = cmd.Root().GenZshCompletion(os.Stdout) case "fish": err = cmd.Root().GenFishCompletion(os.Stdout, true) } if err != nil { slog.Warn("Error sending command", "error", err) } }, }
var RootCommand = &cobra.Command{
Use: "nginx-agent [flags]",
Short: "nginx-agent",
}
Functions ¶
func DefaultAllowedDirectories ¶
func DefaultAllowedDirectories() []string
func DefaultFeatures ¶
func DefaultFeatures() []string
func RegisterConfigFile ¶
func RegisterConfigFile() error
func RegisterRunner ¶
func ToCommandProto ¶
func ToCommandProto(cmd *Command) *mpi.CommandServer
ToCommandProto maps the AgentConfig Command struct back to the Command proto message
Types ¶
type APIDetails ¶
type AuthConfig ¶
type AuthConfig struct {
Token string `yaml:"-" mapstructure:"token"`
}
type CPUScraper ¶
type CPUScraper struct{}
type Client ¶
type Client struct { Timeout time.Duration `yaml:"-" mapstructure:"timeout"` Time time.Duration `yaml:"-" mapstructure:"time"` PermitWithoutStream bool `yaml:"-" mapstructure:"permit_without_stream"` // if MaxMessageSize is size set then we use that value, // otherwise MaxMessageRecieveSize and MaxMessageSendSize for individual settings MaxMessageSize int `yaml:"-" mapstructure:"max_message_size"` MaxMessageRecieveSize int `yaml:"-" mapstructure:"max_message_receive_size"` MaxMessageSendSize int `yaml:"-" mapstructure:"max_message_send_size"` }
type Collector ¶
type Collector struct { ConfigPath string `yaml:"-" mapstructure:"config_path"` Log *Log `yaml:"-" mapstructure:"log"` Exporters Exporters `yaml:"-" mapstructure:"exporters"` Extensions Extensions `yaml:"-" mapstructure:"extensions"` Processors Processors `yaml:"-" mapstructure:"processors"` Receivers Receivers `yaml:"-" mapstructure:"receivers"` }
type Command ¶
type Command struct { Server *ServerConfig `yaml:"-" mapstructure:"server"` Auth *AuthConfig `yaml:"-" mapstructure:"auth"` TLS *TLSConfig `yaml:"-" mapstructure:"tls"` }
func FromCommandProto ¶
func FromCommandProto(config *mpi.CommandServer) *Command
FromCommandProto maps the AgentConfig Command struct to the Command proto message
type CommonSettings ¶
type CommonSettings struct { InitialInterval time.Duration `yaml:"-" mapstructure:"initial_interval"` MaxInterval time.Duration `yaml:"-" mapstructure:"max_interval"` MaxElapsedTime time.Duration `yaml:"-" mapstructure:"max_elapsed_time"` RandomizationFactor float64 `yaml:"-" mapstructure:"randomization_factor"` Multiplier float64 `yaml:"-" mapstructure:"multiplier"` }
type Config ¶
type Config struct { Command *Command `yaml:"-" mapstructure:"command"` Log *Log `yaml:"-" mapstructure:"log"` DataPlaneConfig *DataPlaneConfig `yaml:"-" mapstructure:"data_plane_config"` Client *Client `yaml:"-" mapstructure:"client"` Collector *Collector `yaml:"-" mapstructure:"collector"` File *File `yaml:"-" mapstructure:"file"` Common *CommonSettings `yaml:"-"` Watchers *Watchers `yaml:"-"` Version string `yaml:"-"` Path string `yaml:"-"` UUID string `yaml:"-"` AllowedDirectories []string `yaml:"-" mapstructure:"allowed_directories"` Features []string `yaml:"-"` }
func ResolveConfig ¶
func (*Config) AreReceiversConfigured ¶
func (*Config) IsACollectorExporterConfigured ¶
func (*Config) IsDirectoryAllowed ¶
func (*Config) IsFeatureEnabled ¶
type DataPlaneConfig ¶
type DataPlaneConfig struct {
Nginx *NginxDataPlaneConfig `yaml:"-" mapstructure:"nginx"`
}
type DebugExporter ¶
type DebugExporter struct{}
type DiskScraper ¶
type DiskScraper struct{}
type Exporters ¶
type Exporters struct { Debug *DebugExporter `yaml:"-" mapstructure:"debug"` PrometheusExporter *PrometheusExporter `yaml:"-" mapstructure:"prometheus_exporter"` OtlpExporters []OtlpExporter `yaml:"-" mapstructure:"otlp_exporters"` }
type Extensions ¶
type Extensions struct { Health *Health `yaml:"-" mapstructure:"health"` HeadersSetter *HeadersSetter `yaml:"-" mapstructure:"headers_setter"` }
type FileWatcher ¶
type FilesystemScraper ¶
type FilesystemScraper struct{}
type HeadersSetter ¶
type HeadersSetter struct {
Headers []Header `yaml:"-" mapstructure:"headers"`
}
type Health ¶
type Health struct { Server *ServerConfig `yaml:"-" mapstructure:"server"` TLS *TLSConfig `yaml:"-" mapstructure:"tls"` Path string `yaml:"-" mapstructure:"path"` }
type HostMetrics ¶
type HostMetrics struct { Scrapers *HostMetricsScrapers `yaml:"-" mapstructure:"scrapers"` CollectionInterval time.Duration `yaml:"-" mapstructure:"collection_interval"` InitialDelay time.Duration `yaml:"-" mapstructure:"initial_delay"` }
type HostMetricsScrapers ¶
type HostMetricsScrapers struct { CPU *CPUScraper `yaml:"-" mapstructure:"cpu"` Disk *DiskScraper `yaml:"-" mapstructure:"disk"` Filesystem *FilesystemScraper `yaml:"-" mapstructure:"filesystem"` Memory *MemoryScraper `yaml:"-" mapstructure:"memory"` Network *NetworkScraper `yaml:"-" mapstructure:"network"` }
type InstanceHealthWatcher ¶
type InstanceWatcher ¶
type MemoryScraper ¶
type MemoryScraper struct{}
type NetworkScraper ¶
type NetworkScraper struct{}
type NginxDataPlaneConfig ¶
type NginxPlusReceiver ¶
type NginxPlusReceiver struct { InstanceID string `yaml:"-" mapstructure:"instance_id"` PlusAPI APIDetails `yaml:"-" mapstructure:"api_details"` }
type NginxReceiver ¶
type NginxReceiver struct { InstanceID string `yaml:"-" mapstructure:"instance_id"` StubStatus APIDetails `yaml:"-" mapstructure:"api_details"` AccessLogs []AccessLog `yaml:"-" mapstructure:"access_logs"` }
func (*NginxReceiver) Validate ¶
func (nr *NginxReceiver) Validate(allowedDirectories []string) error
type Operator ¶
type Operator struct { Fields map[string]string `yaml:"-" mapstructure:"fields"` Type string `yaml:"-" mapstructure:"type"` }
There are many types of operators with different field names so we use a generic map to store the fields. See here for more info: https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/pkg/stanza/docs/operators/README.md
type OtlpExporter ¶
type OtlpExporter struct { Server *ServerConfig `yaml:"-" mapstructure:"server"` TLS *TLSConfig `yaml:"-" mapstructure:"tls"` Compression string `yaml:"-" mapstructure:"compression"` Authenticator string `yaml:"-" mapstructure:"authenticator"` }
type OtlpReceiver ¶
type OtlpReceiver struct { Server *ServerConfig `yaml:"-" mapstructure:"server"` Auth *AuthConfig `yaml:"-" mapstructure:"auth"` OtlpTLSConfig *OtlpTLSConfig `yaml:"-" mapstructure:"tls"` }
type OtlpTLSConfig ¶
type OtlpTLSConfig struct { Cert string `yaml:"-" mapstructure:"cert"` Key string `yaml:"-" mapstructure:"key"` Ca string `yaml:"-" mapstructure:"ca"` ServerName string `yaml:"-" mapstructure:"server_name"` ExistingCert bool `yaml:"-"` SkipVerify bool `yaml:"-" mapstructure:"skip_verify"` GenerateSelfSignedCert bool `yaml:"-" mapstructure:"generate_self_signed_cert"` }
Specialized TLS configuration for OtlpReceiver with self-signed cert generation.
type Processors ¶
type Processors struct { Attribute *Attribute `yaml:"-" mapstructure:"attribute"` Resource *Resource `yaml:"-" mapstructure:"resource"` Batch *Batch `yaml:"-" mapstructure:"batch"` }
OTel Collector Processors configuration.
type PrometheusExporter ¶
type PrometheusExporter struct { Server *ServerConfig `yaml:"-" mapstructure:"server"` TLS *TLSConfig `yaml:"-" mapstructure:"tls"` }
type Receivers ¶
type Receivers struct { HostMetrics *HostMetrics `yaml:"-" mapstructure:"host_metrics"` OtlpReceivers []OtlpReceiver `yaml:"-" mapstructure:"otlp_receivers"` NginxReceivers []NginxReceiver `yaml:"-" mapstructure:"nginx_receivers"` NginxPlusReceivers []NginxPlusReceiver `yaml:"-" mapstructure:"nginx_plus_receivers"` TcplogReceivers []TcplogReceiver `yaml:"-" mapstructure:"tcplog_receivers"` }
OTel Collector Receiver configuration.
type Resource ¶
type Resource struct {
Attributes []ResourceAttribute `yaml:"-" mapstructure:"attributes"`
}
type ResourceAttribute ¶
type ServerConfig ¶
type ServerConfig struct { Host string `yaml:"-" mapstructure:"host"` Port int `yaml:"-" mapstructure:"port"` Type ServerType `yaml:"-" mapstructure:"type"` }
type TcplogReceiver ¶
type Watchers ¶
type Watchers struct { InstanceWatcher InstanceWatcher `yaml:"-" mapstructure:"instance_watcher"` InstanceHealthWatcher InstanceHealthWatcher `yaml:"-" mapstructure:"instance_health_watcher"` FileWatcher FileWatcher `yaml:"-" mapstructure:"file_watcher"` }