forked from percona/promconfig
-
Notifications
You must be signed in to change notification settings - Fork 1
/
service_discovery.go
176 lines (161 loc) · 7.83 KB
/
service_discovery.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
// Changes described in CHANGELOG
// Copyright 2021 Zomato Ltd
//
// promconfig
// Copyright 2020 Percona LLC
//
// Based on Prometheus systems and service monitoring server.
// Copyright 2015 The Prometheus Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package promconfig
// ServiceDiscoveryConfig configures lists of different service discovery mechanisms.
type ServiceDiscoveryConfig struct {
// List of labeled target groups for this job.
StaticConfigs []*Group `yaml:"static_configs,omitempty"`
// List of file service discovery configurations.
FileSDConfigs []*FilesSDConfig `yaml:"file_sd_configs,omitempty"`
// List of HTTP service discovery configurations.
HTTPSDConfigs []*HTTPSDConfig `yaml:"http_sd_configs,omitempty"`
// List of Kubernetes service discovery configurations.
KubernetesSDConfigs []*KubernetesSDConfig `yaml:"kubernetes_sd_configs,omitempty"`
// List of AWS EC2 service discovery configurations.
EC2SDConfigs []*EC2SDConfig `yaml:"ec2_sd_configs,omitempty"`
// List of Google cloud GCE service discovery configurations.
GceSDConfigs []*GceSDConfig `yaml:"gce_sd_configs,omitempty"`
// List of azure cloud service discovery configurations.
AzureSDConfigs []*AzureSDConfig `yaml:"azure_sd_configs,omitempty"`
// List of digitalocean droplet service discovery configurations.
DigitaloceanSDConfigs []*DigitaloceanSDConfig `yaml:"digitalocean_sd_configs,omitempty"`
// List of consul catalog service discovery configurations.
ConsulSDConfigs []*ConsulSDConfig `yaml:"consul_sd_configs,omitempty"`
// List of docker swarm service discovery configurations.
DockerswarmSDConfigs []*DockerswarmSDConfig `yaml:"dockerswarm_sd_configs,omitempty"`
// List of dns-based service discovery configurations.
DNSSDConfigs []*DNSSDConfig `yaml:"dns_sd_configs,omitempty"`
// List of kuma service mesh service discovery configurations.
KumaSDConfigs []*KumaSDConfig `yaml:"kuma_sd_configs,omitempty"`
}
// Group is a set of targets with a common label set(production , test, staging etc.).
type Group struct {
// Targets is a list of targets identified by a label set. Each target is
// uniquely identifiable in the group by its address label.
Targets []string `yaml:"targets,omitempty"`
// Labels is a set of labels that is common across all targets in the group.
Labels map[string]string `yaml:"labels,omitempty"`
}
// FilesSDConfig is the configuration for file based discovery.
type FilesSDConfig struct {
Files []string `yaml:"files"`
RefreshInterval Duration `yaml:"refresh_interval,omitempty"`
}
// KubernetesSDConfig is the configuration for Kubernetes service discovery.
type KubernetesSDConfig struct {
APIServer string `yaml:"api_server,omitempty"`
Role string `yaml:"role"`
HTTPClientConfig HTTPClientConfig `yaml:",inline"`
NamespaceDiscovery []string `yaml:"namespaces,omitempty"`
}
// KumaSDConfig for kuma service mesh service discovery
type KumaSDConfig struct {
// Address of the Kuma Control Plane's MADS xDS server.
Server string `yaml:"server"`
RefreshInterval Duration `yaml:"refresh_interval,omitempty"`
FetchTimeout Duration `yaml:"fetch_timeout,omitempty"`
ProxyURL string `yaml:"proxy_url,omitempty"`
TLSConfig TLSConfig `yaml:"tls_config,omitempty"`
BasicAuth BasicAuth `yaml:"basic_auth,omitempty"`
Authorization Authorization `yaml:"authorization,omitempty"`
OAuth2 OAuth2 `yaml:"oauth2,omitempty"`
FollowRedirects *bool `yaml:"follow_redirects,omitempty"`
}
// EC2SDConfig is the configuration for AWS EC2 instance service discovery.
type EC2SDConfig struct {
Region string `yaml:"region,omitempty"`
Endpoint string `yaml:"endpoint,omitempty"`
AccessKey string `yaml:"access_key,omitempty"`
SecretKey string `yaml:"secret_key,omitempty"`
Profile string `yaml:"profile,omitempty"`
RoleArn string `yaml:"role_arn,omitempty"`
RefreshInterval Duration `yaml:"refresh_interval,omitempty"`
Port int `yaml:"port,omitempty"`
Filters []*Filter `yaml:"filters,omitempty"`
}
// HTTPSDConfig is the configuration for HTTP service discovery.
type HTTPSDConfig struct {
HTTPClientConfig HTTPClientConfig `yaml:",inline"`
RefreshInterval Duration `yaml:"refresh_interval,omitempty"`
URL string `yaml:"url,omitempty"`
}
// GceSDConfig is the configuration for Google cloud GCE instance service discovery
type GceSDConfig struct {
Project string `yaml:"project"`
Zone string `yaml:"zone"`
Filter string `yaml:"filter,omitempty"`
RefreshInterval Duration `yaml:"refresh_interval,omitempty"`
Port int `yaml:"port,omitempty"`
TagSeprator string `yaml:"tag_separator,omitempty"`
}
// AzureSDConfig is the configuration for Azure cloud service discovery
type AzureSDConfig struct {
Environment string `yaml:"environment,omitempty"`
SubscriptionID string `yaml:"subscription_id"`
TenantID string `yaml:"tenant_id,omitempty"`
ClientID string `yaml:"client_id,omitempty"`
ClientSecret string `yaml:"client_secret,omitempty"`
RefreshInterval Duration `yaml:"refresh_interval,omitempty"`
Port int `yaml:"port,omitempty"`
}
// DigitaloceanSDConfig is the configuration for digitalocean droplet service discovery
type DigitaloceanSDConfig struct {
HTTPClientConfig HTTPClientConfig `yaml:",inline"`
RefreshInterval Duration `yaml:"refresh_interval,omitempty"`
Port int `yaml:"port,omitempty"`
}
// ConsulSDConfig is the configuration for the consul cataloge service discovery
type ConsulSDConfig struct {
Server string `yaml:"server,omitempty"`
Token string `yaml:"token"`
Datacenter string `yaml:"datacenter"`
Scheme string `yaml:"scheme,omitempty"`
Username string `yaml:"username"`
Password string `yaml:"password"`
TLSConfig TLSConfig `yaml:"tls_config,omitempty"`
Services []string `yaml:"services,omitempty"`
Tags []string `yaml:"tags,omitempty"`
NodeMeta map[string]string `yaml:"node_meta,omitempty"`
TagSeprator string `yaml:"tag_seprator,omitempty"`
AllowStale *bool `yaml:"allow_stale,omitempty"`
RefreshInterval Duration `yaml:"refresh_interval,omitempty"`
}
// DockerswarmSDConfig is the configuration for service discovery of docker services, tasks or nodes.
type DockerswarmSDConfig struct {
HTTPClientConfig HTTPClientConfig `yaml:",inline"`
Host string `yaml:"host"`
Role string `yaml:"role"`
RefreshInterval Duration `yaml:"refresh_interval,omitempty"`
Port int `yaml:"port,omitempty"`
Filters []*Filter `yaml:"filters,omitempty"`
}
// DNSSDConfig is configuration for dns based service discovery.
type DNSSDConfig struct {
Names []string `yaml:"names"`
Type string `yaml:"type,omitempty"`
RefreshInterval Duration `yaml:"refresh_interval,omitempty"`
Port int `yaml:"port,omitempty"`
}
// Filter to limit service discovery
type Filter struct {
Name string `yaml:"name"`
Values []string `yaml:"values"`
}