2

I'm running Locust with one master and a couple of workers on Azure Container Instances (ACI). The UI shows the hostnames of each worker as the name of it. ACI auto-generates those hostnames (SandboxHost-637602127034802671) and locust adds some ID(?!):

enter image description here

However, as there is currently no way to influence the hostname of an ACI container, is there any other way I could influence the name locust shows for the worker, e.g. through some environment variable?

silent
  • 14,494
  • 4
  • 46
  • 86

1 Answers1

1

Not sure if it will work, but you can try changing the WorkerRunner id via environment.runner.client_id. By then it might be too late, though, as the init event that you use to access environment is fired after the worker makes a connection to the master and has passed along its id and the master may reject worker reports if the id changes.

I have used Locust in AWS by starting EC2 instances and then starting Docker containers I've built of my Locust file and such. When you do it that way you can change the hostname via Docker's --hostname option for the run command, which I've used successfully to accomplish the same result you're looking for.

If Azure Container Instances don't have an equivalent to that, your only other option might be to find another way to change the hostname before Locust starts. You could try some suggestions in this answer to change the hostname in a script you run as part of your entry point script or during build:

Dockerfile HOSTNAME Instruction for docker build like docker run -h

Solowalker
  • 2,431
  • 8
  • 13
  • is that an ENV I can set? `environment.runner.client_id` – silent Jun 25 '21 at 15:05
  • No, the environment is a variable that contains all sorts of information and data about Locust and what it's running. You can check out these doc links for more about it: https://docs.locust.io/en/stable/writing-a-locustfile.html#environment-attribute https://docs.locust.io/en/stable/api.html?#locust.event.Events.init – Solowalker Jun 26 '21 at 14:34