Update tags on existing service (need some example)

I’m using Consul, with Nomad, all with ACL enabled. I have a service with 3 instances, and would like to manually update tags on specific instances (1 instance master, 2 instances replica). But I do not understand how to do this. I know I have to use the API, there’s no easy way to do it with consul cli. But what I want is simply

  • Get the current service definition
  • Add / Remove the tags I need
  • Register the service again to update the tags, without changing anything else

I really do not understand how to do this. There’re several API endpointsto both get, or set/modify servcices


Could anyone provide a simple one-liner to update the service tag while keeping everything else the same ?
Something like

curl http://localhost:8500/v1/<the path to query> | \
  jq 'the magic JQ filter and modification needed' | \
  curl -X PUT -d @- http://localhost:8500/v1/<the path to update>