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 Execute(ctx context.Context) error
- func Init(version, commit string)
- func RegisterConfigFile() error
- func RegisterRunner(r func(cmd *cobra.Command, args []string))
- type AuthConfig
- type Client
- type Collector
- type Command
- type CommonSettings
- type Config
- type DataPlaneConfig
- type Exporter
- type File
- type GRPC
- type InstanceHealthWatcher
- type InstanceWatcher
- type Log
- type NginxDataPlaneConfig
- type Processor
- type Receiver
- type ServerConfig
- type ServerType
- type TLSConfig
- type Watchers
Constants ¶
View Source
const ( ConfigFileName = "nginx-agent.conf" EnvPrefix = "NGINX_AGENT" KeyDelimiter = "_" )
View Source
const ( DefGracefulShutdownPeriod = 5 * time.Second DefNginxReloadMonitoringPeriod = 10 * time.Second DefTreatErrorsAsWarnings = true DefCollectorConfigPath = "/var/run/nginx-agent-otelcol.yaml" DefCommandServerHostKey = "" DefCommandServerPortKey = 0 DefCommandServerTypeKey = "grpc" DefCommandAuthTokenKey = "" DefCommandTLSCertKey = "" DefCommandTLSKeyKey = "" DefCommandTLSCaKey = "" DefCommandTLSSkipVerifyKey = false DefBackoffInitialInterval = 50 * time.Millisecond // the value is 0 <= and < 1 DefBackoffRandomizationFactor = 0.1 DefBackoffMultiplier = 1.5 DefBackoffMaxInterval = 200 * time.Millisecond DefBackoffMaxElapsedTime = 3 * time.Second DefInstanceWatcherMonitoringFrequency = 5 * time.Second DefInstanceHealthWatcherMonitoringFrequency = 5 * time.Second )
View Source
const ( ClientRootKey = "client" ConfigDirectoriesKey = "config_dirs" ConfigPathKey = "path" CommandRootKey = "command" DataPlaneConfigRootKey = "data_plane_config" LogLevelRootKey = "log" CollectorRootKey = "collector" VersionKey = "version" UUIDKey = "uuid" InstanceWatcherMonitoringFrequencyKey = "watchers_instance_watcher_monitoring_frequency" InstanceHealthWatcherMonitoringFrequencyKey = "watchers_instance_health_watcher_monitoring_frequency" )
Variables ¶
View Source
var ( // child flags saved as vars to enable easier prefixing. ClientPermitWithoutStreamKey = pre(ClientRootKey) + "permit_without_stream" ClientTimeKey = pre(ClientRootKey) + "time" ClientTimeoutKey = pre(ClientRootKey) + "timeout" CollectorConfigPathKey = pre(CollectorRootKey) + "config_path" CollectorExportersKey = pre(CollectorRootKey) + "exporters" CollectorProcessorsKey = pre(CollectorRootKey) + "processors" CollectorHealthKey = pre(CollectorRootKey) + "health" CollectorReceiversKey = pre(CollectorRootKey) + "receivers" CommandAuthKey = pre(CommandRootKey) + "auth" CommandAuthTokenKey = pre(CommandAuthKey) + "token" CommandServerHostKey = pre(CommandServerKey) + "host" CommandServerKey = pre(CommandRootKey) + "server" CommandServerPortKey = pre(CommandServerKey) + "port" CommandServerTypeKey = pre(CommandServerKey) + "type" CommandTLSCaKey = pre(CommandTLSKey) + "ca" CommandTLSCertKey = pre(CommandTLSKey) + "cert" CommandTLSKey = pre(CommandRootKey) + "tls" CommandTLSKeyKey = pre(CommandTLSKey) + "key" CommandTLSServerNameKey = pre(CommandRootKey) + "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_error" OTLPExportURLKey = pre(CollectorRootKey) + "otlp_export_url" OTLPReceiverURLKey = pre(CollectorRootKey) + "otlp_receiver_url" )
View Source
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) } }, }
View Source
var RootCommand = &cobra.Command{
Use: "nginx-agent [flags]",
Short: "nginx-agent",
}
Functions ¶
func RegisterConfigFile ¶
func RegisterConfigFile() error
func RegisterRunner ¶
Types ¶
type AuthConfig ¶
type AuthConfig struct {
Token string `yaml:"-" mapstructure:"token"`
}
type Collector ¶
type Collector struct { ConfigPath string `yaml:"-" mapstructure:"config_path"` Exporters []Exporter `yaml:"-" mapstructure:"exporters"` Health *ServerConfig `yaml:"-" mapstructure:"health"` Processors []Processor `yaml:"-" mapstructure:"processors"` Receivers []Receiver `yaml:"-" mapstructure:"receivers"` }
type Command ¶
type Command struct { Server *ServerConfig `yaml:"-" mapstructure:"server"` Auth *AuthConfig `yaml:"-" mapstructure:"auth"` TLS *TLSConfig `yaml:"-" mapstructure:"tls"` }
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 { UUID string `yaml:"-"` Version string `yaml:"-"` Path string `yaml:"-"` Log *Log `yaml:"-" mapstructure:"log"` DataPlaneConfig *DataPlaneConfig `yaml:"-" mapstructure:"data_plane_config"` Client *Client `yaml:"-" mapstructure:"client"` ConfigDir string `yaml:"-" mapstructure:"config-dirs"` AllowedDirectories []string `yaml:"-"` Collector *Collector `yaml:"-" mapstructure:"collector"` Command *Command `yaml:"-" mapstructure:"command"` File *File `yaml:"-" mapstructure:"file"` Common *CommonSettings `yaml:"-"` Watchers *Watchers `yaml:"-"` }
func ResolveConfig ¶
func (*Config) IsDirectoryAllowed ¶
type DataPlaneConfig ¶
type DataPlaneConfig struct {
Nginx *NginxDataPlaneConfig `yaml:"-" mapstructure:"nginx"`
}
type Exporter ¶
type Exporter struct { Type string `yaml:"-" mapstructure:"type"` Server *ServerConfig `yaml:"-" mapstructure:"server"` Auth *AuthConfig `yaml:"-" mapstructure:"auth"` TLS *TLSConfig `yaml:"-" mapstructure:"tls"` }
OTel Collector Exporter configuration.
type InstanceHealthWatcher ¶
type InstanceWatcher ¶
type NginxDataPlaneConfig ¶
type Processor ¶
type Processor struct {
Type string `yaml:"-" mapstructure:"type"`
}
OTel Collector Processor configuration.
type Receiver ¶
type Receiver struct { Type string `yaml:"-" mapstructure:"type"` Server *ServerConfig `yaml:"-" mapstructure:"server"` Auth *AuthConfig `yaml:"-" mapstructure:"auth"` TLS *TLSConfig `yaml:"-" mapstructure:"tls"` }
OTel Collector Receiver configuration.
type ServerConfig ¶
type ServerConfig struct { Host string `yaml:"-" mapstructure:"host"` Port int `yaml:"-" mapstructure:"port"` Type ServerType `yaml:"-" mapstructure:"type"` }
type Watchers ¶
type Watchers struct { InstanceWatcher InstanceWatcher `yaml:"-" mapstructure:"instance_watcher"` InstanceHealthWatcher InstanceHealthWatcher `yaml:"-" mapstructure:"instance_health_watcher"` }
Click to show internal directories.
Click to hide internal directories.