Documentation ¶
Index ¶
- Constants
- Variables
- func CheckAndSetDefault(attribute interface{}, defaultValue interface{})
- func ConfigFilePaths() []string
- func Execute() error
- func LoadPropertiesFromFile(cfg string) error
- func RegisterConfigFile(dynamicConfFilePath string, confFileName string, confPaths ...string) (string, error)
- func RegisterFlags()
- func RegisterRunner(r func(cmd *cobra.Command, args []string))
- func SeekConfigFileInPaths(configName string, searchPaths ...string) (string, error)
- func SetDefaults()
- func SetDynamicConfigFileAbsPath(dynamicCfgPath string)
- func SetVersion(version, commit string)
- func UpdateAgentConfig(systemId string, updateTags []string, updateFeatures []string) (bool, error)
- type AgentAPI
- type AgentMetrics
- type BoolFlag
- type Config
- type Dataplane
- type DurationFlag
- type IntFlag
- type LogConfig
- type Nginx
- type Registrable
- type Server
- type Status
- type StringFlag
- type StringMapFlag
- type StringSliceFlag
- type TLSConfig
Constants ¶
View Source
const ( DynamicConfigFileName = "agent-dynamic.conf" DynamicConfigFileAbsPath = "/etc/nginx-agent/agent-dynamic.conf" ConfigFileName = "nginx-agent.conf" ConfigFileType = "yaml" EnvPrefix = "nms" ConfigPathKey = "path" DynamicConfigPathKey = "dynamic-config-path" CloudAccountIdKey = "cloudaccountid" LocationKey = "location" DisplayNameKey = "display_name" InstanceGroupKey = "instance_group" ConfigDirsKey = "config_dirs" TagsKey = "tags" // viper keys used in config LogKey = "log" LogLevel = LogKey + agent_config.KeyDelimiter + "level" LogPath = LogKey + agent_config.KeyDelimiter + "path" // viper keys used in config ServerKey = "server" ServerHost = ServerKey + agent_config.KeyDelimiter + "host" ServerGrpcPort = ServerKey + agent_config.KeyDelimiter + "grpcport" ServerToken = ServerKey + agent_config.KeyDelimiter + "token" ServerMetrics = ServerKey + agent_config.KeyDelimiter + "metrics" ServerCommand = ServerKey + agent_config.KeyDelimiter + "command" // viper keys used in config APIKey = "api" AgentAPIPort = APIKey + agent_config.KeyDelimiter + "port" AgentAPICert = APIKey + agent_config.KeyDelimiter + "cert" AgentAPIKey = APIKey + agent_config.KeyDelimiter + "key" // viper keys used in config TlsKey = "tls" TlsEnable = TlsKey + agent_config.KeyDelimiter + "enable" TlsCert = TlsKey + agent_config.KeyDelimiter + "cert" TlsPrivateKey = TlsKey + agent_config.KeyDelimiter + "key" TlsCa = TlsKey + agent_config.KeyDelimiter + "ca" TlsSkipVerify = TlsKey + agent_config.KeyDelimiter + "skip_verify" // viper keys used in config NginxKey = "nginx" NginxExcludeLogs = NginxKey + agent_config.KeyDelimiter + "exclude_logs" NginxDebug = NginxKey + agent_config.KeyDelimiter + "debug" NginxCountingSocket = NginxKey + agent_config.KeyDelimiter + "socket" NginxClientVersion = NginxKey + agent_config.KeyDelimiter + "client_version" // viper keys used in config DataplaneKey = "dataplane" DataplaneEventsEnable = DataplaneKey + agent_config.KeyDelimiter + "events_enable" DataplaneSyncEnable = DataplaneKey + agent_config.KeyDelimiter + "sync_enable" DataplaneStatusPoll = DataplaneKey + agent_config.KeyDelimiter + "status_poll_interval" DataplaneStatusReportInterval = DataplaneKey + agent_config.KeyDelimiter + "report_interval" // viper keys used in config MetricsKey = "metrics" MetricsBulkSize = MetricsKey + agent_config.KeyDelimiter + "bulk_size" MetricsReportInterval = MetricsKey + agent_config.KeyDelimiter + "report_interval" MetricsCollectionInterval = MetricsKey + agent_config.KeyDelimiter + "collection_interval" MetricsMode = MetricsKey + agent_config.KeyDelimiter + "mode" // DEPRECATED KEYS AdvancedMetricsKey = "advanced_metrics" AdvancedMetricsSocketPath = AdvancedMetricsKey + agent_config.KeyDelimiter + "socket_path" AdvancedMetricsAggregationPeriod = AdvancedMetricsKey + agent_config.KeyDelimiter + "aggregation_period" AdvancedMetricsPublishPeriod = AdvancedMetricsKey + agent_config.KeyDelimiter + "publishing_period" AdvancedMetricsTableSizesLimits = AdvancedMetricsKey + agent_config.KeyDelimiter + "table_sizes_limits" AdvancedMetricsTableSizesLimitsSTMS = AdvancedMetricsTableSizesLimits + agent_config.KeyDelimiter + "staging_table_max_size" AdvancedMetricsTableSizesLimitsSTT = AdvancedMetricsTableSizesLimits + agent_config.KeyDelimiter + "staging_table_threshold" AdvancedMetricsTableSizesLimitsPTMS = AdvancedMetricsTableSizesLimits + agent_config.KeyDelimiter + "priority_table_max_size" AdvancedMetricsTableSizesLimitsPTT = AdvancedMetricsTableSizesLimits + agent_config.KeyDelimiter + "priority_table_threshold" NginxAppProtectKey = "nginx_app_protect" NginxAppProtectReportInterval = NginxAppProtectKey + agent_config.KeyDelimiter + "report_interval" NginxAppProtectPrecompiledPublication = NginxAppProtectKey + agent_config.KeyDelimiter + "precompiled_publication" NAPMonitoringKey = "nap_monitoring" NAPMonitoringCollectorBufferSize = NAPMonitoringKey + agent_config.KeyDelimiter + "collector_buffer_size" NAPMonitoringProcessorBufferSize = NAPMonitoringKey + agent_config.KeyDelimiter + "processor_buffer_size" NAPMonitoringSyslogIP = NAPMonitoringKey + agent_config.KeyDelimiter + "syslog_ip" NAPMonitoringSyslogPort = NAPMonitoringKey + agent_config.KeyDelimiter + "syslog_port" NAPMonitoringReportInterval = NAPMonitoringKey + agent_config.KeyDelimiter + "report_interval" NAPMonitoringReportCount = NAPMonitoringKey + agent_config.KeyDelimiter + "report_count" )
Variables ¶
View Source
var ( Defaults = &Config{ CloudAccountID: uuid.New().String(), Log: LogConfig{ Level: "info", Path: "/var/log/nginx-agent", }, Server: Server{ Command: "", Metrics: "", Token: uuid.New().String(), }, Nginx: Nginx{ Debug: false, NginxCountingSocket: "unix:/var/run/nginx-agent/nginx.sock", NginxClientVersion: 6, }, ConfigDirs: "/etc/nginx:/usr/local/etc/nginx:/usr/share/nginx/modules:/etc/nms", AllowedDirectoriesMap: map[string]struct{}{}, TLS: TLSConfig{ Enable: false, SkipVerify: false, }, Dataplane: Dataplane{ Status: Status{ PollInterval: 30 * time.Second, ReportInterval: 24 * time.Hour, }, }, AgentMetrics: AgentMetrics{ BulkSize: 20, ReportInterval: 1 * time.Minute, CollectionInterval: 15 * time.Second, Mode: "aggregation", }, Features: agent_config.GetDefaultFeatures(), } AllowedDirectoriesMap map[string]struct{} )
View Source
var COMPLETION_COMMAND = &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.ExactValidArgs(1), 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 { log.Warnf("Error sending command: %v", err) } }, }
View Source
var ROOT_COMMAND = &cobra.Command{
Use: "nginx-agent [flags]",
Short: "nginx-agent",
}
View Source
var (
Viper = viper.NewWithOptions(viper.KeyDelimiter(agent_config.KeyDelimiter))
)
Functions ¶
func CheckAndSetDefault ¶
func CheckAndSetDefault(attribute interface{}, defaultValue interface{})
func ConfigFilePaths ¶
func ConfigFilePaths() []string
func LoadPropertiesFromFile ¶
func RegisterConfigFile ¶
func RegisterFlags ¶
func RegisterFlags()
func RegisterRunner ¶
func SeekConfigFileInPaths ¶
func SetDefaults ¶
func SetDefaults()
func SetDynamicConfigFileAbsPath ¶
func SetDynamicConfigFileAbsPath(dynamicCfgPath string)
func SetVersion ¶
func SetVersion(version, commit string)
func UpdateAgentConfig ¶
UpdateAgentConfig updates the Agent config on disk with the tags and features that are passed into it. A bool is returned indicating if the Agent config was overwritten or not.
Types ¶
type AgentMetrics ¶
type AgentMetrics struct { BulkSize int `mapstructure:"bulk_size" yaml:"-"` ReportInterval time.Duration `mapstructure:"report_interval" yaml:"-"` CollectionInterval time.Duration `mapstructure:"collection_interval" yaml:"-"` Mode string `mapstructure:"mode" yaml:"-"` }
AgentMetrics for system/agent metrics
type Config ¶
type Config struct { Path string `yaml:"-"` DynamicConfigPath string `yaml:"-"` ClientID string `mapstructure:"agent_id" yaml:"-"` CloudAccountID string `mapstructure:"cloud_account" yaml:"-"` Server Server `mapstructure:"server" yaml:"-"` AgentAPI AgentAPI `mapstructure:"api" yaml:"-"` ConfigDirs string `mapstructure:"config-dirs" yaml:"-"` Log LogConfig `mapstructure:"log" yaml:"-"` TLS TLSConfig `mapstructure:"tls" yaml:"-"` Nginx Nginx `mapstructure:"nginx" yaml:"-"` Dataplane Dataplane `mapstructure:"dataplane" yaml:"-"` AgentMetrics AgentMetrics `mapstructure:"metrics" yaml:"-"` Tags []string `mapstructure:"tags" yaml:"tags,omitempty"` Features []string `mapstructure:"features" yaml:"features,omitempty"` Extensions []string `mapstructure:"extensions" yaml:"extensions,omitempty"` Updated time.Time `yaml:"-"` // update time of the config file AllowedDirectoriesMap map[string]struct{} `yaml:"-"` DisplayName string `mapstructure:"display_name" yaml:"display_name,omitempty"` InstanceGroup string `mapstructure:"instance_group" yaml:"instance_group,omitempty"` }
func (*Config) IsExtensionEnabled ¶ added in v2.24.0
func (*Config) IsFeatureEnabled ¶ added in v2.21.0
func (*Config) IsGrpcServerConfigured ¶ added in v2.21.0
type DurationFlag ¶
type LogConfig ¶
type LogConfig struct { Level string `mapstructure:"level" yaml:"-"` Path string `mapstructure:"path" yaml:"-"` }
LogConfig for logging
type Nginx ¶
type Nginx struct { ExcludeLogs string `mapstructure:"exclude_logs" yaml:"-"` Debug bool `mapstructure:"debug" yaml:"-"` NginxCountingSocket string `mapstructure:"socket" yaml:"-"` NginxClientVersion int `mapstructure:"client_version" yaml:"-"` }
Nginx settings
type Registrable ¶
type Registrable interface {
// contains filtered or unexported methods
}
Registrable registers a pflag
type Server ¶
type Server struct { Host string `mapstructure:"host" yaml:"-"` GrpcPort int `mapstructure:"grpcPort" yaml:"-"` Token string `mapstructure:"token" yaml:"-"` Metrics string `mapstructure:"metrics" yaml:"-"` Command string `mapstructure:"command" yaml:"-"` // This is internal and shouldnt be exposed as a flag Target string `mapstructure:"target" yaml:"-"` }
type Status ¶
type Status struct { PollInterval time.Duration `mapstructure:"poll_interval" yaml:"-"` ReportInterval time.Duration `mapstructure:"report_interval" yaml:"-"` }
Status polling for heartbeat settings
type StringFlag ¶
type StringMapFlag ¶
type StringSliceFlag ¶
type TLSConfig ¶
type TLSConfig struct { Enable bool `mapstructure:"enable" yaml:"-"` Cert string `mapstructure:"cert" yaml:"-"` Key string `mapstructure:"key" yaml:"-"` Ca string `mapstructure:"ca" yaml:"-"` SkipVerify bool `mapstructure:"skip_verify" yaml:"-"` }
TLSConfig for securing communications
Click to show internal directories.
Click to hide internal directories.