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

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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Monday in Jira Software

How large do you think Jira Software can grow?

Hi Atlassian Community! My name is Shana, and I’m on the Jira Software team. One of the many reasons this Community exists is to connect you to others on similar product journeys or with comparabl...

384 views 4 10
Read article

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