Is this possible at all?
I have an automated build that spins up a container and runs locust with the headless flag so I can set the run-time.
This means the stats/requests endpoint is not available and the exporter can't read it.
I found a way to get around this by using locust as an API:
example from https://github.com/locustio/locust/blob/master/examples/use_as_lib.py
# setup Environment and Runner
env = Environment(user_classes=[User])
env.create_local_runner()
# start a WebUI instance
env.create_web_ui("127.0.0.1", 8089)
# start a greenlet that periodically outputs the current stats
gevent.spawn(stats_printer(env.stats))
# start the test
env.runner.start(1, hatch_rate=10)
# in 60 seconds stop the runner
gevent.spawn_later(60, lambda: env.runner.quit())
# wait for the greenlets
env.runner.greenlet.join()
# stop the web server for good measures
env.web_ui.stop()
Is there a better way to do this?
Is this possible at all?
I have an automated build that spins up a container and runs locust with the
headlessflag so I can set the run-time.This means the stats/requests endpoint is not available and the exporter can't read it.
I found a way to get around this by using locust as an API:
example from https://github.com/locustio/locust/blob/master/examples/use_as_lib.py
Is there a better way to do this?