I am trying to create a table/chart in Grafana showing the total number of unique users who have logged in to a given application over a given time range (e.g. last 24 hours). I have a metric, app_request_path
which records the number of requests hitting a specific path per minute:
app_request_count{app="my-app", path="/login"}
This gives me the following:
app_request_count{app="my-app",path="/login",status="200",username="username1"}
app_request_count{app="my-app",path="/login",status="200",username="username2"}
Now I want to count the number of unique usernames, so I run:
count_values("username", app_request_count{app="my_app", path="/login"})
and I get:
{username="0"}
{username="1"}
{username="2"}
{username="3"}
{username="4"}
{username="5"}
What am I missing / what am I doing wrong? Ideally I'd like to get a single scalar value that display the total number of unique usernames who have logged in in the past 24 hours.
Many thanks.
count without (username) (sum(sum_over_time(app_request_count{app="my-app", path="/login"}[24h])) by (username))
Thanks very much for the help! – Clabo