mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-23 20:37:12 +01:00
e5eca54951
See the list of configs supported by Prometheus atf88a0a7d83/discovery/nomad/nomad.go (L76-L84)
- Removed "token" option. In can be set either via NOMAD_TOKEN env var or via `bearer_token` config option. - Removed "scheme" option. It is automatically detected depending on whether the `tls_config` is set. - Removed "services" and "tags" options, since they aren't supported by Prometheus. - Added "region" option. If it is missing, then the region is read from NOMAD_REGION env var. If this var is empty, then it is set to "global" in the same way as Nomad client does. See865ee8d37c/api/api.go (L297)
and865ee8d37c/api/api.go (L555-L556)
- If the "server" option is missing, then it is read from NOMAD_ADDR in the same way as Nomad client does - see865ee8d37c/api/api.go (L294-L296)
This is a follow-up for8aee209c53
Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3367
47 lines
1.5 KiB
Go
47 lines
1.5 KiB
Go
package nomad
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/promauth"
|
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/promutils"
|
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/proxy"
|
|
)
|
|
|
|
// SDConfig represents service discovery config for Nomad.
|
|
//
|
|
// See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#nomad_sd_config
|
|
type SDConfig struct {
|
|
Server string `yaml:"server,omitempty"`
|
|
Namespace string `yaml:"namespace,omitempty"`
|
|
// RefreshInterval time.Duration `yaml:"refresh_interval"`
|
|
// refresh_interval is obtained from `-promscrape.nomadSDCheckInterval` command-line option.
|
|
Region string `yaml:"region,omitempty"`
|
|
TagSeparator *string `yaml:"tag_separator,omitempty"`
|
|
AllowStale *bool `yaml:"allow_stale,omitempty"`
|
|
|
|
HTTPClientConfig promauth.HTTPClientConfig `yaml:",inline"`
|
|
ProxyURL *proxy.URL `yaml:"proxy_url,omitempty"`
|
|
ProxyClientConfig promauth.ProxyClientConfig `yaml:",inline"`
|
|
}
|
|
|
|
// GetLabels returns Nomad labels according to sdc.
|
|
func (sdc *SDConfig) GetLabels(baseDir string) ([]*promutils.Labels, error) {
|
|
cfg, err := getAPIConfig(sdc, baseDir)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("cannot get API config: %w", err)
|
|
}
|
|
ms := getServiceLabels(cfg)
|
|
return ms, nil
|
|
}
|
|
|
|
// MustStop stops further usage for sdc.
|
|
func (sdc *SDConfig) MustStop() {
|
|
v := configMap.Delete(sdc)
|
|
if v != nil {
|
|
// v can be nil if GetLabels wasn't called yet.
|
|
cfg := v.(*apiConfig)
|
|
cfg.mustStop()
|
|
}
|
|
}
|