diff --git a/api/operator/v1beta1/vmscrapeconfig_types.go b/api/operator/v1beta1/vmscrapeconfig_types.go index 3a4c0433..6aef9523 100644 --- a/api/operator/v1beta1/vmscrapeconfig_types.go +++ b/api/operator/v1beta1/vmscrapeconfig_types.go @@ -82,6 +82,9 @@ type VMScrapeConfigSpec struct { // ScrapeTimeout is the number of seconds to wait until a scrape request times out. // +optional ScrapeTimeout string `json:"scrapeTimeout,omitempty"` + // MaxScrapeSize defines a maximum size of scraped data for a job + // +optional + MaxScrapeSize string `json:"max_scrape_size,omitempty"` // HonorTimestamps controls whether to respect the timestamps present in scraped data. // +optional HonorTimestamps *bool `json:"honorTimestamps,omitempty"` diff --git a/config/crd/overlay/crd.yaml b/config/crd/overlay/crd.yaml index c9d4af30..ca34cd17 100644 --- a/config/crd/overlay/crd.yaml +++ b/config/crd/overlay/crd.yaml @@ -22548,6 +22548,10 @@ spec: - role type: object type: array + max_scrape_size: + description: MaxScrapeSize defines a maximum size of scraped data + for a job + type: string metricRelabelConfigs: description: MetricRelabelConfigs to apply to samples after scrapping. items: diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index a184979a..22b70025 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -53,6 +53,8 @@ aliases: - [operator](./README.md): fix VM CRs' `xxNamespaceSelector` and `xxSelector` options, previously they are inverted. See this [issue](https://github.com/VictoriaMetrics/operator/issues/980) for details. - [vmnodescrape](./api.md#vmnodescrape): remove duplicated `series_limit` and `sample_limit` fields in generated scrape_config. See [this issue](https://github.com/VictoriaMetrics/operator/issues/986). +- [vmscrapeconfig](./api.md#vmscrapeconfig) - added `max_scrape_size` parameter for scrape protocols configuration + ## [v0.45.0](https://github.com/VictoriaMetrics/operator/releases/tag/v0.45.0) - 10 Jun 2024 diff --git a/internal/controller/operator/factory/vmagent/scrapeconfig.go b/internal/controller/operator/factory/vmagent/scrapeconfig.go index 59c76833..4a422e09 100644 --- a/internal/controller/operator/factory/vmagent/scrapeconfig.go +++ b/internal/controller/operator/factory/vmagent/scrapeconfig.go @@ -83,6 +83,9 @@ func generateScrapeConfig( if sc.Spec.SeriesLimit > 0 { cfg = append(cfg, yaml.MapItem{Key: "series_limit", Value: sc.Spec.SeriesLimit}) } + if sc.Spec.MaxScrapeSize != "" { + cfg = append(cfg, yaml.MapItem{Key: "max_scrape_size", Value: sc.Spec.MaxScrapeSize}) + } var relabelings []yaml.MapSlice for _, c := range sc.Spec.RelabelConfigs { diff --git a/internal/controller/operator/factory/vmagent/scrapeconfig_test.go b/internal/controller/operator/factory/vmagent/scrapeconfig_test.go index 7480d7f5..0dec2ae6 100644 --- a/internal/controller/operator/factory/vmagent/scrapeconfig_test.go +++ b/internal/controller/operator/factory/vmagent/scrapeconfig_test.go @@ -40,6 +40,7 @@ func TestGenerateScrapeConfig(t *testing.T) { Namespace: "default", }, Spec: vmv1beta1.VMScrapeConfigSpec{ + MaxScrapeSize: "60KB", ScrapeInterval: "10s", StaticConfigs: []vmv1beta1.StaticConfig{ { @@ -68,6 +69,7 @@ scrape_interval: 30s basic_auth: username: admin password: dangerous +max_scrape_size: 60KB relabel_configs: [] static_configs: - targets: