Summary

The blockedQueries() GraphQL query returns the list of blocked query patterns. Blocked queries prevent matching queries from running, supporting resource management and access control. Each entry can match by exact string or by regex pattern. By default, the query returns patterns visible to the current organization; set clusterWide to return patterns across the entire cluster.

Syntax

graphql
blockedQueries(
      clusterWide: Boolean = false,
      includeBlockedQueriesForDeletedOrganizations: Boolean = false
   ): [BlockedQuery!]!

Both input parameters are optional and default to false. Set clusterWide to true to return all blocked queries across the cluster (requires the ManageCluster permission). Set includeBlockedQueriesForDeletedOrganizations to true to include patterns tied to deleted organizations. See Input Parameters for details.

The results can include a regex pattern used to filter queries before they are executed. You can also get related information such as data on the associated view, when blocking expires, and so on.

Example

Raw
graphql
query {
	blockedQueries 
	  { id, type, pattern }
}
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 {
	blockedQueries 
	  { id, type, pattern }
}"
}
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 {
	blockedQueries 
	  { id, type, pattern }
}"
}
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 { ^
	blockedQueries  ^
	  { id, type, pattern } ^
}" ^
} '
Windows Powershell and curl
powershell
curl.exe -X POST 
    -H "Authorization: Bearer $TOKEN"
    -H "Content-Type: application/json"
    -d '{"query" : "query {
	blockedQueries 
	  { id, type, pattern }
}"
}'
    "$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 {
	blockedQueries 
	  { id, type, pattern }
}";
$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 {
	blockedQueries 
	  { id, type, pattern }
}"
}'''

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 {
	blockedQueries 
	  { id, type, pattern }
}"
}
);


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": {
    "blockedQueries": [
      {
        "id": "abc123",
        "type": "REGEX",
        "pattern": "#type=humio"
      },
      {
        "id": "def456",
        "type": "REGEX",
        "pattern": "#type=testerroo"
      }
    ]
  }
}

Notice that the example above requests three values, separated by commas. Since there were two blocked queries, two sets of values were returned, each in square brackets.

Input Parameters

For the input, indicate whether to return all blocked queries within the cluster and whether to include blocked queries for deleted organizations. Both parameters are optional and default to false.

Table: Input Parameters & Datatypes

Parameter Type Required Default Description
This table contains all input parameters for this query.
clusterWide Boolean No false Whether to return all blocked queries within the cluster. Requires the ManageCluster permission.
includeBlockedQueriesForDeletedOrganizations Boolean No false Whether to include blocked queries of deleted organizations.

Returned Values

The result is a non-nullable list of BlockedQuery objects. Each entry includes the unique identifier (id) and pattern string (pattern), the match type (type: EXACT or REGEX), and expiration data (expiresAt and expiresInMilliseconds, both nullable). The associated view (view) and owning organization (organization) are also available (both nullable). limitedToOrganization indicates whether the block is scoped to an organization, and unblockAllowed indicates whether the current user can remove the pattern. The available fields are listed here:

Table: BlockedQuery Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
expiresAtDateTime  Long-Term  
expiresInMillisecondsInt  Long-Term  
idStringyes Long-Term  
limitedToOrganizationBooleanyes Long-Term  
organizationOrganization  Long-Term The organization owning the pattern or view, if any.
patternStringyes Long-Term  
typeBlockedQueryMatcherTypeyes Long-Term  
unblockAllowedBooleanyes Long-Term True if the current actor is allowed the remove this pattern
viewView  Long-Term Â