mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-15 00:13:30 +01:00
lib/promscrape/discovery/http: follow up after e307bbb29a
This commit is contained in:
parent
e03a3d3a36
commit
4adf6c9766
@ -10,6 +10,7 @@ sort: 15
|
|||||||
* FEATURE: vmagent: change the default value for `-remoteWrite.queues` from 4 to `2 * numCPUs`. This should reduce scrape duration for highly loaded vmagent, which scrapes tens of thousands of targets. See [this pull request](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/1385).
|
* FEATURE: vmagent: change the default value for `-remoteWrite.queues` from 4 to `2 * numCPUs`. This should reduce scrape duration for highly loaded vmagent, which scrapes tens of thousands of targets. See [this pull request](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/1385).
|
||||||
* FEATURE: vmagent: show the number of samples the target returned during the last scrape on `/targets` and `/api/v1/targets` pages. This should simplify debugging targets, which may return too big or too low number of samples. See [this feature request](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1377).
|
* FEATURE: vmagent: show the number of samples the target returned during the last scrape on `/targets` and `/api/v1/targets` pages. This should simplify debugging targets, which may return too big or too low number of samples. See [this feature request](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1377).
|
||||||
* FEATURE: vmagent: show jobs with zero discovered targets on `/targets` page. This should help debugging improperly configured scrape configs.
|
* FEATURE: vmagent: show jobs with zero discovered targets on `/targets` page. This should help debugging improperly configured scrape configs.
|
||||||
|
* FEATURE: vmagent: support for http-based service discovery (aka [http_sd_config](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#http_sd_config)), which has been added since Prometheus 2.28. See [this feature request](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1392).
|
||||||
* FEATURE: vmagent: support namespace in Consul serive discovery in the same way as Prometheus 2.28 does. See [this issue](https://github.com/prometheus/prometheus/issues/8894) for details.
|
* FEATURE: vmagent: support namespace in Consul serive discovery in the same way as Prometheus 2.28 does. See [this issue](https://github.com/prometheus/prometheus/issues/8894) for details.
|
||||||
* FEATURE: vmagent: support generic auth configs in `consul_sd_configs` in the same way as Prometheus 2.28 does. See [this issue](https://github.com/prometheus/prometheus/issues/8924) for details.
|
* FEATURE: vmagent: support generic auth configs in `consul_sd_configs` in the same way as Prometheus 2.28 does. See [this issue](https://github.com/prometheus/prometheus/issues/8924) for details.
|
||||||
* FEATURE: [vmctl](https://docs.victoriametrics.com/vmctl.html): limit the number of samples per each imported JSON line. This should limit the memory usage at VictoriaMetrics side when importing time series with big number of samples.
|
* FEATURE: [vmctl](https://docs.victoriametrics.com/vmctl.html): limit the number of samples per each imported JSON line. This should limit the memory usage at VictoriaMetrics side when importing time series with big number of samples.
|
||||||
|
@ -30,16 +30,14 @@ func (sdc *SDConfig) GetLabels(baseDir string) ([]map[string]string, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("cannot get API config: %w", err)
|
return nil, fmt.Errorf("cannot get API config: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
hts, err := getHTTPTargets(cfg)
|
hts, err := getHTTPTargets(cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
return addHTTPTargetLabels(hts, sdc.URL), nil
|
||||||
return addHTTPTargetLabels(hts), nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func addHTTPTargetLabels(src []httpGroupTarget) []map[string]string {
|
func addHTTPTargetLabels(src []httpGroupTarget, sourceURL string) []map[string]string {
|
||||||
ms := make([]map[string]string, 0, len(src))
|
ms := make([]map[string]string, 0, len(src))
|
||||||
for _, targetGroup := range src {
|
for _, targetGroup := range src {
|
||||||
labels := targetGroup.Labels
|
labels := targetGroup.Labels
|
||||||
@ -49,6 +47,7 @@ func addHTTPTargetLabels(src []httpGroupTarget) []map[string]string {
|
|||||||
m[k] = v
|
m[k] = v
|
||||||
}
|
}
|
||||||
m["__address__"] = target
|
m["__address__"] = target
|
||||||
|
m["__meta_url"] = sourceURL
|
||||||
ms = append(ms, m)
|
ms = append(ms, m)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,27 +23,29 @@ func Test_addHTTPTargetLabels(t *testing.T) {
|
|||||||
src: []httpGroupTarget{
|
src: []httpGroupTarget{
|
||||||
{
|
{
|
||||||
Targets: []string{"127.0.0.1:9100", "127.0.0.2:91001"},
|
Targets: []string{"127.0.0.1:9100", "127.0.0.2:91001"},
|
||||||
Labels: map[string]string{"__meta__kubernetes_pod": "pod-1", "__meta_consul_dc": "dc-2"},
|
Labels: map[string]string{"__meta_kubernetes_pod": "pod-1", "__meta_consul_dc": "dc-2"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
want: [][]prompbmarshal.Label{
|
want: [][]prompbmarshal.Label{
|
||||||
discoveryutils.GetSortedLabels(map[string]string{
|
discoveryutils.GetSortedLabels(map[string]string{
|
||||||
"__address__": "127.0.0.1:9100",
|
"__address__": "127.0.0.1:9100",
|
||||||
"__meta__kubernetes_pod": "pod-1",
|
"__meta_kubernetes_pod": "pod-1",
|
||||||
"__meta_consul_dc": "dc-2",
|
"__meta_consul_dc": "dc-2",
|
||||||
|
"__meta_url": "http://foo.bar/baz?aaa=bb",
|
||||||
}),
|
}),
|
||||||
discoveryutils.GetSortedLabels(map[string]string{
|
discoveryutils.GetSortedLabels(map[string]string{
|
||||||
"__address__": "127.0.0.2:91001",
|
"__address__": "127.0.0.2:91001",
|
||||||
"__meta__kubernetes_pod": "pod-1",
|
"__meta_kubernetes_pod": "pod-1",
|
||||||
"__meta_consul_dc": "dc-2",
|
"__meta_consul_dc": "dc-2",
|
||||||
|
"__meta_url": "http://foo.bar/baz?aaa=bb",
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
got := addHTTPTargetLabels(tt.args.src)
|
got := addHTTPTargetLabels(tt.args.src, "http://foo.bar/baz?aaa=bb")
|
||||||
var sortedLabelss [][]prompbmarshal.Label
|
var sortedLabelss [][]prompbmarshal.Label
|
||||||
for _, labels := range got {
|
for _, labels := range got {
|
||||||
sortedLabelss = append(sortedLabelss, discoveryutils.GetSortedLabels(labels))
|
sortedLabelss = append(sortedLabelss, discoveryutils.GetSortedLabels(labels))
|
||||||
|
Loading…
Reference in New Issue
Block a user