User login data query

Hi,

I have a question that i can get "Login Count", "Last Login", "Failed Count" at once for all users.

I know it can get from user statistics, it's hard to check all each users.

So, i found this query for Last login but is there any way to query at once for the three things?

4.JPG

https://confluence.atlassian.com/jirakb/retrieve-last-login-dates-for-users-from-the-database-363364638.html

I use Jira 7.2.6 with MysqlDB

1 answer

This widget could not be displayed.

Yes you can use the following attribute_name to build our query.

select distinct attribute_name from cwd_user_attributes where attribute_name in ('login.count','login.totalFailedCount','login.lastLoginMillis');
     attribute_name
------------------------
 login.lastLoginMillis
 login.count
 login.totalFailedCount

Hi, 

I got error with this query, where i should fix?

SELECT d.directory_name AS "Directory", 
    u.user_name AS "Username",
    to_timestamp(CAST(a.attribute_value AS BIGINT)/1000) AS "Last Login" ,
    b.attribute_value as "Login Count",
    c.attribute_value as "Total Failed Login Attempts"
FROM cwd_user u
JOIN (
    SELECT DISTINCT child_name 
    FROM cwd_membership m 
    JOIN globalpermissionentry gp ON m.parent_name = gp.group_id 
    WHERE gp.permission IN ('ADMINISTER', 'USE', 'SYSTEM_ADMIN')
    ) AS m ON m.child_name = u.user_name
LEFT JOIN (
    SELECT * 
    FROM cwd_user_attributes ca
    WHERE attribute_name = 'login.lastLoginMillis'
    ) AS a ON a.user_id = u.id
LEFT JOIN (
    SELECT * 
    FROM cwd_user_attributes ca
    WHERE attribute_name = 'login.count'
    ) AS b ON b.user_id = u.id
LEFT JOIN (
    SELECT * 
    FROM cwd_user_attributes ca
    WHERE attribute_name = 'login.totalFailedCount'
    ) AS c ON c.user_id = u.id
JOIN cwd_directory d ON u.directory_id = d.id
ORDER BY "Last Login" DESC;

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'BIGINT)/1000) AS "Last Login", b.attribute_value as "Login Count", c.attribute_v' at line 3

 

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

83 views 1 0
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you