diff --git a/api/operator/v1beta1/common_scrapeparams.go b/api/operator/v1beta1/common_scrapeparams.go index 630014f5..13d61a85 100644 --- a/api/operator/v1beta1/common_scrapeparams.go +++ b/api/operator/v1beta1/common_scrapeparams.go @@ -250,6 +250,9 @@ type EndpointScrapeParams struct { // Timeout after which the scrape is ended // +optional ScrapeTimeout string `json:"scrapeTimeout,omitempty"` + // ScrapeProtocols defines Prometheus scrape protocol. + // +optional + ScrapeProtocols []string `json:"scrape_protocols,omitempty"` // ProxyURL eg http://proxyserver:2195 Directs scrapes to proxy through this endpoint. // +optional ProxyURL *string `json:"proxyURL,omitempty"` diff --git a/api/operator/v1beta1/vmagent_types.go b/api/operator/v1beta1/vmagent_types.go index d229b1c8..1501524f 100644 --- a/api/operator/v1beta1/vmagent_types.go +++ b/api/operator/v1beta1/vmagent_types.go @@ -174,6 +174,9 @@ type VMAgentSpec struct { // +optional // +kubebuilder:validation:Pattern:="[0-9]+(ms|s|m|h)" ScrapeTimeout string `json:"scrapeTimeout,omitempty"` + // ScrapeProtocols defines Prometheus scrape protocol. + // +optional + ScrapeProtocols []string `json:"scrape_protocols,omitempty"` // APIServerConfig allows specifying a host and auth methods to access apiserver. // If left empty, VMAgent is assumed to run inside of the cluster diff --git a/api/operator/v1beta1/zz_generated.deepcopy.go b/api/operator/v1beta1/zz_generated.deepcopy.go index defa8671..7b4d255a 100644 --- a/api/operator/v1beta1/zz_generated.deepcopy.go +++ b/api/operator/v1beta1/zz_generated.deepcopy.go @@ -1023,6 +1023,11 @@ func (in *EndpointScrapeParams) DeepCopyInto(out *EndpointScrapeParams) { *out = new(bool) **out = **in } + if in.ScrapeProtocols != nil { + in, out := &in.ScrapeProtocols, &out.ScrapeProtocols + *out = make([]string, len(*in)) + copy(*out, *in) + } if in.ProxyURL != nil { in, out := &in.ProxyURL, &out.ProxyURL *out = new(string) @@ -3599,6 +3604,11 @@ func (in *VMAgentSpec) DeepCopyInto(out *VMAgentSpec) { (*in)[i].DeepCopyInto(&(*out)[i]) } } + if in.ScrapeProtocols != nil { + in, out := &in.ScrapeProtocols, &out.ScrapeProtocols + *out = make([]string, len(*in)) + copy(*out, *in) + } if in.APIServerConfig != nil { in, out := &in.APIServerConfig, &out.APIServerConfig *out = new(APIServerConfig) diff --git a/config/crd/overlay/crd.yaml b/config/crd/overlay/crd.yaml index dcac0476..3882ca12 100644 --- a/config/crd/overlay/crd.yaml +++ b/config/crd/overlay/crd.yaml @@ -3799,6 +3799,11 @@ spec: schedulerName: description: SchedulerName - defines kubernetes scheduler name type: string + scrape_protocols: + description: ScrapeProtocols defines Prometheus scrape protocol. + items: + type: string + type: array scrapeConfigNamespaceSelector: description: |- ScrapeConfigNamespaceSelector defines Namespaces to be selected for VMScrapeConfig discovery. @@ -19212,6 +19217,11 @@ spec: ScrapeInterval is the same as Interval and has priority over it. one of scrape_interval or interval can be used type: string + scrape_protocols: + description: ScrapeProtocols defines Prometheus scrape protocol. + items: + type: string + type: array scrapeTimeout: description: Timeout after which the scrape is ended type: string @@ -20298,6 +20308,11 @@ spec: ScrapeInterval is the same as Interval and has priority over it. one of scrape_interval or interval can be used type: string + scrape_protocols: + description: ScrapeProtocols defines Prometheus scrape protocol. + items: + type: string + type: array scrapeTimeout: description: Timeout after which the scrape is ended type: string @@ -21290,6 +21305,11 @@ spec: ScrapeInterval is the same as Interval and has priority over it. one of scrape_interval or interval can be used type: string + scrape_protocols: + description: ScrapeProtocols defines Prometheus scrape protocol. + items: + type: string + type: array scrapeTimeout: description: Timeout after which the scrape is ended type: string @@ -25932,6 +25952,11 @@ spec: ScrapeInterval is the same as Interval and has priority over it. one of scrape_interval or interval can be used type: string + scrape_protocols: + description: ScrapeProtocols defines Prometheus scrape protocol. + items: + type: string + type: array scrapeTimeout: description: Timeout after which the scrape is ended type: string @@ -26976,6 +27001,11 @@ spec: ScrapeInterval is the same as Interval and has priority over it. one of scrape_interval or interval can be used type: string + scrape_protocols: + description: ScrapeProtocols defines Prometheus scrape protocol. + items: + type: string + type: array scrapeTimeout: description: Timeout after which the scrape is ended type: string @@ -29774,6 +29804,11 @@ spec: ScrapeInterval is the same as Interval and has priority over it. one of scrape_interval or interval can be used type: string + scrape_protocols: + description: ScrapeProtocols defines Prometheus scrape protocol. + items: + type: string + type: array scrapeTimeout: description: Timeout after which the scrape is ended type: string diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index e1e40b29..a06e193f 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -75,6 +75,8 @@ aliases: - [vmscrapeconfig](https://docs.victoriametrics.com/operator/api#vmscrapeconfig) - added `max_scrape_size` parameter for scrape protocols configuration +- [vmservicescrape](./api.md#vmservicescrape), [vmpodscrape](./api.md#vmpodscrape), [vmnodescrape](./api.md#vmnodescrape) - added `scrape_protocols` parameter for scrape protocols configuration + ## [v0.45.0](https://github.com/VictoriaMetrics/operator/releases/tag/v0.45.0) - 10 Jun 2024 diff --git a/docs/api.md b/docs/api.md index cc24a5e5..73af47bd 100644 --- a/docs/api.md +++ b/docs/api.md @@ -719,6 +719,7 @@ _Appears in:_ | `scheme` | HTTP scheme to use for scraping. | _string_ | false | | `scrapeTimeout` | Timeout after which the scrape is ended | _string_ | false | | `scrape_interval` | ScrapeInterval is the same as Interval and has priority over it.
one of scrape_interval or interval can be used | _string_ | false | +| `scrape_protocols` | ScrapeProtocols defines Prometheus scrape protocol. | _string array_ | false | | `seriesLimit` | SeriesLimit defines per-scrape limit on number of unique time series
a single target can expose during all the scrapes on the time window of 24h. | _integer_ | false | | `targetPort` | TargetPort
Name or number of the pod port this endpoint refers to. Mutually exclusive with port. | _[IntOrString](#intorstring)_ | false | | `tlsConfig` | TLSConfig configuration to use when scraping the endpoint | _[TLSConfig](#tlsconfig)_ | false | @@ -802,6 +803,7 @@ _Appears in:_ | `scheme` | HTTP scheme to use for scraping. | _string_ | false | | `scrapeTimeout` | Timeout after which the scrape is ended | _string_ | false | | `scrape_interval` | ScrapeInterval is the same as Interval and has priority over it.
one of scrape_interval or interval can be used | _string_ | false | +| `scrape_protocols` | ScrapeProtocols defines Prometheus scrape protocol. | _string array_ | false | | `seriesLimit` | SeriesLimit defines per-scrape limit on number of unique time series
a single target can expose during all the scrapes on the time window of 24h. | _integer_ | false | | `vm_scrape_params` | VMScrapeParams defines VictoriaMetrics specific scrape parameters | _[VMScrapeParams](#vmscrapeparams)_ | false | @@ -1355,6 +1357,7 @@ _Appears in:_ | `scheme` | HTTP scheme to use for scraping. | _string_ | false | | `scrapeTimeout` | Timeout after which the scrape is ended | _string_ | false | | `scrape_interval` | ScrapeInterval is the same as Interval and has priority over it.
one of scrape_interval or interval can be used | _string_ | false | +| `scrape_protocols` | ScrapeProtocols defines Prometheus scrape protocol. | _string array_ | false | | `seriesLimit` | SeriesLimit defines per-scrape limit on number of unique time series
a single target can expose during all the scrapes on the time window of 24h. | _integer_ | false | | `targetPort` | TargetPort
Name or number of the pod port this endpoint refers to. Mutually exclusive with port. | _[IntOrString](#intorstring)_ | false | | `tlsConfig` | TLSConfig configuration to use when scraping the endpoint | _[TLSConfig](#tlsconfig)_ | false | @@ -2015,6 +2018,7 @@ _Appears in:_ | `scheme` | HTTP scheme to use for scraping. | _string_ | false | | `scrapeTimeout` | Timeout after which the scrape is ended | _string_ | false | | `scrape_interval` | ScrapeInterval is the same as Interval and has priority over it.
one of scrape_interval or interval can be used | _string_ | false | +| `scrape_protocols` | ScrapeProtocols defines Prometheus scrape protocol. | _string array_ | false | | `seriesLimit` | SeriesLimit defines per-scrape limit on number of unique time series
a single target can expose during all the scrapes on the time window of 24h. | _integer_ | false | | `targets` | Targets static targets addresses in form of ["192.122.55.55:9100","some-name:9100"]. | _string array_ | true | | `tlsConfig` | TLSConfig configuration to use when scraping the endpoint | _[TLSConfig](#tlsconfig)_ | false | @@ -2470,6 +2474,7 @@ _Appears in:_ | `scrapeConfigSelector` | ScrapeConfigSelector defines VMScrapeConfig to be selected for target discovery.
Works in combination with NamespaceSelector. | _[LabelSelector](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#labelselector-v1-meta)_ | false | | `scrapeInterval` | ScrapeInterval defines how often scrape targets by default | _string_ | false | | `scrapeTimeout` | ScrapeTimeout defines global timeout for targets scrape | _string_ | false | +| `scrape_protocols` | ScrapeProtocols defines Prometheus scrape protocol. | _string array_ | false | | `secrets` | Secrets is a list of Secrets in the same namespace as the vmagent
object, which shall be mounted into the vmagent Pods.
will be mounted at path /etc/vm/secrets | _string array_ | false | | `securityContext` | SecurityContext holds pod-level security attributes and common container settings.
This defaults to the default PodSecurityContext. | _[PodSecurityContext](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#podsecuritycontext-v1-core)_ | false | | `selectAllByDefault` | SelectAllByDefault changes default behavior for empty CRD selectors, such ServiceScrapeSelector.
with selectAllByDefault: true and empty serviceScrapeSelector and ServiceScrapeNamespaceSelector
Operator selects all exist serviceScrapes
with selectAllByDefault: false - selects nothing | _boolean_ | false | @@ -3089,6 +3094,7 @@ _Appears in:_ | `scheme` | HTTP scheme to use for scraping. | _string_ | false | | `scrapeTimeout` | Timeout after which the scrape is ended | _string_ | false | | `scrape_interval` | ScrapeInterval is the same as Interval and has priority over it.
one of scrape_interval or interval can be used | _string_ | false | +| `scrape_protocols` | ScrapeProtocols defines Prometheus scrape protocol. | _string array_ | false | | `selector` | Selector to select kubernetes Nodes. | _[LabelSelector](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#labelselector-v1-meta)_ | false | | `seriesLimit` | SeriesLimit defines per-scrape limit on number of unique time series
a single target can expose during all the scrapes on the time window of 24h. | _integer_ | false | | `targetLabels` | TargetLabels transfers labels on the Kubernetes Node onto the target. | _string array_ | false | @@ -3192,6 +3198,7 @@ _Appears in:_ | `scheme` | HTTP scheme to use for scraping. | _string_ | false | | `scrapeTimeout` | Timeout after which the scrape is ended | _string_ | false | | `scrape_interval` | ScrapeInterval is the same as Interval and has priority over it.
one of scrape_interval or interval can be used | _string_ | false | +| `scrape_protocols` | ScrapeProtocols defines Prometheus scrape protocol. | _string array_ | false | | `seriesLimit` | SeriesLimit defines per-scrape limit on number of unique time series
a single target can expose during all the scrapes on the time window of 24h. | _integer_ | false | | `targets` | Targets defines a set of static and/or dynamically discovered targets to be probed using the prober. | _[VMProbeTargets](#vmprobetargets)_ | true | | `tlsConfig` | TLSConfig configuration to use when scraping the endpoint | _[TLSConfig](#tlsconfig)_ | false | @@ -3380,6 +3387,7 @@ _Appears in:_ | `scheme` | HTTP scheme to use for scraping. | _string_ | false | | `scrapeTimeout` | Timeout after which the scrape is ended | _string_ | false | | `scrape_interval` | ScrapeInterval is the same as Interval and has priority over it.
one of scrape_interval or interval can be used | _string_ | false | +| `scrape_protocols` | ScrapeProtocols defines Prometheus scrape protocol. | _string array_ | false | | `seriesLimit` | SeriesLimit defines per-scrape limit on number of unique time series
a single target can expose during all the scrapes on the time window of 24h. | _integer_ | false | | `staticConfigs` | StaticConfigs defines a list of static targets with a common label set. | _[StaticConfig](#staticconfig) array_ | false | | `tlsConfig` | TLSConfig configuration to use when scraping the endpoint | _[TLSConfig](#tlsconfig)_ | false | diff --git a/internal/controller/operator/factory/vmagent/scrapeconfig_test.go b/internal/controller/operator/factory/vmagent/scrapeconfig_test.go index 11a627cf..a0c86928 100644 --- a/internal/controller/operator/factory/vmagent/scrapeconfig_test.go +++ b/internal/controller/operator/factory/vmagent/scrapeconfig_test.go @@ -41,8 +41,9 @@ func TestGenerateScrapeConfig(t *testing.T) { }, Spec: vmv1beta1.VMScrapeConfigSpec{ EndpointScrapeParams: vmv1beta1.EndpointScrapeParams{ - MaxScrapeSize: "60KB", - ScrapeInterval: "10s", + MaxScrapeSize: "60KB", + ScrapeInterval: "10s", + ScrapeProtocols: []string{"PrometheusProto"}, }, StaticConfigs: []vmv1beta1.StaticConfig{ { @@ -70,6 +71,8 @@ func TestGenerateScrapeConfig(t *testing.T) { want: `job_name: scrapeConfig/default/static-1 honor_labels: false scrape_interval: 30s +scrape_protocols: +- PrometheusProto max_scrape_size: 60KB relabel_configs: [] basic_auth: diff --git a/internal/controller/operator/factory/vmagent/vmagent_scrapeconfig.go b/internal/controller/operator/factory/vmagent/vmagent_scrapeconfig.go index 248d28d6..78b8140f 100644 --- a/internal/controller/operator/factory/vmagent/vmagent_scrapeconfig.go +++ b/internal/controller/operator/factory/vmagent/vmagent_scrapeconfig.go @@ -1490,6 +1490,9 @@ func addCommonScrapeParamsTo(cfg yaml.MapSlice, cs vmv1beta1.EndpointScrapeParam if cs.ScrapeInterval != "" { cfg = append(cfg, yaml.MapItem{Key: "scrape_interval", Value: cs.ScrapeInterval}) } + if len(cs.ScrapeProtocols) > 0 { + cfg = append(cfg, yaml.MapItem{Key: "scrape_protocols", Value: cs.ScrapeProtocols}) + } if cs.ScrapeTimeout != "" { cfg = append(cfg, yaml.MapItem{Key: "scrape_timeout", Value: cs.ScrapeTimeout}) }