mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-15 08:23:34 +01:00
lib/promscrape: expose promscrape_discovery_http_errors_total metric for tracking errors per each http_sd config
This commit is contained in:
parent
b885bd9b7d
commit
4a2d7aec7f
@ -10,6 +10,7 @@ sort: 15
|
|||||||
* FEATURE: take into account failed queries in `vm_request_duration_seconds` summary at `/metrics`. Previously only successful queries were taken into account. This could result in skewed summary. See [this pull request](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/1537).
|
* FEATURE: take into account failed queries in `vm_request_duration_seconds` summary at `/metrics`. Previously only successful queries were taken into account. This could result in skewed summary. See [this pull request](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/1537).
|
||||||
* FEATURE: vmalert: add `-disableAlertgroupLabel` command-line flag for disabling the label with alert group name. This may be needed for proper deduplication in Alertmanager. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1532).
|
* FEATURE: vmalert: add `-disableAlertgroupLabel` command-line flag for disabling the label with alert group name. This may be needed for proper deduplication in Alertmanager. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1532).
|
||||||
* FEATURE: update Go builder from v1.16.7 to v1.17.0. This improves data ingestion and query performance by up to 5% according to benchmarks. See [the release post for Go1.17](https://go.dev/blog/go1.17).
|
* FEATURE: update Go builder from v1.16.7 to v1.17.0. This improves data ingestion and query performance by up to 5% according to benchmarks. See [the release post for Go1.17](https://go.dev/blog/go1.17).
|
||||||
|
* FEATURE: vmagent: expose `promscrape_discovery_http_errors_total` metric, which can be used for monitoring the number of failed discovery attempts per each `http_sd` config.
|
||||||
|
|
||||||
* BUGFIX: rename `sign` function to `sgn` in order to be consistent with PromQL. See [this pull request from Prometheus](https://github.com/prometheus/prometheus/pull/8457).
|
* BUGFIX: rename `sign` function to `sgn` in order to be consistent with PromQL. See [this pull request from Prometheus](https://github.com/prometheus/prometheus/pull/8457).
|
||||||
* BUGFIX: improve the detection of the needed free space for background merge operation. This should prevent from possible out of disk space crashes during big merges. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1560).
|
* BUGFIX: improve the detection of the needed free space for background merge operation. This should prevent from possible out of disk space crashes during big merges. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1560).
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
|
|
||||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/promscrape/discoveryutils"
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/promscrape/discoveryutils"
|
||||||
"github.com/VictoriaMetrics/fasthttp"
|
"github.com/VictoriaMetrics/fasthttp"
|
||||||
|
"github.com/VictoriaMetrics/metrics"
|
||||||
)
|
)
|
||||||
|
|
||||||
var configMap = discoveryutils.NewConfigMap()
|
var configMap = discoveryutils.NewConfigMap()
|
||||||
@ -15,6 +16,9 @@ var configMap = discoveryutils.NewConfigMap()
|
|||||||
type apiConfig struct {
|
type apiConfig struct {
|
||||||
client *discoveryutils.Client
|
client *discoveryutils.Client
|
||||||
path string
|
path string
|
||||||
|
|
||||||
|
fetchErrors *metrics.Counter
|
||||||
|
parseErrors *metrics.Counter
|
||||||
}
|
}
|
||||||
|
|
||||||
// httpGroupTarget respresent prometheus GroupTarget
|
// httpGroupTarget respresent prometheus GroupTarget
|
||||||
@ -46,6 +50,8 @@ func newAPIConfig(sdc *SDConfig, baseDir string) (*apiConfig, error) {
|
|||||||
cfg := &apiConfig{
|
cfg := &apiConfig{
|
||||||
client: client,
|
client: client,
|
||||||
path: parsedURL.RequestURI(),
|
path: parsedURL.RequestURI(),
|
||||||
|
fetchErrors: metrics.GetOrCreateCounter(fmt.Sprintf(`promscrape_discovery_http_errors_total{type="fetch",url=%q}`, sdc.URL)),
|
||||||
|
parseErrors: metrics.GetOrCreateCounter(fmt.Sprintf(`promscrape_discovery_http_errors_total{type="parse",url=%q}`, sdc.URL)),
|
||||||
}
|
}
|
||||||
return cfg, nil
|
return cfg, nil
|
||||||
}
|
}
|
||||||
@ -64,9 +70,15 @@ func getHTTPTargets(cfg *apiConfig) ([]httpGroupTarget, error) {
|
|||||||
request.Header.Set("Accept", "application/json")
|
request.Header.Set("Accept", "application/json")
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
cfg.fetchErrors.Inc()
|
||||||
return nil, fmt.Errorf("cannot read http_sd api response: %w", err)
|
return nil, fmt.Errorf("cannot read http_sd api response: %w", err)
|
||||||
}
|
}
|
||||||
return parseAPIResponse(data, cfg.path)
|
tg, err := parseAPIResponse(data, cfg.path)
|
||||||
|
if err != nil {
|
||||||
|
cfg.parseErrors.Inc()
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return tg, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseAPIResponse(data []byte, path string) ([]httpGroupTarget, error) {
|
func parseAPIResponse(data []byte, path string) ([]httpGroupTarget, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user