/
vmstaticscrape_types.go
145 lines (133 loc) · 5.46 KB
/
vmstaticscrape_types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
package v1beta1
import (
"fmt"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// VMStaticScrapeSpec defines the desired state of VMStaticScrape.
type VMStaticScrapeSpec struct {
// JobName name of job.
JobName string `json:"jobName,omitempty"`
// A list of target endpoints to scrape metrics from.
TargetEndpoints []*TargetEndpoint `json:"targetEndpoints"`
// SampleLimit defines per-scrape limit on number of scraped samples that will be accepted.
// +optional
SampleLimit uint64 `json:"sampleLimit,omitempty"`
// 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.
// +optional
SeriesLimit uint64 `json:"seriesLimit,omitempty"`
}
// TargetEndpoint defines single static target endpoint.
type TargetEndpoint struct {
// Targets static targets addresses in form of ["192.122.55.55:9100","some-name:9100"].
// +kubebuilder:validation:MinItems=1
Targets []string `json:"targets"`
// Labels static labels for targets.
// +optional
Labels map[string]string `json:"labels,omitempty"`
// Default port for target.
// +optional
Port string `json:"port,omitempty"`
// HTTP path to scrape for metrics.
// +optional
Path string `json:"path,omitempty"`
// HTTP scheme to use for scraping.
// +optional
// +kubebuilder:validation:Enum=http;https
Scheme string `json:"scheme,omitempty"`
// Optional HTTP URL parameters
// +optional
Params map[string][]string `json:"params,omitempty"`
// FollowRedirects controls redirects for scraping.
// +optional
FollowRedirects *bool `json:"follow_redirects,omitempty"`
// SampleLimit defines per-scrape limit on number of scraped samples that will be accepted.
// +optional
SampleLimit uint64 `json:"sampleLimit,omitempty"`
// 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.
// +optional
SeriesLimit uint64 `json:"seriesLimit,omitempty"`
// Interval at which metrics should be scraped
// +optional
Interval string `json:"interval,omitempty"`
// ScrapeInterval is the same as Interval and has priority over it.
// one of scrape_interval or interval can be used
// +optional
ScrapeInterval string `json:"scrape_interval,omitempty"`
// Timeout after which the scrape is ended
// +optional
ScrapeTimeout string `json:"scrapeTimeout,omitempty"`
// OAuth2 defines auth configuration
// +optional
OAuth2 *OAuth2 `json:"oauth2,omitempty"`
// TLSConfig configuration to use when scraping the endpoint
// +optional
TLSConfig *TLSConfig `json:"tlsConfig,omitempty"`
// File to read bearer token for scraping targets.
// +optional
BearerTokenFile string `json:"bearerTokenFile,omitempty"`
// Secret to mount to read bearer token for scraping targets. The secret
// needs to be in the same namespace as the service scrape and accessible by
// the victoria-metrics operator.
// +optional
// +nullable
BearerTokenSecret *v1.SecretKeySelector `json:"bearerTokenSecret,omitempty"`
// BasicAuth allow an endpoint to authenticate over basic authentication
// More info: https://prometheus.io/docs/operating/configuration/#endpoints
// +optional
BasicAuth *BasicAuth `json:"basicAuth,omitempty"`
// Authorization with http header Authorization
// +optional
Authorization *Authorization `json:"authorization,omitempty"`
// MetricRelabelConfigs to apply to samples before ingestion.
// +optional
MetricRelabelConfigs []*RelabelConfig `json:"metricRelabelConfigs,omitempty"`
// RelabelConfigs to apply to samples before scraping.
// More info: https://prometheus.io/docs/prometheus/latest/configuration/configuration/#relabel_config
// +optional
RelabelConfigs []*RelabelConfig `json:"relabelConfigs,omitempty"`
// ProxyURL eg http://proxyserver:2195 Directs scrapes to proxy through this endpoint.
// +optional
ProxyURL *string `json:"proxyURL,omitempty"`
// HonorLabels chooses the metric's labels on collisions with target labels.
// +optional
HonorLabels bool `json:"honorLabels,omitempty"`
// HonorTimestamps controls whether vmagent respects the timestamps present in scraped data.
// +optional
HonorTimestamps *bool `json:"honorTimestamps,omitempty"`
// VMScrapeParams defines VictoriaMetrics specific scrape parametrs
// +optional
VMScrapeParams *VMScrapeParams `json:"vm_scrape_params,omitempty"`
}
// VMStaticScrapeStatus defines the observed state of VMStaticScrape
type VMStaticScrapeStatus struct{}
// VMStaticScrape defines static targets configuration for scraping.
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +genclient
type VMStaticScrape struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec VMStaticScrapeSpec `json:"spec,omitempty"`
Status VMStaticScrapeStatus `json:"status,omitempty"`
}
// +kubebuilder:object:root=true
// VMStaticScrapeList contains a list of VMStaticScrape
type VMStaticScrapeList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []VMStaticScrape `json:"items"`
}
// AsProxyKey builds key for proxy cache maps
func (cr VMStaticScrape) AsProxyKey(i int) string {
return fmt.Sprintf("staticScrapeProxy/%s/%s/%d", cr.Namespace, cr.Name, i)
}
// AsMapKey builds key for cache secret map
func (cr VMStaticScrape) AsMapKey(i int) string {
return fmt.Sprintf("staticScrape/%s/%s/%d", cr.Namespace, cr.Name, i)
}
func init() {
SchemeBuilder.Register(&VMStaticScrape{}, &VMStaticScrapeList{})
}