Skip to content

Commit

Permalink
[receiver/purefa] Add a new scraper type volumes (#16738)
Browse files Browse the repository at this point in the history
  • Loading branch information
dgoscn authored Dec 6, 2022
1 parent 1ad54c0 commit 1dd389f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 0 deletions.
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

0 comments on commit 1dd389f

Please sign in to comment.