Track How Many Users Are Logged In

Does anyone know if there is a way to count or keep track of the number of users that are logged in?

Thanks,

–Matt Royer

Hi Matt,

What do you mean by “logged in”?

Hi Stéphane,

I’m sorry. I thought about it afterward and realized I could have worded that better.

I’m running a CSV with user credentials through a feeder in Gatling to authenticate our users and log them into our system.

What I’m looking for is a way to track which ones from that sheet have been authenticated. Would it be a good idea to create some kind of counter that tracks a certain status? That way we know if one of the users wasn’t authenticated. I’m not sure which way would work best.

I’m mainly asking if anyone has done something similar or has any ideas on the best way to do this. Also, tracking the session id’s would be great as well.

Thank you,

–Matt

Got it now :slight_smile:

First, you can use a check in order to tell authenticated and non authenticated users apart:
check(status.is(200).saveAs(“authenticated”)) or check(regex(…).saveAs(“authenticated”))

Only authenticated users will have a authenticated session attribute.

Then, you can use a custom action such as:

val logger = org.slf4j.LoggerFactory.getLogger(“myUserTracker”)

val scn =

login phase with the check

.exec{ session =>
logger.info(“user=” + session.userId + "authenticated? " + session.isAttributeDefined(“authenticated”))

session

}

Does this suits your needs?

Cheers,

Stéphane

Perfect! That’s exactly what I need. Thanks, Stéphane!!!

You’re welcome.
Have fun!