mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-23 12:31:07 +01:00
lib/promscrape: follow-up for 8537533beb
- Add a comment describing the purpose of the `role` field inside `apiConfig` struct - Revert changes at lib/promscrape/discovery/dockerswarm/dockerswarm.go , since they reduce code readability. E.g. the reader needs to look up the named string constants in order to get their values.
This commit is contained in:
parent
8537533beb
commit
b4ad3a3b4c
@ -17,6 +17,8 @@ type apiConfig struct {
|
||||
port int
|
||||
|
||||
// role is the type of objects to discover.
|
||||
//
|
||||
// filtersQueryArg is applied only to the given role - the rest of objects are queried without filters.
|
||||
role string
|
||||
|
||||
// filtersQueryArg contains escaped `filters` query arg to add to each request to Docker Swarm API.
|
||||
|
@ -15,12 +15,6 @@ var SDCheckInterval = flag.Duration("promscrape.dockerswarmSDCheckInterval", 30*
|
||||
"This works only if dockerswarm_sd_configs is configured in '-promscrape.config' file. "+
|
||||
"See https://docs.victoriametrics.com/sd_configs.html#dockerswarm_sd_configs for details")
|
||||
|
||||
const (
|
||||
roleTasks = "tasks"
|
||||
roleServices = "services"
|
||||
roleNodes = "nodes"
|
||||
)
|
||||
|
||||
// SDConfig represents docker swarm service discovery configuration
|
||||
//
|
||||
// See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#dockerswarm_sd_config
|
||||
@ -49,11 +43,11 @@ func (sdc *SDConfig) GetLabels(baseDir string) ([]*promutils.Labels, error) {
|
||||
return nil, fmt.Errorf("cannot get API config: %w", err)
|
||||
}
|
||||
switch sdc.Role {
|
||||
case roleTasks:
|
||||
case "tasks":
|
||||
return getTasksLabels(cfg)
|
||||
case roleServices:
|
||||
case "services":
|
||||
return getServicesLabels(cfg)
|
||||
case roleNodes:
|
||||
case "nodes":
|
||||
return getNodesLabels(cfg)
|
||||
default:
|
||||
return nil, fmt.Errorf("unexpected `role`: %q; must be one of `tasks`, `services` or `nodes`; skipping it", sdc.Role)
|
||||
|
Loading…
Reference in New Issue
Block a user