Skip to content
This repository has been archived by the owner on Jul 19, 2023. It is now read-only.

Commit

Permalink
Fixes the scrape timeout validation.
Browse files Browse the repository at this point in the history
  • Loading branch information
cyriltovena committed Jan 2, 2023
1 parent 5784584 commit 2fd3dea
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions pkg/agent/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@ func (c *ScrapeConfig) Validate() error {
if c.JobName == "" {
return fmt.Errorf("job_name is empty")
}
if c.ScrapeTimeout > c.ScrapeInterval {
return fmt.Errorf("scrape timeout must be larger or equal to inverval for: %v", c.JobName)
}
if c.ScrapeTimeout == 0 {
c.ScrapeTimeout = c.ScrapeInterval
c.ScrapeTimeout = c.ScrapeInterval + model.Duration(3*time.Second)
}
if c.ScrapeTimeout <= c.ScrapeInterval {
return fmt.Errorf("scrape timeout must be larger or equal to inverval for: %v", c.JobName)
}

if cfg, ok := c.ProfilingConfig.PprofConfig[pprofProcessCPU]; ok {
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/profiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ func (tg *TargetGroup) targetsFromGroup(group *targetgroup.Group) ([]*Target, []
}

if pcfg, found := tg.config.ProfilingConfig.PprofConfig[profType]; found && pcfg.Delta {
params.Add("seconds", strconv.Itoa(int(time.Duration(tg.config.ScrapeTimeout)/time.Second)-1))
params.Add("seconds", strconv.Itoa(int(time.Duration(tg.config.ScrapeInterval)/time.Second)))
}
targets = append(targets, &Target{
Target: scrape.NewTarget(lbls, origLabels, params),
Expand Down

0 comments on commit 2fd3dea

Please sign in to comment.