Summary

The addOrUpdateQueryQuotaUserSettings() mutation creates or updates query quota settings for a specific user. Query quotas limit the query resources a user can consume within a defined time interval, protecting cluster performance. Use this mutation to assign per-user quota overrides. These override the organization-wide default configured by addOrUpdateQueryQuotaDefaultSettings().

Syntax

graphql
addOrUpdateQueryQuotaUserSettings(
      input: QueryQuotaUserSettingsInput!
   ): QueryQuotaUserSettings!

The mutation accepts a single required input argument of type QueryQuotaUserSettingsInput. This input identifies the target user by username and specifies one or more quota interval configurations. The mutation returns a non-null QueryQuotaUserSettings object containing the saved quota configuration.

Example

Raw
graphql
mutation {
  addOrUpdateQueryQuotaUserSettings(input: 
       { username: "tester", 
         settings: [ {interval: PerDay, measurementKind: QueryCount, 
                      valueKind: Limited, value: 1000 } ] } )
  { settings { interval, value } }
}
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" : "mutation {
  addOrUpdateQueryQuotaUserSettings(input: 
       { username: \"tester\", 
         settings: [ {interval: PerDay, measurementKind: QueryCount, 
                      valueKind: Limited, value: 1000 } ] } )
  { settings { interval, value } }
}"
}
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" : "mutation {
  addOrUpdateQueryQuotaUserSettings(input: 
       { username: \"tester\", 
         settings: [ {interval: PerDay, measurementKind: QueryCount, 
                      valueKind: Limited, value: 1000 } ] } )
  { settings { interval, value } }
}"
}
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" : "mutation { ^
  addOrUpdateQueryQuotaUserSettings(input:  ^
       { username: \"tester\",  ^
         settings: [ {interval: PerDay, measurementKind: QueryCount,  ^
                      valueKind: Limited, value: 1000 } ] } ) ^
  { settings { interval, value } } ^
}" ^
} '
Windows Powershell and curl
powershell
curl.exe -X POST 
    -H "Authorization: Bearer $TOKEN"
    -H "Content-Type: application/json"
    -d '{"query" : "mutation {
  addOrUpdateQueryQuotaUserSettings(input: 
       { username: \"tester\", 
         settings: [ {interval: PerDay, measurementKind: QueryCount, 
                      valueKind: Limited, value: 1000 } ] } )
  { settings { interval, value } }
}"
}'
    "$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 = "mutation {
  addOrUpdateQueryQuotaUserSettings(input: 
       { username: \"tester\", 
         settings: [ {interval: PerDay, measurementKind: QueryCount, 
                      valueKind: Limited, value: 1000 } ] } )
  { settings { interval, value } }
}";
$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" : "mutation {
  addOrUpdateQueryQuotaUserSettings(input: 
       { username: \"tester\", 
         settings: [ {interval: PerDay, measurementKind: QueryCount, 
                      valueKind: Limited, value: 1000 } ] } )
  { settings { interval, value } }
}"
}'''

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" : "mutation {
  addOrUpdateQueryQuotaUserSettings(input: 
       { username: \"tester\", 
         settings: [ {interval: PerDay, measurementKind: QueryCount, 
                      valueKind: Limited, value: 1000 } ] } )
  { settings { interval, value } }
}"
}
);


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": {
    "addOrUpdateQueryQuotaUserSettings": {
      "settings": [
        {
          "interval": "PerDay",
          "value": 1000
        }
      ]
    }
  }
}

Input Parameters

The input argument accepts a QueryQuotaUserSettingsInput object containing the target username and one or more interval quota configurations. Each configuration uses the QueryQuotaIntervalSettingInput sub-datatype to specify the interval, measurement kind, and quota value.

Table: QueryQuotaUserSettingsInput Input Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
settingsQueryQuotaIntervalSettingInputyes Short-Term The query quota settings for the user. See QueryQuotaIntervalSettingInput.
usernameStringyes Short-Term The username for which to set the query quota.

The QueryQuotaUserSettingsInput datatype contains a settings field that accepts a list of QueryQuotaIntervalSettingInput objects. The fields for that sub-datatype are listed in the following table.

Table: QueryQuotaIntervalSettingInput Input Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
intervalQueryQuotaIntervalyes Short-Term The query quota time interval to use. See QueryQuotaInterval.
measurementKindQueryQuotaMeasurementKindyes Short-Term The kind of measurement used for the query quota. See QueryQuotaMeasurementKind.
valueLong  Short-Term The amount to set for the query quota.
valueKindQueryQuotaIntervalSettingKindyes Short-Term The kind of query quota setting. See QueryQuotaIntervalSettingKind.

Returned Values

The mutation returns a non-null QueryQuotaUserSettings object containing the saved quota configuration for the target user. This includes the username, quota interval, and measurement method. Request these fields to confirm the applied settings or to display quota details in administrative tooling.

Table: QueryQuotaUserSettings Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
settingsQueryQuotaIntervalSettingyes Short-Term List of the settings that apply. See QueryQuotaIntervalSetting.
usernameStringyes Short-Term Username of the user for which these Query Quota settings apply.

Table: QueryQuotaIntervalSetting Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
intervalQueryQuotaIntervalyes Short-Term The interval for setting the query quota. See QueryQuotaInterval.
measurementKindQueryQuotaMeasurementKindyes Short-Term The kind of measurement. See QueryQuotaMeasurementKind.
sourceQueryQuotaIntervalSettingSourceyes Short-Term The source of the query quota. See QueryQuotaIntervalSettingSource.
valueLong  Short-Term The query quota value.
valueKindQueryQuotaIntervalSettingKindyes Short-Term The kind of value. See QueryQuotaIntervalSettingKind.