Summary

The groupByDisplayName() GraphQL query returns details for the group with the given display name. Use this as an alternative to group() when the display name is known but the group ID is not.

Syntax

graphql
groupByDisplayName(
      displayName: String!
   ): Group!

Provide the group's display name as displayName (required). Note that display names are case-sensitive. See Returned Values for available fields.

Example

Raw
graphql
query{
  groupByDisplayName(displayName: "chiefs") {
    id, users {
      id, username, displayName
    }
  }
}
Mac OS or Linux (curl)
shell
curl -v -X POST $YOUR_LOGSCALE_URL/graphql \
    -H "Authorization: Bearer $TOKEN" \
    -H "Content-Type: application/json" \
    -d @- << EOF
{"query" : "query{
  groupByDisplayName(displayName: \"chiefs\") {
    id, users {
      id, username, displayName
    }
  }
}"
}
EOF
Mac OS or Linux (curl) One-line
shell
curl -v -X POST $YOUR_LOGSCALE_URL/graphql \
    -H "Authorization: Bearer $TOKEN" \
    -H "Content-Type: application/json" \
    -d @- << EOF
{"query" : "query{
  groupByDisplayName(displayName: \"chiefs\") {
    id, users {
      id, username, displayName
    }
  }
}"
}
EOF
Windows Cmd and curl
shell
curl -v -X POST $YOUR_LOGSCALE_URL/graphql ^
    -H "Authorization: Bearer $TOKEN" ^
    -H "Content-Type: application/json" ^
    -d @'{"query" : "query{ ^
  groupByDisplayName(displayName: \"chiefs\") { ^
    id, users { ^
      id, username, displayName ^
    } ^
  } ^
}" ^
} '
Windows Powershell and curl
powershell
curl.exe -X POST 
    -H "Authorization: Bearer $TOKEN"
    -H "Content-Type: application/json"
    -d '{"query" : "query{
  groupByDisplayName(displayName: \"chiefs\") {
    id, users {
      id, username, displayName
    }
  }
}"
}'
    "$YOUR_LOGSCALE_URL/graphql"
Perl
perl
#!/usr/bin/perl

use HTTP::Request;
use LWP;

my $TOKEN = "TOKEN";

my $uri = '$YOUR_LOGSCALE_URL/graphql';

my $query = "query{
  groupByDisplayName(displayName: \"chiefs\") {
    id, users {
      id, username, displayName
    }
  }
}";
$query =~ s/\n/ /g;
my $json = sprintf('{"query" : "%s"}',$query);
my $req = HTTP::Request->new("POST", $uri );

$req->header("Authorization" => "Bearer $TOKEN");
$req->header("Content-Type" => "application/json");

$req->content( $json );

my $lwp = LWP::UserAgent->new;

my $result = $lwp->request( $req );

print $result->{"_content"},"\n";
Python
python
#! /usr/local/bin/python3

import requests

url = '$YOUR_LOGSCALE_URL/graphql'
mydata = r'''{"query" : "query{
  groupByDisplayName(displayName: \"chiefs\") {
    id, users {
      id, username, displayName
    }
  }
}"
}'''

resp = requests.post(url,
                     data = mydata,
                     headers = {
   "Authorization" : "Bearer $TOKEN",
   "Content-Type" : "application/json"
}
)

print(resp.text)
Node.js
javascript
const https = require('https');

const data = JSON.stringify(
    {"query" : "query{
  groupByDisplayName(displayName: \"chiefs\") {
    id, users {
      id, username, displayName
    }
  }
}"
}
);


const options = {
  hostname: '$YOUR_LOGSCALE_URL',
  path: 'graphql',
  port: 443,
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Content-Length': data.length,
    Authorization: 'BEARER ' + process.env.TOKEN,
    'User-Agent': 'Node',
  },
};

const req = https.request(options, (res) => {
  let data = '';
  console.log(`statusCode: ${res.statusCode}`);

  res.on('data', (d) => {
    data += d;
  });
  res.on('end', () => {
    console.log(JSON.parse(data).data);
  });
});

req.on('error', (error) => {
  console.error(error);
});

req.write(data);
req.end();
Example Responses
Success (HTTP Response Code 200 OK)
json
{
  "data": {
    "groupByDisplayName": {
      "id": "BHdJstvjgDUjXg10KrbjiybpSbOHIw1b",
      "users": [
        {
          "id": "czN4YDhpmZ1JrZnJ4bkQzK52",
          "username": "tom",
          "displayName": "Tom Hanks"
        },
        {
          "id": "mQ2oDkHSLhTG6l6ppsmxJYHJ",
          "username": "steve",
          "displayName": "Steve McQueen"
        },
        {
          "id": "TMc2x9a2APnkGvyMJQbxgcOU",
          "username": "bob",
          "displayName": "Bob Newhart"
        }
      ]
    }
  }
}

This example requests first the ID for the group, then a list or array of users in the group. For each user, it calls for the user's ID, the username, and the display name of the user.

Returned Values

Returns a non-nullable Group object with the same fields as group(). Identity fields include id, displayName, and lookupName (nullable โ€” when set, used instead of displayName for IdP/SSO group synchronization matching). Access control fields include defaultRole, defaultQueryPrefix (nullable โ€” a search filter prepended to every query by group members), roles, systemRoles, organizationRoles, and queryPrefixes. User fields include userCount and users. The available fields are listed here: