ContainerSolutions / ContainerSolutions/locust_exporter

Using the exporter without the locust WebUI

Open
#5 1 comment 1 reaction 0 assignees View on GitHub
good first issue question
Dominant language
Go
Stars
115
Forks
39
PR merge metrics
No merged PRs in 30d

Description

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?

Contributor guide

Open the contributing guide

Research direction

Start by checking how the exporter reads Locust's stats/requests endpoint in the headless flow described. Read Locust's examples/use_as_lib.py to understand the suggested API-based setup. Done means the exporter can obtain metrics when Locust runs without its WebUI, with the behavior covered by appropriate tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
observability
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.