Skip to content

Commit

Permalink
feat: add scrape interval parameter to prometheus config
Browse files Browse the repository at this point in the history
  • Loading branch information
zmird-r authored May 4, 2023
1 parent 02daf4a commit 40de685
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions bundle/manifests/monitoring.rhobs_monitoringstacks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,10 @@ spec:
format: int32
minimum: 0
type: integer
scrapeInterval:
description: Default interval between scrapes.
pattern: ^(0|(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?)$
type: string
type: object
resourceSelector:
description: 'Label selector for Monitoring Stack Resources. To monitor
Expand Down
4 changes: 4 additions & 0 deletions deploy/crds/common/monitoring.rhobs_monitoringstacks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,10 @@ spec:
format: int32
minimum: 0
type: integer
scrapeInterval:
description: Default interval between scrapes.
pattern: ^(0|(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?)$
type: string
type: object
resourceSelector:
description: 'Label selector for Monitoring Stack Resources. To monitor
Expand Down
7 changes: 7 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,13 @@ Define prometheus config
<i>Minimum</i>: 0<br/>
</td>
<td>false</td>
</tr><tr>
<td><b>scrapeInterval</b></td>
<td>string</td>
<td>
Default interval between scrapes.<br/>
</td>
<td>false</td>
</tr></tbody>
</table>

Expand Down
3 changes: 3 additions & 0 deletions pkg/apis/monitoring/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ type PrometheusConfig struct {
// Enable Prometheus to be used as a receiver for the Prometheus remote write protocol. Defaults to the value of `false`.
// +optional
EnableRemoteWriteReceiver bool `json:"enableRemoteWriteReceiver,omitempty"`
// Default interval between scrapes.
// +optional
ScrapeInterval *monv1.Duration `json:"scrapeInterval,omitempty"`
}

type AlertmanagerConfig struct {
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/monitoring/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions pkg/controllers/monitoring/monitoring-stack/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ func newPrometheus(
}
}

if config.ScrapeInterval != nil {
prometheus.Spec.ScrapeInterval = *ms.Spec.PrometheusConfig.ScrapeInterval
}

return prometheus
}

Expand Down

0 comments on commit 40de685

Please sign in to comment.