mirror of
https://github.com/hanzoai/metrics.git
synced 2026-10-30 20:03:39 +00:00
This avoids a redirect from the old link https://docs.victoriametrics.com/sd_configs/ to https://docs.victoriametrics.com/victoriametrics/sd_configs/ ,
and fixes `backwards` navigation for these links across VictoriaMetrics docs.
This is a follow-up for ca45112df2
See https://github.com/VictoriaMetrics/VictoriaMetrics/pull/8595#issuecomment-2831598274
55 lines
1.9 KiB
Go
55 lines
1.9 KiB
Go
package ovhcloud
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
"time"
|
|
|
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/promauth"
|
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/promutil"
|
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/proxy"
|
|
)
|
|
|
|
// SDCheckInterval defines interval for targets refresh.
|
|
var SDCheckInterval = flag.Duration("promscrape.ovhcloudSDCheckInterval", 30*time.Second, "Interval for checking for changes in OVH Cloud API. "+
|
|
"This works only if ovhcloud_sd_configs is configured in '-promscrape.config' file. "+
|
|
"See https://docs.victoriametrics.com/victoriametrics/sd_configs/#ovhcloud_sd_configs for details")
|
|
|
|
// SDConfig is the configuration for OVH Cloud service discovery.
|
|
type SDConfig struct {
|
|
Endpoint string `yaml:"endpoint"`
|
|
ApplicationKey string `yaml:"application_key"`
|
|
ApplicationSecret *promauth.Secret `yaml:"application_secret"`
|
|
ConsumerKey *promauth.Secret `yaml:"consumer_key"`
|
|
Service string `yaml:"service"`
|
|
|
|
HTTPClientConfig promauth.HTTPClientConfig `yaml:",inline"`
|
|
ProxyURL *proxy.URL `yaml:"proxy_url,omitempty"`
|
|
ProxyClientConfig promauth.ProxyClientConfig `yaml:",inline"`
|
|
}
|
|
|
|
// GetLabels returns labels for OVH Cloud according to service discover config.
|
|
func (sdc *SDConfig) GetLabels(baseDir string) ([]*promutil.Labels, error) {
|
|
cfg, err := getAPIConfig(sdc, baseDir)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("cannot get API config: %w", err)
|
|
}
|
|
switch sdc.Service {
|
|
case "dedicated_server":
|
|
return getDedicatedServerLabels(cfg)
|
|
case "vps":
|
|
return getVPSLabels(cfg)
|
|
default:
|
|
return nil, fmt.Errorf("skipping unexpected service=%q; only `dedicated_server` and `vps` are supported for now", sdc.Service)
|
|
}
|
|
}
|
|
|
|
// MustStop stops further usage for sdc.
|
|
func (sdc *SDConfig) MustStop() {
|
|
v := configMap.Delete(sdc)
|
|
if v != nil {
|
|
cfg := v.(*apiConfig)
|
|
cfg.client.Stop()
|
|
}
|
|
}
|