mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-15 08:23:34 +01:00
app/{vmagent,victoria-metrics}: add -dryRun
option and make more clear handling for -promscrape.config.dryRun
This commit is contained in:
parent
ed06990609
commit
3f52e59efe
@ -69,12 +69,19 @@ func main() {
|
|||||||
logger.Init()
|
logger.Init()
|
||||||
cgroup.UpdateGOMAXPROCSToCPUQuota()
|
cgroup.UpdateGOMAXPROCSToCPUQuota()
|
||||||
|
|
||||||
|
if promscrape.IsDryRun() {
|
||||||
|
if err := promscrape.CheckConfig(); err != nil {
|
||||||
|
logger.Fatalf("error when checking -promscrape.config: %s", err)
|
||||||
|
}
|
||||||
|
logger.Infof("-promscrape.config is ok; exitting with 0 status code")
|
||||||
|
return
|
||||||
|
}
|
||||||
if *dryRun {
|
if *dryRun {
|
||||||
if err := remotewrite.CheckRelabelConfigs(); err != nil {
|
if err := remotewrite.CheckRelabelConfigs(); err != nil {
|
||||||
logger.Fatalf("error when checking relabel configs: %s", err)
|
logger.Fatalf("error when checking relabel configs: %s", err)
|
||||||
}
|
}
|
||||||
if err := promscrape.CheckConfig(); err != nil {
|
if err := promscrape.CheckConfig(); err != nil {
|
||||||
logger.Fatalf("error when checking Prometheus config: %s", err)
|
logger.Fatalf("error when checking -promscrape.config: %s", err)
|
||||||
}
|
}
|
||||||
logger.Infof("all the configs are ok; exitting with 0 status code")
|
logger.Infof("all the configs are ok; exitting with 0 status code")
|
||||||
return
|
return
|
||||||
|
@ -20,6 +20,7 @@ See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/851
|
|||||||
Slow query logging is controlled with `-search.logSlowQueryDuration` command-line flag.
|
Slow query logging is controlled with `-search.logSlowQueryDuration` command-line flag.
|
||||||
* FEATURE: add `/tags/delSeries` handler from Graphite Tags API. See https://victoriametrics.github.io/#graphite-tags-api-usage
|
* FEATURE: add `/tags/delSeries` handler from Graphite Tags API. See https://victoriametrics.github.io/#graphite-tags-api-usage
|
||||||
* FEATURE: log metric name plus all its labels when the metric timestamp is out of the configured retention. This should simplify detecting the source of metrics with unexpected timestamps.
|
* FEATURE: log metric name plus all its labels when the metric timestamp is out of the configured retention. This should simplify detecting the source of metrics with unexpected timestamps.
|
||||||
|
* FEATURE: add `-dryRun` command-line flag to single-node VictoriaMetrics in order to check config file pointed by `-promscrape.config`.
|
||||||
|
|
||||||
* BUGFIX: properly parse Prometheus metrics with [exemplars](https://github.com/OpenObservability/OpenMetrics/blob/master/OpenMetrics.md#exemplars-1) such as `foo 123 # {bar="baz"} 1`.
|
* BUGFIX: properly parse Prometheus metrics with [exemplars](https://github.com/OpenObservability/OpenMetrics/blob/master/OpenMetrics.md#exemplars-1) such as `foo 123 # {bar="baz"} 1`.
|
||||||
* BUGFIX: properly parse "infinity" values in [OpenMetrics format](https://github.com/OpenObservability/OpenMetrics/blob/master/OpenMetrics.md#abnf).
|
* BUGFIX: properly parse "infinity" values in [OpenMetrics format](https://github.com/OpenObservability/OpenMetrics/blob/master/OpenMetrics.md#abnf).
|
||||||
|
@ -5,7 +5,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
@ -134,16 +133,14 @@ func loadConfig(path string) (cfg *Config, data []byte, err error) {
|
|||||||
if err := cfgObj.parse(data, path); err != nil {
|
if err := cfgObj.parse(data, path); err != nil {
|
||||||
return nil, nil, fmt.Errorf("cannot parse Prometheus config from %q: %w", path, err)
|
return nil, nil, fmt.Errorf("cannot parse Prometheus config from %q: %w", path, err)
|
||||||
}
|
}
|
||||||
if *dryRun {
|
|
||||||
// This is a dirty hack for checking Prometheus config only.
|
|
||||||
// See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/362
|
|
||||||
// and https://github.com/VictoriaMetrics/VictoriaMetrics/issues/508 for details.
|
|
||||||
logger.Infof("Success: the config at %q has no errors; exitting with 0 status code", path)
|
|
||||||
os.Exit(0)
|
|
||||||
}
|
|
||||||
return &cfgObj, data, nil
|
return &cfgObj, data, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsDryRun returns true if -promscrape.config.dryRun command-line flag is set
|
||||||
|
func IsDryRun() bool {
|
||||||
|
return *dryRun
|
||||||
|
}
|
||||||
|
|
||||||
func (cfg *Config) parse(data []byte, path string) error {
|
func (cfg *Config) parse(data []byte, path string) error {
|
||||||
if err := unmarshalMaybeStrict(data, cfg); err != nil {
|
if err := unmarshalMaybeStrict(data, cfg); err != nil {
|
||||||
return fmt.Errorf("cannot unmarshal data: %w", err)
|
return fmt.Errorf("cannot unmarshal data: %w", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user