Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to pull the overall number of logins this month for JIRA? (PostgreSQL)

zapzap47 March 10, 2023

How to pull the overall number of logins this month for JIRA? (PostgreSQL)

 

I need this for auditing and cant seem to get a number :) I will eventually need to do this for Confluence and Bitbucket, any help would be appreciated.

2 answers

0 votes
Radek Dostál
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 10, 2023

This requirement is folly and misguided. What is it trying to achieve?

Login counts are arbitrary and can be inflated without the user's knowledge, due to app links or due to basic auth in integrations.

Such a number surely cannot represent any meaningful data, because it:

* cannot be accurate

* can be inflated artificially

* can be inflated without the user's knowledge

* can differ due to session timeout

* can differ due to downtime

zapzap47 March 13, 2023

This is something that I require even if it can be artificially inflated by people spam logging in

Radek Dostál
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 13, 2023

Ok great but then it doesn't matter because the data you require is practically and theoretically useless.

And no, you won't get it with a single query, because such a number is not tracked anywhere, you would need to compare the table data between time ranges. I can assure you, nobody has written anything to do it, because the requirement is pointless.

0 votes
Aditya Verma
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 10, 2023

Hi @zapzap47 ,

Welcome to the community!

Below is an Oracle DB query for Jira. Please edit it for Postgres if required. This will return you all users with their last login details.

SELECT d.directory_name, u.id, u.directory_id, u.user_name, u.active, u.created_date, u.updated_date,
u.first_name, u.last_name, u.display_name, u.email_address,
TO_DATE('19700101','yyyymmdd') + ((a.attribute_value/1000)/24/60/60) as last_login_date
FROM cwd_user u
LEFT JOIN (
SELECT DISTINCT child_name
FROM cwd_membership m
JOIN licenserolesgroup gp ON m.parent_name = gp.GROUP_ID
) m ON m.child_name = u.user_name
LEFT JOIN (
SELECT *
FROM cwd_user_attributes
WHERE attribute_name = 'login.lastLoginMillis'
) a ON a.user_id = u.ID
LEFT JOIN cwd_directory d ON u.directory_id = d.ID
order by last_login_date desc;

Also,please note that last login date is not always correct if the user checks "remember me" per https://jira.atlassian.com/browse/JRASERVER-60508

Thanks,

Aditya

zapzap47 March 10, 2023

Hi, thanks for the reply but I am after the overall count of logins for the month not just on a user basis.

Aditya Verma
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 10, 2023

This will provide you list of users in descending order of their last login. You can export the data into an excel and easily filter out a month data.

Thanks,
Aditya

zapzap47 March 10, 2023

I am after the whole count not just their singular logins to the total logins regardless of user so if a user logs in 30 times that month I need that :)

Aditya Verma
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 10, 2023

So, you need total number of logins per user and for all users in last one month.
This KB article can provide some direction in that case.

Thanks,
Aditya

zapzap47 March 10, 2023

Thanks for the KB, I've tried the first "select sum(attribute_value::int) from cwd_user_attributes where attribute_name='login.count'"

But I am getting nothing come back from the database, any thoughts?

Suggest an answer

Log in or Sign up to answer