the ${stack_name}/${service_name} are understood by Rancher when making scheduling decisions. You’ll need to escape them with a $ so, $${stack_name}/$${service_name}
If you want them from inside the container while running, then you just need to query metadata: