Skip to content

Commit

Permalink
vmpodscrape/vmservicescrape/vmnodescrape/vmstaticscrape: support scra…
Browse files Browse the repository at this point in the history
…pe_protocols option
  • Loading branch information
AndrewChubatiuk committed Jun 21, 2024
1 parent e9b2e9c commit 7e56086
Show file tree
Hide file tree
Showing 21 changed files with 108 additions and 13 deletions.
5 changes: 4 additions & 1 deletion api/v1beta1/vmnodescrape_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,12 @@ type VMNodeScrapeSpec struct {
// one of scrape_interval or interval can be used
// +optional
ScrapeInterval string `json:"scrape_interval,omitempty"`
// Timeout after which the scrape is ended
// ScrapeTimeout after which the scrape is ended
// +optional
ScrapeTimeout string `json:"scrapeTimeout,omitempty"`
// ScrapeProtocols defines Prometheus scrape protocol.
// +optional
ScrapeProtocols []string `json:"scrape_protocols,omitempty"`
// OAuth2 defines auth configuration
// +optional
OAuth2 *OAuth2 `json:"oauth2,omitempty"`
Expand Down
5 changes: 4 additions & 1 deletion api/v1beta1/vmpodscrape_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ type PodMetricsEndpoint struct {
// one of scrape_interval or interval can be used
// +optional
ScrapeInterval string `json:"scrape_interval,omitempty"`
// Timeout after which the scrape is ended
// ScrapeTimeout after which the scrape is ended
// +optional
ScrapeTimeout string `json:"scrapeTimeout,omitempty"`
// SampleLimit defines per-podEndpoint limit on number of scraped samples that will be accepted.
Expand All @@ -107,6 +107,9 @@ type PodMetricsEndpoint struct {
// a single target can expose during all the scrapes on the time window of 24h.
// +optional
SeriesLimit uint64 `json:"seriesLimit,omitempty"`
// ScrapeProtocols defines Prometheus scrape protocol.
// +optional
ScrapeProtocols []string `json:"scrape_protocols,omitempty"`
// HonorLabels chooses the metric's labels on collisions with target labels.
// +optional
HonorLabels bool `json:"honorLabels,omitempty"`
Expand Down
5 changes: 4 additions & 1 deletion api/v1beta1/vmservicescrape_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ type Endpoint struct {
// one of scrape_interval or interval can be used
// +optional
ScrapeInterval string `json:"scrape_interval,omitempty"`
// Timeout after which the scrape is ended
// ScrapeTimeout after which the scrape is ended
// +optional
ScrapeTimeout string `json:"scrapeTimeout,omitempty"`
// SampleLimit defines per-endpoint limit on number of scraped samples that will be accepted.
Expand All @@ -150,6 +150,9 @@ type Endpoint struct {
// a single target can expose during all the scrapes on the time window of 24h.
// +optional
SeriesLimit uint64 `json:"seriesLimit,omitempty"`
// ScrapeProtocols defines Prometheus scrape protocol.
// +optional
ScrapeProtocols []string `json:"scrape_protocols,omitempty"`
// OAuth2 defines auth configuration
// +optional
OAuth2 *OAuth2 `json:"oauth2,omitempty"`
Expand Down
5 changes: 4 additions & 1 deletion api/v1beta1/vmstaticscrape_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,12 @@ type TargetEndpoint struct {
// one of scrape_interval or interval can be used
// +optional
ScrapeInterval string `json:"scrape_interval,omitempty"`
// Timeout after which the scrape is ended
// ScrapeTimeout after which the scrape is ended
// +optional
ScrapeTimeout string `json:"scrapeTimeout,omitempty"`
// ScrapeProtocols defines Prometheus scrape protocol.
// +optional
ScrapeProtocols []string `json:"scrape_protocols,omitempty"`
// OAuth2 defines auth configuration
// +optional
OAuth2 *OAuth2 `json:"oauth2,omitempty"`
Expand Down
20 changes: 20 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

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

5 changes: 4 additions & 1 deletion api/victoriametrics/v1beta1/vmnodescrape_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,12 @@ type VMNodeScrapeSpec struct {
// one of scrape_interval or interval can be used
// +optional
ScrapeInterval string `json:"scrape_interval,omitempty"`
// Timeout after which the scrape is ended
// ScrapeTimeout after which the scrape is ended
// +optional
ScrapeTimeout string `json:"scrapeTimeout,omitempty"`
// ScrapeProtocols defines Prometheus scrape protocol.
// +optional
ScrapeProtocols []string `json:"scrape_protocols,omitempty"`
// OAuth2 defines auth configuration
// +optional
OAuth2 *OAuth2 `json:"oauth2,omitempty"`
Expand Down
5 changes: 4 additions & 1 deletion api/victoriametrics/v1beta1/vmpodscrape_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,12 @@ type PodMetricsEndpoint struct {
// one of scrape_interval or interval can be used
// +optional
ScrapeInterval string `json:"scrape_interval,omitempty"`
// Timeout after which the scrape is ended
// ScrapeTimeout after which the scrape is ended
// +optional
ScrapeTimeout string `json:"scrapeTimeout,omitempty"`
// ScrapeProtocols defines Prometheus scrape protocol.
// +optional
ScrapeProtocols []string `json:"scrape_protocols,omitempty"`
// SampleLimit defines per-podEndpoint limit on number of scraped samples that will be accepted.
// +optional
SampleLimit uint64 `json:"sampleLimit,omitempty"`
Expand Down
5 changes: 4 additions & 1 deletion api/victoriametrics/v1beta1/vmservicescrape_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,12 @@ type Endpoint struct {
// one of scrape_interval or interval can be used
// +optional
ScrapeInterval string `json:"scrape_interval,omitempty"`
// Timeout after which the scrape is ended
// ScrapeTimeout after which the scrape is ended
// +optional
ScrapeTimeout string `json:"scrapeTimeout,omitempty"`
// ScrapeProtocols defines Prometheus scrape protocol.
// +optional
ScrapeProtocols []string `json:"scrape_protocols,omitempty"`
// SampleLimit defines per-endpoint limit on number of scraped samples that will be accepted.
// +optional
SampleLimit uint64 `json:"sampleLimit,omitempty"`
Expand Down
5 changes: 4 additions & 1 deletion api/victoriametrics/v1beta1/vmstaticscrape_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,12 @@ type TargetEndpoint struct {
// one of scrape_interval or interval can be used
// +optional
ScrapeInterval string `json:"scrape_interval,omitempty"`
// Timeout after which the scrape is ended
// ScrapeTimeout after which the scrape is ended
// +optional
ScrapeTimeout string `json:"scrapeTimeout,omitempty"`
// ScrapeProtocols defines Prometheus scrape protocol.
// +optional
ScrapeProtocols []string `json:"scrape_protocols,omitempty"`
// OAuth2 defines auth configuration
// +optional
OAuth2 *OAuth2 `json:"oauth2,omitempty"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,13 @@ 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
description: ScrapeTimeout after which the scrape is ended
type: string
selector:
description: Selector to select kubernetes Nodes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,13 @@ 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
description: ScrapeTimeout after which the scrape is ended
type: string
seriesLimit:
description: |-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -458,8 +458,13 @@ 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
description: ScrapeTimeout after which the scrape is ended
type: string
seriesLimit:
description: |-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,8 +442,13 @@ 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
description: ScrapeTimeout after which the scrape is ended
type: string
seriesLimit:
description: |-
Expand Down
2 changes: 2 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ aliases:

- [vmalertmanagerconfig](./api.md#vmalertmanagerconfig): adds missing `handleReconcileErr` callback to the reconcile loop. It must properly handle errors and deregister objects.

- [vmservicescrape](./api.md#vmservicescrape), [vmpodscrape](./api.md#vmpodscrape), [vmnodescrape](./api.md#vmnodescrape) - added `scrape_protocols` parameter for scrape protocols configuration

<a name="v0.45.0"></a>

## [v0.45.0](https://github.com/VictoriaMetrics/operator/releases/tag/v0.45.0) - 10 Jun 2024
Expand Down
4 changes: 3 additions & 1 deletion internal/controller/factory/vmagent/nodescrape.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ func generateNodeScrapeConfig(
if scrapeInterval != "" {
cfg = append(cfg, yaml.MapItem{Key: "scrape_interval", Value: scrapeInterval})
}

if len(nodeSpec.ScrapeProtocols) != 0 {
cfg = append(cfg, yaml.MapItem{Key: "scrape_protocols", Value: nodeSpec.ScrapeProtocols})
}
if nodeSpec.ScrapeTimeout != "" {
cfg = append(cfg, yaml.MapItem{Key: "scrape_timeout", Value: nodeSpec.ScrapeTimeout})
}
Expand Down
3 changes: 3 additions & 0 deletions internal/controller/factory/vmagent/nodescrape_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ relabel_configs:
FollowRedirects: pointer.Bool(true),
ScrapeTimeout: "10s",
ScrapeInterval: "5s",
ScrapeProtocols: []string{"PrometheusProto"},
Params: map[string][]string{"module": {"client"}},
JobLabel: "env",
HonorTimestamps: pointer.Bool(true),
Expand Down Expand Up @@ -134,6 +135,8 @@ honor_timestamps: true
kubernetes_sd_configs:
- role: node
scrape_interval: 5s
scrape_protocols:
- PrometheusProto
scrape_timeout: 10s
metrics_path: /metrics
proxy_url: https://some-url
Expand Down
3 changes: 3 additions & 0 deletions internal/controller/factory/vmagent/podscrape.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ func generatePodScrapeConfig(
if scrapeInterval != "" {
cfg = append(cfg, yaml.MapItem{Key: "scrape_interval", Value: scrapeInterval})
}
if len(ep.ScrapeProtocols) != 0 {
cfg = append(cfg, yaml.MapItem{Key: "scrape_protocols", Value: ep.ScrapeProtocols})
}
if ep.ScrapeTimeout != "" {
cfg = append(cfg, yaml.MapItem{Key: "scrape_timeout", Value: ep.ScrapeTimeout})
}
Expand Down
7 changes: 7 additions & 0 deletions internal/controller/factory/vmagent/podscrape_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ relabel_configs:
},
},
ep: vmv1beta1.PodMetricsEndpoint{
ScrapeProtocols: []string{
"PrometheusText",
"PrometheusProto",
},
Path: "/metric",
Port: "web",
},
Expand All @@ -170,6 +174,9 @@ kubernetes_sd_configs:
selectors:
- role: pod
label: label-1=value-1,label-2=value-2,label-3=value-3
scrape_protocols:
- PrometheusText
- PrometheusProto
metrics_path: /metric
relabel_configs:
- action: drop
Expand Down
3 changes: 3 additions & 0 deletions internal/controller/factory/vmagent/servicescrape.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ func generateServiceScrapeConfig(
if scrapeInterval != "" {
cfg = append(cfg, yaml.MapItem{Key: "scrape_interval", Value: scrapeInterval})
}
if len(ep.ScrapeProtocols) != 0 {
cfg = append(cfg, yaml.MapItem{Key: "scrape_protocols", Value: ep.ScrapeProtocols})
}
if ep.ScrapeTimeout != "" {
cfg = append(cfg, yaml.MapItem{Key: "scrape_timeout", Value: ep.ScrapeTimeout})
}
Expand Down
7 changes: 7 additions & 0 deletions internal/controller/factory/vmagent/servicescrape_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ relabel_configs:
},
BearerTokenFile: "/var/run/tolen",
ScrapeInterval: "60m",
ScrapeProtocols: []string{
"PrometheusText",
"OpenMetricsText",
},
},
i: 0,
apiserverConfig: nil,
Expand All @@ -202,6 +206,9 @@ kubernetes_sd_configs:
names:
- default
scrape_interval: 40m
scrape_protocols:
- PrometheusText
- OpenMetricsText
tls_config:
insecure_skip_verify: false
ca_file: /etc/vmagent-tls/certs/default_tls-secret_ca
Expand Down
4 changes: 4 additions & 0 deletions internal/controller/factory/vmagent/staticscrape.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ func generateStaticScrapeConfig(
cfg = append(cfg, yaml.MapItem{Key: "scrape_interval", Value: scrapeInterval})
}

if len(ep.ScrapeProtocols) != 0 {
cfg = append(cfg, yaml.MapItem{Key: "scrape_protocols", Value: ep.ScrapeProtocols})
}

if ep.ScrapeTimeout != "" {
cfg = append(cfg, yaml.MapItem{Key: "scrape_timeout", Value: ep.ScrapeTimeout})
}
Expand Down

0 comments on commit 7e56086

Please sign in to comment.