prometheus/retrieval
beorn7 e2b3626e0c retrieval: Clean up target group map on config reload
Also, remove unused `providers` field in targetSet.

If the config file changes, we recreate all providers (by calling
`providersFromConfig`) and retrieve all targets anew from the newly
created providers. From that perspective, it cannot harm to clean up
the target group map in the targetSet. Not doing so (as it was the
case so far) keeps stale targets around. This mattered if an existing
key in the target group map was not overwritten in the initial fetch
of all targets from the providers. Examples where that mattered:

```
scrape_configs:
- job_name: "foo"
  static_configs:
  - targets: ["foo:9090"]
  - targets: ["bar:9090"]
```
updated to:
```
scrape_configs:
- job_name: "foo"
  static_configs:
  - targets: ["foo:9090"]
```

`bar:9090` would still be monitored. (The static provider just
enumerates the target groups. If the number of target groups
decreases, the old ones stay around.

```
scrape_configs:
- job_name: "foo"
  dns_sd_configs:
  - names:
    - "srv.name.one.example.org"
```
updated to:
```
scrape_configs:
- job_name: "foo"
  dns_sd_configs:
  - names:
    - "srv.name.two.example.org"
```

Now both SRV records are still monitored. The SRV name is part of the
key in the target group map, thus the new one is just added and the
old ane stays around.

Obviously, this should have tests, and should have tests before, not
only for this case. This is the quick fix. I have created
https://github.com/prometheus/prometheus/issues/1906 to track test
creation.

Fixes https://github.com/prometheus/prometheus/issues/1610 .
2016-08-22 19:25:33 +02:00
..
discovery discovery/kubernetes: filter pod/container, service/endpoint 2016-07-05 14:24:17 +02:00
testdata Add ServerName into TLS Config 2016-05-26 14:24:49 -07:00
helpers_test.go Fix tests for append API changes 2016-02-03 10:17:08 +01:00
relabel_test.go Relabel: Document whole label set is dropped 2016-06-07 17:13:30 +01:00
relabel.go Add missing license headers 2015-08-24 19:19:21 +02:00
scrape_test.go Fix format argument in retrieval test. 2016-05-01 23:37:45 +02:00
scrape.go Consistently use the Seconds() method for conversion of durations 2016-07-07 15:24:35 +02:00
target_test.go Unexport testing constant 2016-05-26 14:42:17 -07:00
target.go Add ServerName into TLS Config 2016-05-26 14:24:49 -07:00
targetmanager_test.go Remove old tests 2016-03-01 13:48:36 +01:00
targetmanager.go retrieval: Clean up target group map on config reload 2016-08-22 19:25:33 +02:00