Skip to content

vmscrapeconfig: support scrape_protocol option #877

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions api/operator/v1beta1/common_scrapeparams.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
3 changes: 3 additions & 0 deletions api/operator/v1beta1/vmagent_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions api/operator/v1beta1/zz_generated.deepcopy.go

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

35 changes: 35 additions & 0 deletions config/crd/overlay/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

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

## [v0.45.0](https://github.com/VictoriaMetrics/operator/releases/tag/v0.45.0) - 10 Jun 2024
Expand Down
8 changes: 8 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.<br />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<br />a single target can expose during all the scrapes on the time window of 24h. | _integer_ | false |
| `targetPort` | TargetPort<br />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 |
Expand Down Expand Up @@ -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.<br />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<br />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 |

Expand Down Expand Up @@ -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.<br />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<br />a single target can expose during all the scrapes on the time window of 24h. | _integer_ | false |
| `targetPort` | TargetPort<br />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 |
Expand Down Expand Up @@ -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.<br />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<br />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 |
Expand Down Expand Up @@ -2470,6 +2474,7 @@ _Appears in:_
| `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 |
| `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<br />object, which shall be mounted into the vmagent Pods.<br />will be mounted at path /etc/vm/secrets | _string array_ | false |
| `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 |
| `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 |
Expand Down Expand Up @@ -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.<br />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<br />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 |
Expand Down Expand Up @@ -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.<br />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<br />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 |
Expand Down Expand Up @@ -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.<br />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<br />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 |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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{
{
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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})
}
Expand Down
Loading