Victoriametrics: vmagent promscrape config: cannot unmarshal data

Created on 7 Dec 2020  路  8Comments  路  Source: VictoriaMetrics/VictoriaMetrics

2020-12-07T03:29:47.079Z    info    VictoriaMetrics/lib/cgroup/cpu.go:37    updating GOMAXPROCS to 40 according to cgroup CPU quota
2020-12-07T03:29:47.082Z    fatal   VictoriaMetrics/app/vmagent/main.go:75  error when checking -promscrape.config: cannot parse Prometheus config from "/tmp/conf.good.yml": cannot unmarshal data: yaml: unmarshal errors:
  line 4: field evaluation_interval not found in type promscrape.GlobalConfig

To Reproduce

wget https://raw.githubusercontent.com/prometheus/prometheus/release-2.23/config/testdata/conf.good.yml
vmagent --promscrape.config.dryRun --remoteWrite.flushInterval=5s --httpListenAddr=127.0.0.1:8429 --promscrape.disableKeepAlive=false --promscrape.disableCompression --promscrape.config=/tmp/conf.good.yml

Version
1.49.0

Would be nice to have an __vmagent__ promscrape config example, which documents all "statements", which __vmagent__ accepts.

enhancement

All 8 comments

vmagent uses strict parsing for -promscrape.config file when -promscrape.config.dryRun is enabled. This means that it reports errors if the config contains unsupported options instead of silently skipping such options. This has been fixed in the commit 9c1c9d8e764d7cff5e52cbf17b3023d60a5938f1 , which will be included in the next release.

A temporary workaround is to run vmagent with -dryRun option instead of -promscrape.config.dryRun

Would be nice to have an vmagent promscrape config example, which documents all "statements", which vmagent accepts

Agreed. Let's keep this issue open until such documentation is published.

As a "never-used-prometheus" vm newbie it is very confusing. Why not KISS, e.g.

log.info("skipping '{varname_or_entry}': vmagent does not ... Removing this entry may speed up things a little bit.")

So, if logging at info level is enabled (default IIRC), people get the info they need, and if annoyed with this message often enough, they'll probably fix it or rise the level to WARN. At least for me as enduser makes parsing with 2 different modes no sense (IMHO there is no need for) confuses ppl even more, and is probably harder to maintain.

So IMHO best way is: either vmagent knows the "statement" and handles it properly (which includes skipping it [silently if log level suggests it]), or it does not know it and throws an error.

@jelmd , thanks for great proposal! Unfortunately it isn't so easy to implement, since VictoriaMetrics uses gopkg.in/yaml.v2 package for parsing -promscrape.config file and this package doesn't provide the functionality for implementing this proposal. So we should either search for another package for parsing yaml files or write VictoriaMetrics-specific package, so it could log unknown statements found in parsed yaml.

Aha (FWIW: I hate the yaml crap - it is a real pain and nightmare). What about getting a yaml2json converter (I hope, something like this exists) and use json object notation as primary config format for VM utils? Much less trouble for everyone ...

YAML is a superset of JSON. So VictoriaMetrics should support JSON configs instead of YAML configs out of the box. Just try it :)

OK, so how would you convert the following snippet to an acceptable --promscrape.config?
```global:
scrape_interval: 15s

scrape_configs:

  • job_name: "nvidia"
    scrape_interval: 2s
    scrape_timeout: 5s
    static_configs:

Try the following JSON:

{
  "scrape_interval": "15s",
  "scrape_configs": [
    {
      "job_name": "nvidia",
      "scrape_interval": "2s",
      "scrape_timeout": "5s",
      "static_configs": [
        {
          "targets": ["localhost:9400"]
        }
      ]
    }
  ]
}

Ahhh, cool, much much better and without the whitespace crazyness - can be now structured much better - great! :+1:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

n4mine picture n4mine  路  3Comments

sh0rez picture sh0rez  路  3Comments

prdatur picture prdatur  路  3Comments

jelmd picture jelmd  路  3Comments

faceair picture faceair  路  3Comments