consul报错:invalid config key service.check.script

问题:

2022-08-11T04:11:22.280+0200 [ERROR] agent.http: Request error: method=PUT url=/v1/agent/reload from=127.0.0.1:39340 error="failed to parse consul.d/docker_test.json: 1 er
ror occurred:
* invalid config key service.check.script

解释:

早期的consul check使用 service.check.script 进行配置。
新版本的consul check使用 service.check.args进行配置;

解决:

Consul shows script is a invalid config key

https://stackoverflow.com/questions/50742333/consul-shows-script-is-a-invalid-config-key

简介:

#NOTE: stackoverflow上的一个记录。 



I am trying to run a shell script to do the health check using consul. I am able to do the HTTP checks but when I try the script its throwing error. ( maybe some silly mistake )

Config File

{
 "services": [
   {
     "name": "test",
     "checks": [
         {
           "script": "./test.sh",
           "interval": "15s"
         }
       ]
     }
   ] 
}


Run

./consul agent -enable-script-checks=true -ui -dev -config-dir=.     


Output

==> Error parsing web.json: 1 error(s) occurred:

* invalid config key services[0].checks[0].script




change your configure variable,change “script” to “args”.

for example:

"args": [
    "/usr/local/bin/check_mem.py",
    "-limit",
    "256MB"
],
it should solve your problem

你可能感兴趣的:(consul报错:invalid config key service.check.script)