2015-08-20 04:03:56 -07:00
|
|
|
// 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.
|
|
|
|
|
2013-02-13 16:04:07 -08:00
|
|
|
package config
|
|
|
|
|
|
|
|
import (
|
2015-06-06 00:55:22 -07:00
|
|
|
"encoding/json"
|
|
|
|
"io/ioutil"
|
2015-09-03 02:47:09 -07:00
|
|
|
"net/url"
|
2017-07-08 21:34:50 -07:00
|
|
|
"path/filepath"
|
2017-05-29 04:46:23 -07:00
|
|
|
"regexp"
|
2013-02-13 16:04:07 -08:00
|
|
|
"strings"
|
|
|
|
"testing"
|
2015-05-07 01:55:03 -07:00
|
|
|
"time"
|
|
|
|
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 12:01:34 -08:00
|
|
|
"github.com/prometheus/prometheus/discovery/azure"
|
|
|
|
"github.com/prometheus/prometheus/discovery/consul"
|
|
|
|
"github.com/prometheus/prometheus/discovery/dns"
|
|
|
|
"github.com/prometheus/prometheus/discovery/ec2"
|
|
|
|
"github.com/prometheus/prometheus/discovery/file"
|
|
|
|
"github.com/prometheus/prometheus/discovery/kubernetes"
|
|
|
|
"github.com/prometheus/prometheus/discovery/marathon"
|
|
|
|
"github.com/prometheus/prometheus/discovery/targetgroup"
|
|
|
|
"github.com/prometheus/prometheus/discovery/triton"
|
|
|
|
"github.com/prometheus/prometheus/discovery/zookeeper"
|
|
|
|
|
2018-01-11 07:10:25 -08:00
|
|
|
config_util "github.com/prometheus/common/config"
|
2015-08-20 08:18:46 -07:00
|
|
|
"github.com/prometheus/common/model"
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 12:01:34 -08:00
|
|
|
sd_config "github.com/prometheus/prometheus/discovery/config"
|
2017-10-10 03:29:15 -07:00
|
|
|
"github.com/prometheus/prometheus/util/testutil"
|
2015-08-22 00:42:45 -07:00
|
|
|
"gopkg.in/yaml.v2"
|
2013-02-13 16:04:07 -08:00
|
|
|
)
|
|
|
|
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 12:01:34 -08:00
|
|
|
func mustParseURL(u string) *config_util.URL {
|
2017-02-13 12:43:20 -08:00
|
|
|
parsed, err := url.Parse(u)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 12:01:34 -08:00
|
|
|
return &config_util.URL{URL: parsed}
|
2017-02-13 12:43:20 -08:00
|
|
|
}
|
|
|
|
|
2015-06-04 08:03:12 -07:00
|
|
|
var expectedConf = &Config{
|
2015-06-07 08:40:22 -07:00
|
|
|
GlobalConfig: GlobalConfig{
|
2016-01-29 06:23:11 -08:00
|
|
|
ScrapeInterval: model.Duration(15 * time.Second),
|
2015-05-07 01:55:03 -07:00
|
|
|
ScrapeTimeout: DefaultGlobalConfig.ScrapeTimeout,
|
2016-01-29 06:23:11 -08:00
|
|
|
EvaluationInterval: model.Duration(30 * time.Second),
|
2015-05-07 01:55:03 -07:00
|
|
|
|
2015-09-29 08:51:03 -07:00
|
|
|
ExternalLabels: model.LabelSet{
|
2015-05-07 01:55:03 -07:00
|
|
|
"monitor": "codelab",
|
|
|
|
"foo": "bar",
|
|
|
|
},
|
2015-06-04 08:03:12 -07:00
|
|
|
},
|
2015-05-07 01:55:03 -07:00
|
|
|
|
|
|
|
RuleFiles: []string{
|
2017-07-08 21:34:50 -07:00
|
|
|
filepath.FromSlash("testdata/first.rules"),
|
|
|
|
filepath.FromSlash("testdata/my/*.rules"),
|
2015-05-07 01:55:03 -07:00
|
|
|
},
|
|
|
|
|
2017-02-13 12:43:20 -08:00
|
|
|
RemoteWriteConfigs: []*RemoteWriteConfig{
|
|
|
|
{
|
|
|
|
URL: mustParseURL("http://remote1/push"),
|
|
|
|
RemoteTimeout: model.Duration(30 * time.Second),
|
|
|
|
WriteRelabelConfigs: []*RelabelConfig{
|
|
|
|
{
|
|
|
|
SourceLabels: model.LabelNames{"__name__"},
|
|
|
|
Separator: ";",
|
|
|
|
Regex: MustNewRegexp("expensive.*"),
|
|
|
|
Replacement: "$1",
|
|
|
|
Action: RelabelDrop,
|
|
|
|
},
|
2016-10-01 08:42:43 -07:00
|
|
|
},
|
2017-08-01 03:00:40 -07:00
|
|
|
QueueConfig: DefaultQueueConfig,
|
2016-10-01 08:42:43 -07:00
|
|
|
},
|
2017-02-13 12:43:20 -08:00
|
|
|
{
|
|
|
|
URL: mustParseURL("http://remote2/push"),
|
|
|
|
RemoteTimeout: model.Duration(30 * time.Second),
|
2017-08-01 03:00:40 -07:00
|
|
|
QueueConfig: DefaultQueueConfig,
|
2017-02-13 12:43:20 -08:00
|
|
|
},
|
2016-10-01 08:42:43 -07:00
|
|
|
},
|
|
|
|
|
2017-10-18 04:08:14 -07:00
|
|
|
RemoteReadConfigs: []*RemoteReadConfig{
|
|
|
|
{
|
|
|
|
URL: mustParseURL("http://remote1/read"),
|
|
|
|
RemoteTimeout: model.Duration(1 * time.Minute),
|
|
|
|
ReadRecent: true,
|
|
|
|
},
|
|
|
|
{
|
2017-11-11 17:23:20 -08:00
|
|
|
URL: mustParseURL("http://remote3/read"),
|
|
|
|
RemoteTimeout: model.Duration(1 * time.Minute),
|
|
|
|
ReadRecent: false,
|
|
|
|
RequiredMatchers: model.LabelSet{"job": "special"},
|
2017-10-18 04:08:14 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2015-05-07 01:55:03 -07:00
|
|
|
ScrapeConfigs: []*ScrapeConfig{
|
2015-06-04 08:03:12 -07:00
|
|
|
{
|
2015-05-07 01:55:03 -07:00
|
|
|
JobName: "prometheus",
|
|
|
|
|
2015-06-22 13:35:19 -07:00
|
|
|
HonorLabels: true,
|
2016-01-29 06:23:11 -08:00
|
|
|
ScrapeInterval: model.Duration(15 * time.Second),
|
2015-05-07 01:55:03 -07:00
|
|
|
ScrapeTimeout: DefaultGlobalConfig.ScrapeTimeout,
|
|
|
|
|
|
|
|
MetricsPath: DefaultScrapeConfig.MetricsPath,
|
|
|
|
Scheme: DefaultScrapeConfig.Scheme,
|
|
|
|
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 12:01:34 -08:00
|
|
|
HTTPClientConfig: config_util.HTTPClientConfig{
|
2017-07-08 21:34:50 -07:00
|
|
|
BearerTokenFile: filepath.FromSlash("testdata/valid_token_file"),
|
2016-11-23 03:41:19 -08:00
|
|
|
},
|
2015-08-05 09:04:34 -07:00
|
|
|
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 12:01:34 -08:00
|
|
|
ServiceDiscoveryConfig: sd_config.ServiceDiscoveryConfig{
|
|
|
|
StaticConfigs: []*targetgroup.Group{
|
2016-11-23 03:41:19 -08:00
|
|
|
{
|
|
|
|
Targets: []model.LabelSet{
|
|
|
|
{model.AddressLabel: "localhost:9090"},
|
|
|
|
{model.AddressLabel: "localhost:9191"},
|
|
|
|
},
|
|
|
|
Labels: model.LabelSet{
|
|
|
|
"my": "label",
|
|
|
|
"your": "label",
|
|
|
|
},
|
2018-06-13 08:34:59 -07:00
|
|
|
Source: "0",
|
2015-05-07 01:55:03 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 12:01:34 -08:00
|
|
|
FileSDConfigs: []*file.SDConfig{
|
2016-11-23 03:41:19 -08:00
|
|
|
{
|
2017-07-04 02:06:02 -07:00
|
|
|
Files: []string{"testdata/foo/*.slow.json", "testdata/foo/*.slow.yml", "testdata/single/file.yml"},
|
2016-11-23 03:41:19 -08:00
|
|
|
RefreshInterval: model.Duration(10 * time.Minute),
|
|
|
|
},
|
|
|
|
{
|
2017-07-04 02:06:02 -07:00
|
|
|
Files: []string{"testdata/bar/*.yaml"},
|
2016-11-23 03:41:19 -08:00
|
|
|
RefreshInterval: model.Duration(5 * time.Minute),
|
|
|
|
},
|
2015-06-04 08:03:12 -07:00
|
|
|
},
|
2015-05-13 02:28:04 -07:00
|
|
|
},
|
|
|
|
|
2015-05-07 01:55:03 -07:00
|
|
|
RelabelConfigs: []*RelabelConfig{
|
2015-06-04 08:03:12 -07:00
|
|
|
{
|
2016-02-14 13:20:39 -08:00
|
|
|
SourceLabels: model.LabelNames{"job", "__meta_dns_name"},
|
2015-05-07 01:55:03 -07:00
|
|
|
TargetLabel: "job",
|
|
|
|
Separator: ";",
|
2015-09-01 06:05:14 -07:00
|
|
|
Regex: MustNewRegexp("(.*)some-[regex]"),
|
2015-05-07 01:55:03 -07:00
|
|
|
Replacement: "foo-${1}",
|
|
|
|
Action: RelabelReplace,
|
2015-11-16 04:16:13 -08:00
|
|
|
}, {
|
|
|
|
SourceLabels: model.LabelNames{"abc"},
|
|
|
|
TargetLabel: "cde",
|
|
|
|
Separator: ";",
|
|
|
|
Regex: DefaultRelabelConfig.Regex,
|
|
|
|
Replacement: DefaultRelabelConfig.Replacement,
|
|
|
|
Action: RelabelReplace,
|
|
|
|
}, {
|
|
|
|
TargetLabel: "abc",
|
|
|
|
Separator: ";",
|
|
|
|
Regex: DefaultRelabelConfig.Regex,
|
|
|
|
Replacement: "static",
|
|
|
|
Action: RelabelReplace,
|
2016-11-03 06:34:15 -07:00
|
|
|
}, {
|
|
|
|
TargetLabel: "abc",
|
|
|
|
Separator: ";",
|
|
|
|
Regex: MustNewRegexp(""),
|
|
|
|
Replacement: "static",
|
|
|
|
Action: RelabelReplace,
|
2015-06-04 08:03:12 -07:00
|
|
|
},
|
2015-05-07 01:55:03 -07:00
|
|
|
},
|
2015-06-04 08:03:12 -07:00
|
|
|
},
|
|
|
|
{
|
2017-05-29 04:46:23 -07:00
|
|
|
|
2015-05-07 01:55:03 -07:00
|
|
|
JobName: "service-x",
|
|
|
|
|
2016-01-29 06:23:11 -08:00
|
|
|
ScrapeInterval: model.Duration(50 * time.Second),
|
|
|
|
ScrapeTimeout: model.Duration(5 * time.Second),
|
2016-12-16 07:08:50 -08:00
|
|
|
SampleLimit: 1000,
|
2015-05-07 01:55:03 -07:00
|
|
|
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 12:01:34 -08:00
|
|
|
HTTPClientConfig: config_util.HTTPClientConfig{
|
|
|
|
BasicAuth: &config_util.BasicAuth{
|
2016-11-23 03:41:19 -08:00
|
|
|
Username: "admin_name",
|
2017-05-29 04:46:23 -07:00
|
|
|
Password: "multiline\nmysecret\ntest",
|
2016-11-23 03:41:19 -08:00
|
|
|
},
|
2015-05-15 03:47:50 -07:00
|
|
|
},
|
2015-05-07 01:55:03 -07:00
|
|
|
MetricsPath: "/my_path",
|
2015-05-15 03:47:50 -07:00
|
|
|
Scheme: "https",
|
2015-05-07 01:55:03 -07:00
|
|
|
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 12:01:34 -08:00
|
|
|
ServiceDiscoveryConfig: sd_config.ServiceDiscoveryConfig{
|
|
|
|
DNSSDConfigs: []*dns.SDConfig{
|
2016-11-23 03:41:19 -08:00
|
|
|
{
|
|
|
|
Names: []string{
|
|
|
|
"first.dns.address.domain.com",
|
|
|
|
"second.dns.address.domain.com",
|
|
|
|
},
|
|
|
|
RefreshInterval: model.Duration(15 * time.Second),
|
|
|
|
Type: "SRV",
|
2015-05-07 01:55:03 -07:00
|
|
|
},
|
2016-11-23 03:41:19 -08:00
|
|
|
{
|
|
|
|
Names: []string{
|
|
|
|
"first.dns.address.domain.com",
|
|
|
|
},
|
|
|
|
RefreshInterval: model.Duration(30 * time.Second),
|
|
|
|
Type: "SRV",
|
2015-05-07 01:55:03 -07:00
|
|
|
},
|
2015-06-04 08:03:12 -07:00
|
|
|
},
|
2015-05-07 01:55:03 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
RelabelConfigs: []*RelabelConfig{
|
2015-06-04 08:03:12 -07:00
|
|
|
{
|
2015-08-20 08:18:46 -07:00
|
|
|
SourceLabels: model.LabelNames{"job"},
|
2015-09-01 06:05:14 -07:00
|
|
|
Regex: MustNewRegexp("(.*)some-[regex]"),
|
2015-05-07 01:55:03 -07:00
|
|
|
Separator: ";",
|
2015-11-16 04:16:13 -08:00
|
|
|
Replacement: DefaultRelabelConfig.Replacement,
|
2015-05-07 01:55:03 -07:00
|
|
|
Action: RelabelDrop,
|
2015-06-04 08:03:12 -07:00
|
|
|
},
|
2015-06-24 00:07:17 -07:00
|
|
|
{
|
2015-08-20 08:18:46 -07:00
|
|
|
SourceLabels: model.LabelNames{"__address__"},
|
2015-08-13 02:39:21 -07:00
|
|
|
TargetLabel: "__tmp_hash",
|
2015-11-16 04:16:13 -08:00
|
|
|
Regex: DefaultRelabelConfig.Regex,
|
|
|
|
Replacement: DefaultRelabelConfig.Replacement,
|
2015-06-24 00:07:17 -07:00
|
|
|
Modulus: 8,
|
|
|
|
Separator: ";",
|
|
|
|
Action: RelabelHashMod,
|
|
|
|
},
|
|
|
|
{
|
2015-08-20 08:18:46 -07:00
|
|
|
SourceLabels: model.LabelNames{"__tmp_hash"},
|
2015-09-01 06:05:14 -07:00
|
|
|
Regex: MustNewRegexp("1"),
|
2015-06-24 00:07:17 -07:00
|
|
|
Separator: ";",
|
2015-11-16 04:16:13 -08:00
|
|
|
Replacement: DefaultRelabelConfig.Replacement,
|
2015-06-24 00:07:17 -07:00
|
|
|
Action: RelabelKeep,
|
|
|
|
},
|
2015-09-21 12:41:19 -07:00
|
|
|
{
|
2015-11-16 04:16:13 -08:00
|
|
|
Regex: MustNewRegexp("1"),
|
|
|
|
Separator: ";",
|
|
|
|
Replacement: DefaultRelabelConfig.Replacement,
|
|
|
|
Action: RelabelLabelMap,
|
2015-09-21 12:41:19 -07:00
|
|
|
},
|
2016-12-14 02:17:42 -08:00
|
|
|
{
|
|
|
|
Regex: MustNewRegexp("d"),
|
|
|
|
Separator: ";",
|
|
|
|
Replacement: DefaultRelabelConfig.Replacement,
|
|
|
|
Action: RelabelLabelDrop,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Regex: MustNewRegexp("k"),
|
|
|
|
Separator: ";",
|
|
|
|
Replacement: DefaultRelabelConfig.Replacement,
|
|
|
|
Action: RelabelLabelKeep,
|
|
|
|
},
|
2015-05-07 01:55:03 -07:00
|
|
|
},
|
2015-06-12 14:16:13 -07:00
|
|
|
MetricRelabelConfigs: []*RelabelConfig{
|
|
|
|
{
|
2015-08-20 08:18:46 -07:00
|
|
|
SourceLabels: model.LabelNames{"__name__"},
|
2015-09-01 06:05:14 -07:00
|
|
|
Regex: MustNewRegexp("expensive_metric.*"),
|
2015-06-12 14:16:13 -07:00
|
|
|
Separator: ";",
|
2015-11-16 04:16:13 -08:00
|
|
|
Replacement: DefaultRelabelConfig.Replacement,
|
2015-06-12 14:16:13 -07:00
|
|
|
Action: RelabelDrop,
|
|
|
|
},
|
|
|
|
},
|
2015-06-04 08:03:12 -07:00
|
|
|
},
|
2015-06-12 04:39:12 -07:00
|
|
|
{
|
|
|
|
JobName: "service-y",
|
|
|
|
|
2016-01-29 06:23:11 -08:00
|
|
|
ScrapeInterval: model.Duration(15 * time.Second),
|
2015-06-12 04:39:12 -07:00
|
|
|
ScrapeTimeout: DefaultGlobalConfig.ScrapeTimeout,
|
|
|
|
|
|
|
|
MetricsPath: DefaultScrapeConfig.MetricsPath,
|
|
|
|
Scheme: DefaultScrapeConfig.Scheme,
|
|
|
|
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 12:01:34 -08:00
|
|
|
ServiceDiscoveryConfig: sd_config.ServiceDiscoveryConfig{
|
|
|
|
ConsulSDConfigs: []*consul.SDConfig{
|
2016-11-23 03:41:19 -08:00
|
|
|
{
|
2018-03-23 07:48:43 -07:00
|
|
|
Server: "localhost:1234",
|
|
|
|
Token: "mysecret",
|
|
|
|
Services: []string{"nginx", "cache", "mysql"},
|
|
|
|
ServiceTag: "canary",
|
|
|
|
NodeMeta: map[string]string{"rack": "123"},
|
|
|
|
TagSeparator: consul.DefaultSDConfig.TagSeparator,
|
|
|
|
Scheme: "https",
|
|
|
|
RefreshInterval: consul.DefaultSDConfig.RefreshInterval,
|
|
|
|
AllowStale: true,
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 12:01:34 -08:00
|
|
|
TLSConfig: config_util.TLSConfig{
|
2017-07-08 21:34:50 -07:00
|
|
|
CertFile: filepath.FromSlash("testdata/valid_cert_file"),
|
|
|
|
KeyFile: filepath.FromSlash("testdata/valid_key_file"),
|
|
|
|
CAFile: filepath.FromSlash("testdata/valid_ca_file"),
|
2017-03-07 06:47:40 -08:00
|
|
|
InsecureSkipVerify: false,
|
|
|
|
},
|
2016-11-23 03:41:19 -08:00
|
|
|
},
|
2015-06-12 04:39:12 -07:00
|
|
|
},
|
|
|
|
},
|
2016-10-18 15:19:19 -07:00
|
|
|
|
|
|
|
RelabelConfigs: []*RelabelConfig{
|
|
|
|
{
|
|
|
|
SourceLabels: model.LabelNames{"__meta_sd_consul_tags"},
|
|
|
|
Regex: MustNewRegexp("label:([^=]+)=([^,]+)"),
|
|
|
|
Separator: ",",
|
|
|
|
TargetLabel: "${1}",
|
|
|
|
Replacement: "${2}",
|
|
|
|
Action: RelabelReplace,
|
|
|
|
},
|
|
|
|
},
|
2015-06-12 04:39:12 -07:00
|
|
|
},
|
2015-07-22 08:48:22 -07:00
|
|
|
{
|
|
|
|
JobName: "service-z",
|
|
|
|
|
2016-01-29 06:23:11 -08:00
|
|
|
ScrapeInterval: model.Duration(15 * time.Second),
|
|
|
|
ScrapeTimeout: model.Duration(10 * time.Second),
|
2015-07-22 08:48:22 -07:00
|
|
|
|
|
|
|
MetricsPath: "/metrics",
|
|
|
|
Scheme: "http",
|
|
|
|
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 12:01:34 -08:00
|
|
|
HTTPClientConfig: config_util.HTTPClientConfig{
|
|
|
|
TLSConfig: config_util.TLSConfig{
|
2017-07-08 21:34:50 -07:00
|
|
|
CertFile: filepath.FromSlash("testdata/valid_cert_file"),
|
|
|
|
KeyFile: filepath.FromSlash("testdata/valid_key_file"),
|
2016-11-23 03:41:19 -08:00
|
|
|
},
|
2015-09-06 16:07:44 -07:00
|
|
|
|
2017-05-29 04:46:23 -07:00
|
|
|
BearerToken: "mysecret",
|
2016-11-23 03:41:19 -08:00
|
|
|
},
|
2015-07-22 08:48:22 -07:00
|
|
|
},
|
2015-07-18 14:23:58 -07:00
|
|
|
{
|
|
|
|
JobName: "service-kubernetes",
|
|
|
|
|
2016-01-29 06:23:11 -08:00
|
|
|
ScrapeInterval: model.Duration(15 * time.Second),
|
2015-07-18 14:23:58 -07:00
|
|
|
ScrapeTimeout: DefaultGlobalConfig.ScrapeTimeout,
|
|
|
|
|
|
|
|
MetricsPath: DefaultScrapeConfig.MetricsPath,
|
|
|
|
Scheme: DefaultScrapeConfig.Scheme,
|
|
|
|
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 12:01:34 -08:00
|
|
|
ServiceDiscoveryConfig: sd_config.ServiceDiscoveryConfig{
|
|
|
|
KubernetesSDConfigs: []*kubernetes.SDConfig{
|
2016-11-23 03:41:19 -08:00
|
|
|
{
|
|
|
|
APIServer: kubernetesSDHostURL(),
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 12:01:34 -08:00
|
|
|
Role: kubernetes.RoleEndpoint,
|
|
|
|
BasicAuth: &config_util.BasicAuth{
|
2016-11-23 03:41:19 -08:00
|
|
|
Username: "myusername",
|
2017-05-29 04:46:23 -07:00
|
|
|
Password: "mysecret",
|
2016-11-23 03:41:19 -08:00
|
|
|
},
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 12:01:34 -08:00
|
|
|
NamespaceDiscovery: kubernetes.NamespaceDiscovery{},
|
2017-04-19 05:36:34 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
JobName: "service-kubernetes-namespaces",
|
|
|
|
|
|
|
|
ScrapeInterval: model.Duration(15 * time.Second),
|
|
|
|
ScrapeTimeout: DefaultGlobalConfig.ScrapeTimeout,
|
|
|
|
|
|
|
|
MetricsPath: DefaultScrapeConfig.MetricsPath,
|
|
|
|
Scheme: DefaultScrapeConfig.Scheme,
|
|
|
|
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 12:01:34 -08:00
|
|
|
ServiceDiscoveryConfig: sd_config.ServiceDiscoveryConfig{
|
|
|
|
KubernetesSDConfigs: []*kubernetes.SDConfig{
|
2017-04-19 05:36:34 -07:00
|
|
|
{
|
|
|
|
APIServer: kubernetesSDHostURL(),
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 12:01:34 -08:00
|
|
|
Role: kubernetes.RoleEndpoint,
|
|
|
|
NamespaceDiscovery: kubernetes.NamespaceDiscovery{
|
2017-04-19 05:36:34 -07:00
|
|
|
Names: []string{
|
|
|
|
"default",
|
|
|
|
},
|
|
|
|
},
|
2015-10-23 08:47:10 -07:00
|
|
|
},
|
2015-07-18 14:23:58 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2015-09-02 06:08:37 -07:00
|
|
|
{
|
|
|
|
JobName: "service-marathon",
|
|
|
|
|
2016-01-29 06:23:11 -08:00
|
|
|
ScrapeInterval: model.Duration(15 * time.Second),
|
2015-09-02 06:08:37 -07:00
|
|
|
ScrapeTimeout: DefaultGlobalConfig.ScrapeTimeout,
|
|
|
|
|
|
|
|
MetricsPath: DefaultScrapeConfig.MetricsPath,
|
|
|
|
Scheme: DefaultScrapeConfig.Scheme,
|
|
|
|
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 12:01:34 -08:00
|
|
|
ServiceDiscoveryConfig: sd_config.ServiceDiscoveryConfig{
|
|
|
|
MarathonSDConfigs: []*marathon.SDConfig{
|
2016-11-23 03:41:19 -08:00
|
|
|
{
|
|
|
|
Servers: []string{
|
|
|
|
"https://marathon.example.com:443",
|
|
|
|
},
|
|
|
|
RefreshInterval: model.Duration(30 * time.Second),
|
2018-04-05 01:08:18 -07:00
|
|
|
AuthToken: config_util.Secret("mysecret"),
|
|
|
|
HTTPClientConfig: config_util.HTTPClientConfig{
|
|
|
|
TLSConfig: config_util.TLSConfig{
|
|
|
|
CertFile: filepath.FromSlash("testdata/valid_cert_file"),
|
|
|
|
KeyFile: filepath.FromSlash("testdata/valid_key_file"),
|
|
|
|
},
|
2016-11-23 03:41:19 -08:00
|
|
|
},
|
2016-09-29 05:57:28 -07:00
|
|
|
},
|
2015-09-02 06:08:37 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2015-09-21 11:49:19 -07:00
|
|
|
{
|
|
|
|
JobName: "service-ec2",
|
|
|
|
|
2016-01-29 06:23:11 -08:00
|
|
|
ScrapeInterval: model.Duration(15 * time.Second),
|
2015-09-21 11:49:19 -07:00
|
|
|
ScrapeTimeout: DefaultGlobalConfig.ScrapeTimeout,
|
|
|
|
|
|
|
|
MetricsPath: DefaultScrapeConfig.MetricsPath,
|
|
|
|
Scheme: DefaultScrapeConfig.Scheme,
|
|
|
|
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 12:01:34 -08:00
|
|
|
ServiceDiscoveryConfig: sd_config.ServiceDiscoveryConfig{
|
|
|
|
EC2SDConfigs: []*ec2.SDConfig{
|
2016-11-23 03:41:19 -08:00
|
|
|
{
|
|
|
|
Region: "us-east-1",
|
|
|
|
AccessKey: "access",
|
2017-05-29 04:46:23 -07:00
|
|
|
SecretKey: "mysecret",
|
2016-11-23 03:41:19 -08:00
|
|
|
Profile: "profile",
|
|
|
|
RefreshInterval: model.Duration(60 * time.Second),
|
|
|
|
Port: 80,
|
2018-03-30 23:51:11 -07:00
|
|
|
Filters: []*ec2.Filter{
|
|
|
|
{
|
|
|
|
Name: "tag:environment",
|
|
|
|
Values: []string{"prod"},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "tag:service",
|
|
|
|
Values: []string{"web", "db"},
|
|
|
|
},
|
|
|
|
},
|
2016-11-23 03:41:19 -08:00
|
|
|
},
|
2015-09-21 11:49:19 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2016-04-06 20:47:02 -07:00
|
|
|
{
|
|
|
|
JobName: "service-azure",
|
|
|
|
|
|
|
|
ScrapeInterval: model.Duration(15 * time.Second),
|
|
|
|
ScrapeTimeout: DefaultGlobalConfig.ScrapeTimeout,
|
|
|
|
|
|
|
|
MetricsPath: DefaultScrapeConfig.MetricsPath,
|
|
|
|
Scheme: DefaultScrapeConfig.Scheme,
|
|
|
|
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 12:01:34 -08:00
|
|
|
ServiceDiscoveryConfig: sd_config.ServiceDiscoveryConfig{
|
|
|
|
AzureSDConfigs: []*azure.SDConfig{
|
2016-11-23 03:41:19 -08:00
|
|
|
{
|
2018-09-04 08:55:40 -07:00
|
|
|
Environment: "AzurePublicCloud",
|
2016-11-23 03:41:19 -08:00
|
|
|
SubscriptionID: "11AAAA11-A11A-111A-A111-1111A1111A11",
|
|
|
|
TenantID: "BBBB222B-B2B2-2B22-B222-2BB2222BB2B2",
|
|
|
|
ClientID: "333333CC-3C33-3333-CCC3-33C3CCCCC33C",
|
2017-05-29 04:46:23 -07:00
|
|
|
ClientSecret: "mysecret",
|
2016-11-23 03:41:19 -08:00
|
|
|
RefreshInterval: model.Duration(5 * time.Minute),
|
|
|
|
Port: 9100,
|
|
|
|
},
|
2016-04-06 20:47:02 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2016-01-09 15:34:32 -08:00
|
|
|
{
|
|
|
|
JobName: "service-nerve",
|
|
|
|
|
2016-01-29 06:23:11 -08:00
|
|
|
ScrapeInterval: model.Duration(15 * time.Second),
|
2016-01-09 15:34:32 -08:00
|
|
|
ScrapeTimeout: DefaultGlobalConfig.ScrapeTimeout,
|
|
|
|
|
|
|
|
MetricsPath: DefaultScrapeConfig.MetricsPath,
|
|
|
|
Scheme: DefaultScrapeConfig.Scheme,
|
|
|
|
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 12:01:34 -08:00
|
|
|
ServiceDiscoveryConfig: sd_config.ServiceDiscoveryConfig{
|
|
|
|
NerveSDConfigs: []*zookeeper.NerveSDConfig{
|
2016-11-23 03:41:19 -08:00
|
|
|
{
|
|
|
|
Servers: []string{"localhost"},
|
|
|
|
Paths: []string{"/monitoring"},
|
|
|
|
Timeout: model.Duration(10 * time.Second),
|
|
|
|
},
|
2016-01-09 15:34:32 -08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2016-09-14 23:00:14 -07:00
|
|
|
{
|
|
|
|
JobName: "0123service-xxx",
|
|
|
|
|
|
|
|
ScrapeInterval: model.Duration(15 * time.Second),
|
|
|
|
ScrapeTimeout: DefaultGlobalConfig.ScrapeTimeout,
|
|
|
|
|
|
|
|
MetricsPath: DefaultScrapeConfig.MetricsPath,
|
|
|
|
Scheme: DefaultScrapeConfig.Scheme,
|
|
|
|
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 12:01:34 -08:00
|
|
|
ServiceDiscoveryConfig: sd_config.ServiceDiscoveryConfig{
|
|
|
|
StaticConfigs: []*targetgroup.Group{
|
2016-11-23 03:41:19 -08:00
|
|
|
{
|
|
|
|
Targets: []model.LabelSet{
|
|
|
|
{model.AddressLabel: "localhost:9090"},
|
|
|
|
},
|
2018-06-13 08:34:59 -07:00
|
|
|
Source: "0",
|
2016-09-14 23:00:14 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
JobName: "測試",
|
|
|
|
|
|
|
|
ScrapeInterval: model.Duration(15 * time.Second),
|
|
|
|
ScrapeTimeout: DefaultGlobalConfig.ScrapeTimeout,
|
|
|
|
|
|
|
|
MetricsPath: DefaultScrapeConfig.MetricsPath,
|
|
|
|
Scheme: DefaultScrapeConfig.Scheme,
|
|
|
|
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 12:01:34 -08:00
|
|
|
ServiceDiscoveryConfig: sd_config.ServiceDiscoveryConfig{
|
|
|
|
StaticConfigs: []*targetgroup.Group{
|
2016-11-23 03:41:19 -08:00
|
|
|
{
|
|
|
|
Targets: []model.LabelSet{
|
|
|
|
{model.AddressLabel: "localhost:9090"},
|
|
|
|
},
|
2018-06-13 08:34:59 -07:00
|
|
|
Source: "0",
|
2016-09-14 23:00:14 -07:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2016-12-27 18:16:47 -08:00
|
|
|
{
|
|
|
|
JobName: "service-triton",
|
|
|
|
|
|
|
|
ScrapeInterval: model.Duration(15 * time.Second),
|
|
|
|
ScrapeTimeout: DefaultGlobalConfig.ScrapeTimeout,
|
|
|
|
|
|
|
|
MetricsPath: DefaultScrapeConfig.MetricsPath,
|
|
|
|
Scheme: DefaultScrapeConfig.Scheme,
|
|
|
|
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 12:01:34 -08:00
|
|
|
ServiceDiscoveryConfig: sd_config.ServiceDiscoveryConfig{
|
|
|
|
TritonSDConfigs: []*triton.SDConfig{
|
2016-12-27 18:16:47 -08:00
|
|
|
{
|
|
|
|
|
|
|
|
Account: "testAccount",
|
|
|
|
DNSSuffix: "triton.example.com",
|
|
|
|
Endpoint: "triton.example.com",
|
|
|
|
Port: 9163,
|
|
|
|
RefreshInterval: model.Duration(60 * time.Second),
|
|
|
|
Version: 1,
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 12:01:34 -08:00
|
|
|
TLSConfig: config_util.TLSConfig{
|
2016-12-27 18:16:47 -08:00
|
|
|
CertFile: "testdata/valid_cert_file",
|
|
|
|
KeyFile: "testdata/valid_key_file",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2015-05-07 01:55:03 -07:00
|
|
|
},
|
2016-11-23 03:42:33 -08:00
|
|
|
AlertingConfig: AlertingConfig{
|
2016-11-24 06:17:50 -08:00
|
|
|
AlertmanagerConfigs: []*AlertmanagerConfig{
|
2016-11-23 03:42:33 -08:00
|
|
|
{
|
|
|
|
Scheme: "https",
|
2018-08-24 07:55:21 -07:00
|
|
|
Timeout: model.Duration(10 * time.Second),
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 12:01:34 -08:00
|
|
|
ServiceDiscoveryConfig: sd_config.ServiceDiscoveryConfig{
|
|
|
|
StaticConfigs: []*targetgroup.Group{
|
2016-11-23 03:42:33 -08:00
|
|
|
{
|
|
|
|
Targets: []model.LabelSet{
|
|
|
|
{model.AddressLabel: "1.2.3.4:9093"},
|
|
|
|
{model.AddressLabel: "1.2.3.5:9093"},
|
|
|
|
{model.AddressLabel: "1.2.3.6:9093"},
|
|
|
|
},
|
2018-06-13 08:34:59 -07:00
|
|
|
Source: "0",
|
2016-11-23 03:42:33 -08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2015-06-04 08:03:12 -07:00
|
|
|
original: "",
|
|
|
|
}
|
2015-05-07 01:55:03 -07:00
|
|
|
|
|
|
|
func TestLoadConfig(t *testing.T) {
|
2015-06-07 08:40:22 -07:00
|
|
|
// Parse a valid file that sets a global scrape timeout. This tests whether parsing
|
|
|
|
// an overwritten default field in the global config permanently changes the default.
|
2017-10-10 03:29:15 -07:00
|
|
|
_, err := LoadFile("testdata/global_timeout.good.yml")
|
|
|
|
testutil.Ok(t, err)
|
2015-06-07 08:40:22 -07:00
|
|
|
|
2015-08-05 09:30:37 -07:00
|
|
|
c, err := LoadFile("testdata/conf.good.yml")
|
2017-10-10 03:29:15 -07:00
|
|
|
testutil.Ok(t, err)
|
2015-07-18 14:23:58 -07:00
|
|
|
|
2015-05-07 01:55:03 -07:00
|
|
|
expectedConf.original = c.original
|
2017-10-10 03:29:15 -07:00
|
|
|
testutil.Equals(t, expectedConf, c)
|
2017-05-11 08:09:24 -07:00
|
|
|
}
|
2015-07-06 05:25:20 -07:00
|
|
|
|
2017-05-11 08:09:24 -07:00
|
|
|
// YAML marshalling must not reveal authentication credentials.
|
|
|
|
func TestElideSecrets(t *testing.T) {
|
|
|
|
c, err := LoadFile("testdata/conf.good.yml")
|
2017-10-10 03:29:15 -07:00
|
|
|
testutil.Ok(t, err)
|
2017-05-29 04:46:23 -07:00
|
|
|
|
2017-05-11 08:09:24 -07:00
|
|
|
secretRe := regexp.MustCompile(`\\u003csecret\\u003e|<secret>`)
|
|
|
|
|
|
|
|
config, err := yaml.Marshal(c)
|
2017-10-10 03:29:15 -07:00
|
|
|
testutil.Ok(t, err)
|
2017-05-11 08:09:24 -07:00
|
|
|
yamlConfig := string(config)
|
|
|
|
|
|
|
|
matches := secretRe.FindAllStringIndex(yamlConfig, -1)
|
2018-04-05 01:08:18 -07:00
|
|
|
testutil.Assert(t, len(matches) == 7, "wrong number of secret matches found")
|
2017-10-10 03:34:03 -07:00
|
|
|
testutil.Assert(t, !strings.Contains(yamlConfig, "mysecret"),
|
2017-10-10 03:29:15 -07:00
|
|
|
"yaml marshal reveals authentication credentials.")
|
2015-05-07 01:55:03 -07:00
|
|
|
}
|
|
|
|
|
2017-07-08 21:34:50 -07:00
|
|
|
func TestLoadConfigRuleFilesAbsolutePath(t *testing.T) {
|
|
|
|
// Parse a valid file that sets a rule files with an absolute path
|
|
|
|
c, err := LoadFile(ruleFilesConfigFile)
|
2017-10-10 03:29:15 -07:00
|
|
|
testutil.Ok(t, err)
|
2017-07-08 21:34:50 -07:00
|
|
|
|
|
|
|
ruleFilesExpectedConf.original = c.original
|
2017-10-10 03:29:15 -07:00
|
|
|
testutil.Equals(t, ruleFilesExpectedConf, c)
|
2017-07-08 21:34:50 -07:00
|
|
|
}
|
|
|
|
|
2015-05-07 01:55:03 -07:00
|
|
|
var expectedErrors = []struct {
|
|
|
|
filename string
|
|
|
|
errMsg string
|
2013-02-13 16:04:07 -08:00
|
|
|
}{
|
|
|
|
{
|
2015-05-07 01:55:03 -07:00
|
|
|
filename: "jobname.bad.yml",
|
2016-09-14 23:00:14 -07:00
|
|
|
errMsg: `job_name is empty`,
|
2013-02-13 16:04:07 -08:00
|
|
|
}, {
|
2015-05-07 01:55:03 -07:00
|
|
|
filename: "jobname_dup.bad.yml",
|
|
|
|
errMsg: `found multiple scrape configs with job name "prometheus"`,
|
2016-02-12 03:51:55 -08:00
|
|
|
}, {
|
|
|
|
filename: "scrape_interval.bad.yml",
|
|
|
|
errMsg: `scrape timeout greater than scrape interval`,
|
2013-06-11 13:59:27 -07:00
|
|
|
}, {
|
2015-05-07 01:55:03 -07:00
|
|
|
filename: "labelname.bad.yml",
|
|
|
|
errMsg: `"not$allowed" is not a valid label name`,
|
2015-06-06 00:55:22 -07:00
|
|
|
}, {
|
|
|
|
filename: "labelname2.bad.yml",
|
|
|
|
errMsg: `"not:allowed" is not a valid label name`,
|
2015-04-30 12:15:18 -07:00
|
|
|
}, {
|
2015-05-07 01:55:03 -07:00
|
|
|
filename: "regex.bad.yml",
|
|
|
|
errMsg: "error parsing regexp",
|
2015-06-24 00:07:17 -07:00
|
|
|
}, {
|
|
|
|
filename: "modulus_missing.bad.yml",
|
|
|
|
errMsg: "relabel configuration for hashmod requires non-zero modulus",
|
2017-03-18 14:32:08 -07:00
|
|
|
}, {
|
|
|
|
filename: "labelkeep.bad.yml",
|
|
|
|
errMsg: "labelkeep action requires only 'regex', and no other fields",
|
|
|
|
}, {
|
|
|
|
filename: "labelkeep2.bad.yml",
|
|
|
|
errMsg: "labelkeep action requires only 'regex', and no other fields",
|
|
|
|
}, {
|
|
|
|
filename: "labelkeep3.bad.yml",
|
|
|
|
errMsg: "labelkeep action requires only 'regex', and no other fields",
|
|
|
|
}, {
|
|
|
|
filename: "labelkeep4.bad.yml",
|
|
|
|
errMsg: "labelkeep action requires only 'regex', and no other fields",
|
|
|
|
}, {
|
|
|
|
filename: "labelkeep5.bad.yml",
|
|
|
|
errMsg: "labelkeep action requires only 'regex', and no other fields",
|
|
|
|
}, {
|
|
|
|
filename: "labeldrop.bad.yml",
|
|
|
|
errMsg: "labeldrop action requires only 'regex', and no other fields",
|
|
|
|
}, {
|
|
|
|
filename: "labeldrop2.bad.yml",
|
|
|
|
errMsg: "labeldrop action requires only 'regex', and no other fields",
|
|
|
|
}, {
|
|
|
|
filename: "labeldrop3.bad.yml",
|
|
|
|
errMsg: "labeldrop action requires only 'regex', and no other fields",
|
|
|
|
}, {
|
|
|
|
filename: "labeldrop4.bad.yml",
|
|
|
|
errMsg: "labeldrop action requires only 'regex', and no other fields",
|
|
|
|
}, {
|
|
|
|
filename: "labeldrop5.bad.yml",
|
|
|
|
errMsg: "labeldrop action requires only 'regex', and no other fields",
|
2018-02-21 02:02:22 -08:00
|
|
|
}, {
|
|
|
|
filename: "labelmap.bad.yml",
|
|
|
|
errMsg: "\"l-$1\" is invalid 'replacement' for labelmap action",
|
2015-05-27 22:36:21 -07:00
|
|
|
}, {
|
|
|
|
filename: "rules.bad.yml",
|
|
|
|
errMsg: "invalid rule file path",
|
2015-06-12 04:39:59 -07:00
|
|
|
}, {
|
|
|
|
filename: "unknown_attr.bad.yml",
|
2018-04-04 01:07:39 -07:00
|
|
|
errMsg: "field consult_sd_configs not found in type config.plain",
|
2015-07-22 08:48:22 -07:00
|
|
|
}, {
|
|
|
|
filename: "bearertoken.bad.yml",
|
|
|
|
errMsg: "at most one of bearer_token & bearer_token_file must be configured",
|
|
|
|
}, {
|
|
|
|
filename: "bearertoken_basicauth.bad.yml",
|
|
|
|
errMsg: "at most one of basic_auth, bearer_token & bearer_token_file must be configured",
|
2015-10-23 08:47:10 -07:00
|
|
|
}, {
|
|
|
|
filename: "kubernetes_bearertoken.bad.yml",
|
|
|
|
errMsg: "at most one of bearer_token & bearer_token_file must be configured",
|
2016-07-18 06:16:27 -07:00
|
|
|
}, {
|
|
|
|
filename: "kubernetes_role.bad.yml",
|
|
|
|
errMsg: "role",
|
2017-04-19 05:36:34 -07:00
|
|
|
}, {
|
|
|
|
filename: "kubernetes_namespace_discovery.bad.yml",
|
2018-04-04 01:07:39 -07:00
|
|
|
errMsg: "field foo not found in type kubernetes.plain",
|
2015-10-23 08:47:10 -07:00
|
|
|
}, {
|
|
|
|
filename: "kubernetes_bearertoken_basicauth.bad.yml",
|
|
|
|
errMsg: "at most one of basic_auth, bearer_token & bearer_token_file must be configured",
|
2015-09-02 06:08:37 -07:00
|
|
|
}, {
|
|
|
|
filename: "marathon_no_servers.bad.yml",
|
2018-04-05 01:08:18 -07:00
|
|
|
errMsg: "marathon_sd: must contain at least one Marathon server",
|
|
|
|
}, {
|
|
|
|
filename: "marathon_authtoken_authtokenfile.bad.yml",
|
|
|
|
errMsg: "marathon_sd: at most one of auth_token & auth_token_file must be configured",
|
|
|
|
}, {
|
|
|
|
filename: "marathon_authtoken_basicauth.bad.yml",
|
|
|
|
errMsg: "marathon_sd: at most one of basic_auth, auth_token & auth_token_file must be configured",
|
|
|
|
}, {
|
|
|
|
filename: "marathon_authtoken_bearertoken.bad.yml",
|
|
|
|
errMsg: "marathon_sd: at most one of bearer_token, bearer_token_file, auth_token & auth_token_file must be configured",
|
2015-11-07 06:25:51 -08:00
|
|
|
}, {
|
|
|
|
filename: "url_in_targetgroup.bad.yml",
|
|
|
|
errMsg: "\"http://bad\" is not a valid hostname",
|
2016-08-29 07:01:45 -07:00
|
|
|
}, {
|
|
|
|
filename: "target_label_missing.bad.yml",
|
|
|
|
errMsg: "relabel configuration for replace action requires 'target_label' value",
|
|
|
|
}, {
|
|
|
|
filename: "target_label_hashmod_missing.bad.yml",
|
|
|
|
errMsg: "relabel configuration for hashmod action requires 'target_label' value",
|
2017-05-30 11:58:06 -07:00
|
|
|
}, {
|
|
|
|
filename: "unknown_global_attr.bad.yml",
|
2018-04-04 01:07:39 -07:00
|
|
|
errMsg: "field nonexistent_field not found in type config.plain",
|
2017-08-07 00:49:45 -07:00
|
|
|
}, {
|
|
|
|
filename: "remote_read_url_missing.bad.yml",
|
|
|
|
errMsg: `url for remote_read is empty`,
|
|
|
|
}, {
|
|
|
|
filename: "remote_write_url_missing.bad.yml",
|
|
|
|
errMsg: `url for remote_write is empty`,
|
2013-12-03 02:59:38 -08:00
|
|
|
},
|
2018-03-30 23:51:11 -07:00
|
|
|
{
|
|
|
|
filename: "ec2_filters_empty_values.bad.yml",
|
|
|
|
errMsg: `EC2 SD configuration filter values cannot be empty`,
|
|
|
|
},
|
2018-04-04 01:07:39 -07:00
|
|
|
{
|
|
|
|
filename: "section_key_dup.bad.yml",
|
|
|
|
errMsg: "field scrape_configs already set in type config.plain",
|
|
|
|
},
|
2013-02-13 16:04:07 -08:00
|
|
|
}
|
|
|
|
|
2015-05-07 01:55:03 -07:00
|
|
|
func TestBadConfigs(t *testing.T) {
|
|
|
|
for _, ee := range expectedErrors {
|
2015-08-05 09:30:37 -07:00
|
|
|
_, err := LoadFile("testdata/" + ee.filename)
|
2017-10-16 08:27:52 -07:00
|
|
|
testutil.NotOk(t, err, "%s", ee.filename)
|
2017-10-10 03:29:15 -07:00
|
|
|
testutil.Assert(t, strings.Contains(err.Error(), ee.errMsg),
|
|
|
|
"Expected error for %s to contain %q but got: %s", ee.filename, ee.errMsg, err)
|
2013-02-13 16:04:07 -08:00
|
|
|
}
|
|
|
|
}
|
2015-06-06 00:55:22 -07:00
|
|
|
|
2018-04-04 01:07:39 -07:00
|
|
|
func TestBadStaticConfigsJSON(t *testing.T) {
|
2016-06-08 06:54:04 -07:00
|
|
|
content, err := ioutil.ReadFile("testdata/static_config.bad.json")
|
2017-10-10 03:29:15 -07:00
|
|
|
testutil.Ok(t, err)
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 12:01:34 -08:00
|
|
|
var tg targetgroup.Group
|
2015-06-06 00:55:22 -07:00
|
|
|
err = json.Unmarshal(content, &tg)
|
2017-10-16 08:27:52 -07:00
|
|
|
testutil.NotOk(t, err, "")
|
2018-04-04 01:07:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestBadStaticConfigsYML(t *testing.T) {
|
|
|
|
content, err := ioutil.ReadFile("testdata/static_config.bad.yml")
|
|
|
|
testutil.Ok(t, err)
|
|
|
|
var tg targetgroup.Group
|
|
|
|
err = yaml.UnmarshalStrict(content, &tg)
|
|
|
|
testutil.NotOk(t, err, "")
|
2015-06-06 00:55:22 -07:00
|
|
|
}
|
2015-07-17 07:12:33 -07:00
|
|
|
|
|
|
|
func TestEmptyConfig(t *testing.T) {
|
|
|
|
c, err := Load("")
|
2017-10-10 03:29:15 -07:00
|
|
|
testutil.Ok(t, err)
|
2015-07-17 07:12:33 -07:00
|
|
|
exp := DefaultConfig
|
2017-10-10 03:29:15 -07:00
|
|
|
testutil.Equals(t, exp, *c)
|
2015-07-17 07:12:33 -07:00
|
|
|
}
|
2015-07-17 10:58:34 -07:00
|
|
|
|
|
|
|
func TestEmptyGlobalBlock(t *testing.T) {
|
|
|
|
c, err := Load("global:\n")
|
2017-10-10 03:29:15 -07:00
|
|
|
testutil.Ok(t, err)
|
2015-07-17 10:58:34 -07:00
|
|
|
exp := DefaultConfig
|
|
|
|
exp.original = "global:\n"
|
2017-10-10 03:29:15 -07:00
|
|
|
testutil.Equals(t, exp, *c)
|
2015-07-17 10:58:34 -07:00
|
|
|
}
|
2015-09-03 02:47:09 -07:00
|
|
|
|
2016-10-19 03:32:42 -07:00
|
|
|
func TestTargetLabelValidity(t *testing.T) {
|
|
|
|
tests := []struct {
|
|
|
|
str string
|
|
|
|
valid bool
|
|
|
|
}{
|
|
|
|
{"-label", false},
|
|
|
|
{"label", true},
|
|
|
|
{"label${1}", true},
|
|
|
|
{"${1}label", true},
|
|
|
|
{"${1}", true},
|
|
|
|
{"${1}label", true},
|
|
|
|
{"${", false},
|
|
|
|
{"$", false},
|
|
|
|
{"${}", false},
|
|
|
|
{"foo${", false},
|
|
|
|
{"$1", true},
|
|
|
|
{"asd$2asd", true},
|
|
|
|
{"-foo${1}bar-", false},
|
|
|
|
{"_${1}_", true},
|
|
|
|
{"foo${bar}foo", true},
|
|
|
|
}
|
|
|
|
for _, test := range tests {
|
2017-10-10 03:29:15 -07:00
|
|
|
testutil.Assert(t, relabelTarget.Match([]byte(test.str)) == test.valid,
|
|
|
|
"Expected %q to be %v", test.str, test.valid)
|
2016-10-19 03:32:42 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 12:01:34 -08:00
|
|
|
func kubernetesSDHostURL() config_util.URL {
|
2015-09-03 02:47:09 -07:00
|
|
|
tURL, _ := url.Parse("https://localhost:1234")
|
Refactor SD configuration to remove `config` dependency (#3629)
* refactor: move targetGroup struct and CheckOverflow() to their own package
* refactor: move auth and security related structs to a utility package, fix import error in utility package
* refactor: Azure SD, remove SD struct from config
* refactor: DNS SD, remove SD struct from config into dns package
* refactor: ec2 SD, move SD struct from config into the ec2 package
* refactor: file SD, move SD struct from config to file discovery package
* refactor: gce, move SD struct from config to gce discovery package
* refactor: move HTTPClientConfig and URL into util/config, fix import error in httputil
* refactor: consul, move SD struct from config into consul discovery package
* refactor: marathon, move SD struct from config into marathon discovery package
* refactor: triton, move SD struct from config to triton discovery package, fix test
* refactor: zookeeper, move SD structs from config to zookeeper discovery package
* refactor: openstack, remove SD struct from config, move into openstack discovery package
* refactor: kubernetes, move SD struct from config into kubernetes discovery package
* refactor: notifier, use targetgroup package instead of config
* refactor: tests for file, marathon, triton SD - use targetgroup package instead of config.TargetGroup
* refactor: retrieval, use targetgroup package instead of config.TargetGroup
* refactor: storage, use config util package
* refactor: discovery manager, use targetgroup package instead of config.TargetGroup
* refactor: use HTTPClient and TLS config from configUtil instead of config
* refactor: tests, use targetgroup package instead of config.TargetGroup
* refactor: fix tagetgroup.Group pointers that were removed by mistake
* refactor: openstack, kubernetes: drop prefixes
* refactor: remove import aliases forced due to vscode bug
* refactor: move main SD struct out of config into discovery/config
* refactor: rename configUtil to config_util
* refactor: rename yamlUtil to yaml_config
* refactor: kubernetes, remove prefixes
* refactor: move the TargetGroup package to discovery/
* refactor: fix order of imports
2017-12-29 12:01:34 -08:00
|
|
|
return config_util.URL{URL: tURL}
|
2015-09-03 02:47:09 -07:00
|
|
|
}
|