diff --git a/lib/promscrape/discovery/dockerswarm/api.go b/lib/promscrape/discovery/dockerswarm/api.go index ef33775ba..ebd8e07ed 100644 --- a/lib/promscrape/discovery/dockerswarm/api.go +++ b/lib/promscrape/discovery/dockerswarm/api.go @@ -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. diff --git a/lib/promscrape/discovery/dockerswarm/dockerswarm.go b/lib/promscrape/discovery/dockerswarm/dockerswarm.go index 77345a307..133d9b2e0 100644 --- a/lib/promscrape/discovery/dockerswarm/dockerswarm.go +++ b/lib/promscrape/discovery/dockerswarm/dockerswarm.go @@ -14,12 +14,6 @@ var SDCheckInterval = flag.Duration("promscrape.dockerswarmSDCheckInterval", 30* "This works only if dockerswarm_sd_configs is configured in '-promscrape.config' file. "+ "See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#dockerswarm_sd_config 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 @@ -48,11 +42,11 @@ func (sdc *SDConfig) GetLabels(baseDir string) ([]map[string]string, 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)