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
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.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.