Skip to content
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

[receiver/purefa] Adds a new scraper type volumes #16738

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions receiver/purefareceiver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ receivers:
host: 13s
directories: 15s
pods: 30s
volumes: 25s
```

The full list of settings exposed for this receiver are documented [here](./config.go)
Expand Down
4 changes: 4 additions & 0 deletions receiver/purefareceiver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ type Config struct {

// Pods represents the list of pods to query
Pods []internal.ScraperConfig `mapstructure:"pods"`

// Volumes represents the list of volumes to query
Volumes []internal.ScraperConfig `mapstructure:"volumes"`
}

type Settings struct {
Expand All @@ -56,6 +59,7 @@ type ReloadIntervals struct {
Host time.Duration `mapstructure:"host"`
Directories time.Duration `mapstructure:"directories"`
Pods time.Duration `mapstructure:"pods"`
Volumes time.Duration `mapstructure:"volumes"`
}

func (c *Config) Validate() error {
Expand Down
1 change: 1 addition & 0 deletions receiver/purefareceiver/internal/scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const (
ScraperTypeHost ScraperType = "host"
ScraperTypeDirectories ScraperType = "directories"
ScraperTypePods ScraperType = "pods"
ScraperTypeVolumes ScraperType = "volumes"
)

type scraper struct {
Expand Down
7 changes: 7 additions & 0 deletions receiver/purefareceiver/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ func (r *purefaReceiver) Start(ctx context.Context, compHost component.Host) err
return err
}

volumesScraper := internal.NewScraper(ctx, internal.ScraperTypeVolumes, r.cfg.Endpoint, r.cfg.Volumes, r.cfg.Settings.ReloadIntervals.Volumes)
if scCfgs, err := volumesScraper.ToPrometheusReceiverConfig(compHost, fact); err == nil {
scrapeCfgs = append(scrapeCfgs, scCfgs...)
} else {
return err
}

promRecvCfg := fact.CreateDefaultConfig().(*prometheusreceiver.Config)
promRecvCfg.PrometheusConfig = &config.Config{ScrapeConfigs: scrapeCfgs}

Expand Down
1 change: 1 addition & 0 deletions receiver/purefareceiver/testdata/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ receivers:
host: 13s
directories: 15s
pods: 30s
volumes: 25s