Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How do I see the number of users in a group?

Sandra Meessen August 1, 2018

Hello, I want to clean up my groups in Confluence. How do I see the number of users in the groups without having to select them one by one? Thanks

3 answers

1 accepted

0 votes
Answer accepted
Danyal Iqbal
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.
August 1, 2018

I am not aware of any way to obtain this info from the front end. However, you can query the database directly e.g for users in crowd directory --select /count (*) /distinct from CWD\_MEMBERSHIP where GROUP_NAME= <> and check the groups from CWD\_GROUP would be a nice place to start.

0 votes
Richard Cross May 24, 2022

If using Atlassian Crowd as the backend auth server, you can find the number of users in a group with the following Crowd REST API call:

curl -s -n \
-H "Accept: application/json" \
'https://mycrowd.server/crowd/rest/usermanagement/1/group/user/direct?groupname=my-test-group&max-results=10000' | jq -r '.users[].name' | wc -l

If the result comes out at exactly the same as max-results, increase max-results until it doesn't.

0 votes
Richard Cross May 24, 2022

An alternative method is to use the Confluence REST API with jq, for example:

curl -s -n \
-H "Accept: application/json" \
'https://myconfluence.server/rest/api/group/nexus-users/member'| jq -r .size

 

However... there is a limit of 200 results by default, so for groups with more than 200 users, you will need something a little more elaborate that uses the pagination feature.

Here's a shell script I knocked together that copes with groups containing any number of users:

#!/usr/bin/env bash

groupname=$1
total=0
result=$(curl -s -n \
-H "Accept: application/json" \
"https://myconfluence.server/rest/api/group/${groupname}/member")
size=$(echo $result | jq -r '.size')
total=$((total+$size))
next_set=$(echo $result | jq -r ._links.next)
base=$(echo $result | jq -r ._links.base)

while [[ $next_set != "null" ]]
do
result=$(curl -s -n -H "Accept: application/json" "${base}${next_set}")
size=$(echo $result | jq -r '.size')
total=$((total+$size))
echo running total: $total # this is optional
next_set=$(echo $result | jq -r ._links.next)
done

echo Total members in $groupname is: $total

which when called, looks something like this:

➜ ./count_group_members.sh my-test-group
running total: 400
running total: 600
running total: 800
running total: 1000
Total members in my-test-group is: 1008

 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events