Skip to content

enable default collector #1044

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 22, 2025
Merged

enable default collector #1044

merged 5 commits into from
Apr 22, 2025

Conversation

aphralG
Copy link
Contributor

@aphralG aphralG commented Apr 15, 2025

Proposed changes

If valid command server block is configured in the nginx-agent.conf but no processors are found in the collector block, a collector will be created using defaults.

  • The host and auth from the command server will be used in the collector (More detail on Defaults Below)
  • If command server is missing any settings (auth, tls etc) the default collector is not created
  • Removed collector from pre-install and upgrade-agent-config script

Default Collector Settings

  • Receiver - Host Metric enabled
    • CPU, Disk, Network, Filesystem, Memory Scrapers Enabled
    • Collection Interval set to 1 min
    • InitialDelay set to 1 second
  • Exporters - OtlpExporters enbaled
    • Server set to Command Server configuration
    • TLS set to Command TLS configuration
    • Authenticator set to "headers_setter",
  • Extensions - HeadersSetter enabled
    • Action set to "insert"
    • Key set to "authorization"
    • Value set to Command Auth Token

Checklist

Before creating a PR, run through this checklist and mark each as complete.

  • I have read the CONTRIBUTING document
  • I have run make install-tools and have attached any dependency changes to this pull request
  • If applicable, I have added tests that prove my fix is effective or that my feature works
  • If applicable, I have checked that any relevant tests pass after adding my changes
  • If applicable, I have updated any relevant documentation (README.md)
  • If applicable, I have tested my cross-platform changes on Ubuntu 22, Redhat 8, SUSE 15 and FreeBSD 13

@aphralG aphralG self-assigned this Apr 15, 2025
@aphralG aphralG requested a review from a team as a code owner April 15, 2025 15:59
@github-actions github-actions bot added the chore Pull requests for routine tasks label Apr 15, 2025
@oCHRISo oCHRISo added the v3.x Issues and Pull Requests related to the major version v3 label Apr 17, 2025
@@ -123,6 +128,60 @@ func ResolveConfig() (*Config, error) {
return config, nil
}

func checkCollectorConfiguration(collector *Collector, config *Config) {
if len(collector.Exporters.OtlpExporters) == 0 && collector.Exporters.PrometheusExporter == nil &&
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add some functions here to make it clearer what the if statement is doing? Like IsOTelExporterConfigured()

"os"
)

func RetrieveTokenFromFile(path string) (string, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func RetrieveTokenFromFile(path string) (string, error) {
func ReadFile(path string) (string, error) {

Can the name for this function be more generic? It could be reused in the future to read other things from files.


func RetrieveTokenFromFile(path string) (string, error) {
if path == "" {
return "", errors.New("token file path is empty")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return "", errors.New("token file path is empty")
return "", errors.New("failed to read file since file path is empty")

@aphralG aphralG merged commit 015eb68 into v3 Apr 22, 2025
20 checks passed
@aphralG aphralG deleted the enable-collector-default branch April 22, 2025 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Pull requests for routine tasks v3.x Issues and Pull Requests related to the major version v3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants