Search code examples
watchconsul

How to add tags to Consul watch


I'm a bit confused. I have such a file for the Consul (v.1.0.7) watch.

{
  "watches": [{
      "type": "service",
      "service": "server-devenv-devplatform-common",
            "tag": ["devenv","devplatform","common"],
            "args": ["/opt/consul_watches_handler.sh"]
    }]
}

It doesn't work as expected giving me this error:

Failed reloading watches: Failed to parse watch (map[string]interface {}{\"tag\":[]interface {}{\"devenv\", \"devplatform\", \"common\"}, \"args\":[]interface {}{\"/opt/consul_watches_handler.sh\"}}): Expecting tag to be a string)"] "stdout": "", "stdout_lines": []}

Without a line with a tag, it works fine. But It's made as described in the manual:

https://www.consul.io/docs/dynamic-app-config/watches

and also works at other servers with a tag. I will appreciate any help.


Solution

  • The ability to use multiple tags in a service watch handler was added in Consul 1.5.0 with PR hashicorp/consul#5725.

    This version requirement is not called out in the docs, nor was the feature addition listed in the Consul 1.5.0 changelog so it is completely understandable that you are not aware of this minimum version requirement.