Dynamic tagging or naming of services

I am new to nomad. Trying my first small cluster(consul+nomad). The idea is to use nomad_follower with loki and promtail for logging from my containers. I use tagging on the services and search them with loki.
On nomad job group with count >1, how i can change the tagging or the name of the service to include what service number is?
For example I want a job to run a (single) Java application container 3 times. How i can say that
javaservicename1 tag jvm1
javaservicename2 tag jvm1 etc

Now when i make a nomad job with group count =2, both services have the same name at consul. And the logs have the same tag.

Hi @dimitris.tzampanakis. Nomad supports interpolation in several jobspec blocks, including the service block. Depending on your exact naming requirement, service names can be interpolated using the NOMAD_ALLOC_INDEX which is unique within a given version of a job.

service {
  name = "javaservicename-${NOMAD_ALLOC_INDEX}"
}

I hope this helps.

Thanks,
jrasell and the Nomad team