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
Andrew Chubatiuk authored and AndrewChubatiuk committed Jun 13, 2024
1 parent 23d58cf commit f8207e0
Show file tree
Hide file tree
Showing 18 changed files with 90 additions and 13 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ generate: controller-gen

# find or download controller-gen
# download controller-gen if necessary

controller-gen:
ifneq (Version: $(CONTROLLER_GEN_VERSION), $(shell controller-gen --version))
@{ \
Expand Down
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 @@ -453,8 +453,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 @@ -506,8 +506,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 @@ -495,8 +495,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 @@ -476,8 +476,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
4 changes: 3 additions & 1 deletion controllers/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 controllers/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
3 changes: 3 additions & 0 deletions controllers/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
4 changes: 4 additions & 0 deletions controllers/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 f8207e0

Please sign in to comment.