Skip to content

Commit 9e2b000

Browse files
vmscrapeconfig: support scrape_protocols option
1 parent 64879fb commit 9e2b000

File tree

8 files changed

+69
-2
lines changed

8 files changed

+69
-2
lines changed

api/operator/v1beta1/common_scrapeparams.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,9 @@ type EndpointScrapeParams struct {
250250
// Timeout after which the scrape is ended
251251
// +optional
252252
ScrapeTimeout string `json:"scrapeTimeout,omitempty"`
253+
// ScrapeProtocols defines Prometheus scrape protocol.
254+
// +optional
255+
ScrapeProtocols []string `json:"scrape_protocols,omitempty"`
253256
// ProxyURL eg http://proxyserver:2195 Directs scrapes to proxy through this endpoint.
254257
// +optional
255258
ProxyURL *string `json:"proxyURL,omitempty"`

api/operator/v1beta1/vmagent_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,9 @@ type VMAgentSpec struct {
174174
// +optional
175175
// +kubebuilder:validation:Pattern:="[0-9]+(ms|s|m|h)"
176176
ScrapeTimeout string `json:"scrapeTimeout,omitempty"`
177+
// ScrapeProtocols defines Prometheus scrape protocol.
178+
// +optional
179+
ScrapeProtocols []string `json:"scrape_protocols,omitempty"`
177180

178181
// APIServerConfig allows specifying a host and auth methods to access apiserver.
179182
// If left empty, VMAgent is assumed to run inside of the cluster

api/operator/v1beta1/zz_generated.deepcopy.go

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/overlay/crd.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3799,6 +3799,11 @@ spec:
37993799
schedulerName:
38003800
description: SchedulerName - defines kubernetes scheduler name
38013801
type: string
3802+
scrape_protocols:
3803+
description: ScrapeProtocols defines Prometheus scrape protocol.
3804+
items:
3805+
type: string
3806+
type: array
38023807
scrapeConfigNamespaceSelector:
38033808
description: |-
38043809
ScrapeConfigNamespaceSelector defines Namespaces to be selected for VMScrapeConfig discovery.
@@ -19212,6 +19217,11 @@ spec:
1921219217
ScrapeInterval is the same as Interval and has priority over it.
1921319218
one of scrape_interval or interval can be used
1921419219
type: string
19220+
scrape_protocols:
19221+
description: ScrapeProtocols defines Prometheus scrape protocol.
19222+
items:
19223+
type: string
19224+
type: array
1921519225
scrapeTimeout:
1921619226
description: Timeout after which the scrape is ended
1921719227
type: string
@@ -20298,6 +20308,11 @@ spec:
2029820308
ScrapeInterval is the same as Interval and has priority over it.
2029920309
one of scrape_interval or interval can be used
2030020310
type: string
20311+
scrape_protocols:
20312+
description: ScrapeProtocols defines Prometheus scrape protocol.
20313+
items:
20314+
type: string
20315+
type: array
2030120316
scrapeTimeout:
2030220317
description: Timeout after which the scrape is ended
2030320318
type: string
@@ -21290,6 +21305,11 @@ spec:
2129021305
ScrapeInterval is the same as Interval and has priority over it.
2129121306
one of scrape_interval or interval can be used
2129221307
type: string
21308+
scrape_protocols:
21309+
description: ScrapeProtocols defines Prometheus scrape protocol.
21310+
items:
21311+
type: string
21312+
type: array
2129321313
scrapeTimeout:
2129421314
description: Timeout after which the scrape is ended
2129521315
type: string
@@ -25932,6 +25952,11 @@ spec:
2593225952
ScrapeInterval is the same as Interval and has priority over it.
2593325953
one of scrape_interval or interval can be used
2593425954
type: string
25955+
scrape_protocols:
25956+
description: ScrapeProtocols defines Prometheus scrape protocol.
25957+
items:
25958+
type: string
25959+
type: array
2593525960
scrapeTimeout:
2593625961
description: Timeout after which the scrape is ended
2593725962
type: string
@@ -26976,6 +27001,11 @@ spec:
2697627001
ScrapeInterval is the same as Interval and has priority over it.
2697727002
one of scrape_interval or interval can be used
2697827003
type: string
27004+
scrape_protocols:
27005+
description: ScrapeProtocols defines Prometheus scrape protocol.
27006+
items:
27007+
type: string
27008+
type: array
2697927009
scrapeTimeout:
2698027010
description: Timeout after which the scrape is ended
2698127011
type: string
@@ -29774,6 +29804,11 @@ spec:
2977429804
ScrapeInterval is the same as Interval and has priority over it.
2977529805
one of scrape_interval or interval can be used
2977629806
type: string
29807+
scrape_protocols:
29808+
description: ScrapeProtocols defines Prometheus scrape protocol.
29809+
items:
29810+
type: string
29811+
type: array
2977729812
scrapeTimeout:
2977829813
description: Timeout after which the scrape is ended
2977929814
type: string

docs/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ aliases:
7575

7676
- [vmscrapeconfig](https://docs.victoriametrics.com/operator/api#vmscrapeconfig) - added `max_scrape_size` parameter for scrape protocols configuration
7777

78+
- [vmservicescrape](./api.md#vmservicescrape), [vmpodscrape](./api.md#vmpodscrape), [vmnodescrape](./api.md#vmnodescrape) - added `scrape_protocols` parameter for scrape protocols configuration
79+
7880
<a name="v0.45.0"></a>
7981

8082
## [v0.45.0](https://github.com/VictoriaMetrics/operator/releases/tag/v0.45.0) - 10 Jun 2024

docs/api.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,7 @@ _Appears in:_
719719
| `scheme` | HTTP scheme to use for scraping. | _string_ | false |
720720
| `scrapeTimeout` | Timeout after which the scrape is ended | _string_ | false |
721721
| `scrape_interval` | ScrapeInterval is the same as Interval and has priority over it.<br />one of scrape_interval or interval can be used | _string_ | false |
722+
| `scrape_protocols` | ScrapeProtocols defines Prometheus scrape protocol. | _string array_ | false |
722723
| `seriesLimit` | SeriesLimit defines per-scrape limit on number of unique time series<br />a single target can expose during all the scrapes on the time window of 24h. | _integer_ | false |
723724
| `targetPort` | TargetPort<br />Name or number of the pod port this endpoint refers to. Mutually exclusive with port. | _[IntOrString](#intorstring)_ | false |
724725
| `tlsConfig` | TLSConfig configuration to use when scraping the endpoint | _[TLSConfig](#tlsconfig)_ | false |
@@ -802,6 +803,7 @@ _Appears in:_
802803
| `scheme` | HTTP scheme to use for scraping. | _string_ | false |
803804
| `scrapeTimeout` | Timeout after which the scrape is ended | _string_ | false |
804805
| `scrape_interval` | ScrapeInterval is the same as Interval and has priority over it.<br />one of scrape_interval or interval can be used | _string_ | false |
806+
| `scrape_protocols` | ScrapeProtocols defines Prometheus scrape protocol. | _string array_ | false |
805807
| `seriesLimit` | SeriesLimit defines per-scrape limit on number of unique time series<br />a single target can expose during all the scrapes on the time window of 24h. | _integer_ | false |
806808
| `vm_scrape_params` | VMScrapeParams defines VictoriaMetrics specific scrape parameters | _[VMScrapeParams](#vmscrapeparams)_ | false |
807809

@@ -1355,6 +1357,7 @@ _Appears in:_
13551357
| `scheme` | HTTP scheme to use for scraping. | _string_ | false |
13561358
| `scrapeTimeout` | Timeout after which the scrape is ended | _string_ | false |
13571359
| `scrape_interval` | ScrapeInterval is the same as Interval and has priority over it.<br />one of scrape_interval or interval can be used | _string_ | false |
1360+
| `scrape_protocols` | ScrapeProtocols defines Prometheus scrape protocol. | _string array_ | false |
13581361
| `seriesLimit` | SeriesLimit defines per-scrape limit on number of unique time series<br />a single target can expose during all the scrapes on the time window of 24h. | _integer_ | false |
13591362
| `targetPort` | TargetPort<br />Name or number of the pod port this endpoint refers to. Mutually exclusive with port. | _[IntOrString](#intorstring)_ | false |
13601363
| `tlsConfig` | TLSConfig configuration to use when scraping the endpoint | _[TLSConfig](#tlsconfig)_ | false |
@@ -2015,6 +2018,7 @@ _Appears in:_
20152018
| `scheme` | HTTP scheme to use for scraping. | _string_ | false |
20162019
| `scrapeTimeout` | Timeout after which the scrape is ended | _string_ | false |
20172020
| `scrape_interval` | ScrapeInterval is the same as Interval and has priority over it.<br />one of scrape_interval or interval can be used | _string_ | false |
2021+
| `scrape_protocols` | ScrapeProtocols defines Prometheus scrape protocol. | _string array_ | false |
20182022
| `seriesLimit` | SeriesLimit defines per-scrape limit on number of unique time series<br />a single target can expose during all the scrapes on the time window of 24h. | _integer_ | false |
20192023
| `targets` | Targets static targets addresses in form of ["192.122.55.55:9100","some-name:9100"]. | _string array_ | true |
20202024
| `tlsConfig` | TLSConfig configuration to use when scraping the endpoint | _[TLSConfig](#tlsconfig)_ | false |
@@ -2470,6 +2474,7 @@ _Appears in:_
24702474
| `scrapeConfigSelector` | ScrapeConfigSelector defines VMScrapeConfig to be selected for target discovery.<br />Works in combination with NamespaceSelector. | _[LabelSelector](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#labelselector-v1-meta)_ | false |
24712475
| `scrapeInterval` | ScrapeInterval defines how often scrape targets by default | _string_ | false |
24722476
| `scrapeTimeout` | ScrapeTimeout defines global timeout for targets scrape | _string_ | false |
2477+
| `scrape_protocols` | ScrapeProtocols defines Prometheus scrape protocol. | _string array_ | false |
24732478
| `secrets` | Secrets is a list of Secrets in the same namespace as the vmagent<br />object, which shall be mounted into the vmagent Pods.<br />will be mounted at path /etc/vm/secrets | _string array_ | false |
24742479
| `securityContext` | SecurityContext holds pod-level security attributes and common container settings.<br />This defaults to the default PodSecurityContext. | _[PodSecurityContext](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#podsecuritycontext-v1-core)_ | false |
24752480
| `selectAllByDefault` | SelectAllByDefault changes default behavior for empty CRD selectors, such ServiceScrapeSelector.<br />with selectAllByDefault: true and empty serviceScrapeSelector and ServiceScrapeNamespaceSelector<br />Operator selects all exist serviceScrapes<br />with selectAllByDefault: false - selects nothing | _boolean_ | false |
@@ -3089,6 +3094,7 @@ _Appears in:_
30893094
| `scheme` | HTTP scheme to use for scraping. | _string_ | false |
30903095
| `scrapeTimeout` | Timeout after which the scrape is ended | _string_ | false |
30913096
| `scrape_interval` | ScrapeInterval is the same as Interval and has priority over it.<br />one of scrape_interval or interval can be used | _string_ | false |
3097+
| `scrape_protocols` | ScrapeProtocols defines Prometheus scrape protocol. | _string array_ | false |
30923098
| `selector` | Selector to select kubernetes Nodes. | _[LabelSelector](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.30/#labelselector-v1-meta)_ | false |
30933099
| `seriesLimit` | SeriesLimit defines per-scrape limit on number of unique time series<br />a single target can expose during all the scrapes on the time window of 24h. | _integer_ | false |
30943100
| `targetLabels` | TargetLabels transfers labels on the Kubernetes Node onto the target. | _string array_ | false |
@@ -3192,6 +3198,7 @@ _Appears in:_
31923198
| `scheme` | HTTP scheme to use for scraping. | _string_ | false |
31933199
| `scrapeTimeout` | Timeout after which the scrape is ended | _string_ | false |
31943200
| `scrape_interval` | ScrapeInterval is the same as Interval and has priority over it.<br />one of scrape_interval or interval can be used | _string_ | false |
3201+
| `scrape_protocols` | ScrapeProtocols defines Prometheus scrape protocol. | _string array_ | false |
31953202
| `seriesLimit` | SeriesLimit defines per-scrape limit on number of unique time series<br />a single target can expose during all the scrapes on the time window of 24h. | _integer_ | false |
31963203
| `targets` | Targets defines a set of static and/or dynamically discovered targets to be probed using the prober. | _[VMProbeTargets](#vmprobetargets)_ | true |
31973204
| `tlsConfig` | TLSConfig configuration to use when scraping the endpoint | _[TLSConfig](#tlsconfig)_ | false |
@@ -3380,6 +3387,7 @@ _Appears in:_
33803387
| `scheme` | HTTP scheme to use for scraping. | _string_ | false |
33813388
| `scrapeTimeout` | Timeout after which the scrape is ended | _string_ | false |
33823389
| `scrape_interval` | ScrapeInterval is the same as Interval and has priority over it.<br />one of scrape_interval or interval can be used | _string_ | false |
3390+
| `scrape_protocols` | ScrapeProtocols defines Prometheus scrape protocol. | _string array_ | false |
33833391
| `seriesLimit` | SeriesLimit defines per-scrape limit on number of unique time series<br />a single target can expose during all the scrapes on the time window of 24h. | _integer_ | false |
33843392
| `staticConfigs` | StaticConfigs defines a list of static targets with a common label set. | _[StaticConfig](#staticconfig) array_ | false |
33853393
| `tlsConfig` | TLSConfig configuration to use when scraping the endpoint | _[TLSConfig](#tlsconfig)_ | false |

internal/controller/operator/factory/vmagent/scrapeconfig_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ func TestGenerateScrapeConfig(t *testing.T) {
4141
},
4242
Spec: vmv1beta1.VMScrapeConfigSpec{
4343
EndpointScrapeParams: vmv1beta1.EndpointScrapeParams{
44-
MaxScrapeSize: "60KB",
45-
ScrapeInterval: "10s",
44+
MaxScrapeSize: "60KB",
45+
ScrapeInterval: "10s",
46+
ScrapeProtocols: []string{"PrometheusProto"},
4647
},
4748
StaticConfigs: []vmv1beta1.StaticConfig{
4849
{
@@ -70,6 +71,8 @@ func TestGenerateScrapeConfig(t *testing.T) {
7071
want: `job_name: scrapeConfig/default/static-1
7172
honor_labels: false
7273
scrape_interval: 30s
74+
scrape_protocols:
75+
- PrometheusProto
7376
max_scrape_size: 60KB
7477
relabel_configs: []
7578
basic_auth:

internal/controller/operator/factory/vmagent/vmagent_scrapeconfig.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,6 +1490,9 @@ func addCommonScrapeParamsTo(cfg yaml.MapSlice, cs vmv1beta1.EndpointScrapeParam
14901490
if cs.ScrapeInterval != "" {
14911491
cfg = append(cfg, yaml.MapItem{Key: "scrape_interval", Value: cs.ScrapeInterval})
14921492
}
1493+
if len(cs.ScrapeProtocols) > 0 {
1494+
cfg = append(cfg, yaml.MapItem{Key: "scrape_protocols", Value: cs.ScrapeProtocols})
1495+
}
14931496
if cs.ScrapeTimeout != "" {
14941497
cfg = append(cfg, yaml.MapItem{Key: "scrape_timeout", Value: cs.ScrapeTimeout})
14951498
}

0 commit comments

Comments
 (0)