Summary

The removeSavedQueryLabels() mutation removes one or more labels from a saved query. Labels organize and filter saved queries in LogScale. A saved query supports at most ten labels. When a saved query reaches the limit, remove labels here before adding new ones with addSavedQueryLabels(). The mutation returns the updated SavedQuery object on success, or null on failure.

Syntax

graphql
removeSavedQueryLabels(
      input: RemoveSavedQueryLabels!
   ): SavedQuery

The mutation takes a single required input argument of type RemoveSavedQueryLabels!.

Hide Query Example

Show Saved Query Identifiers Query

Input parameters

Provide the view or repository name, saved query ID, and labels to remove. The viewName field accepts a repository name or view name. The id field is the unique identifier, not the display name. Use the repository() query to retrieve saved query IDs, as shown in the Syntax section. Labels not present on the saved query are silently ignored.

Table: RemoveSavedQueryLabels Input Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
idStringyes   Id of the saved query.
labelsStringyes   Labels to remove from the saved query, at most 100 at a time.
viewNameRepoOrViewNameyes   Name of the view of the saved query.

Example

Raw
graphql
mutation {
  removeSavedQueryLabels(
    input: { 
      viewName: "humio",
      id: "abc123",
      labels: [ "bobs-savedqueries" ]
    }
  )
  { labels }
}
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 {
  removeSavedQueryLabels(
    input: { 
      viewName: \"humio\",
      id: \"abc123\",
      labels: [ \"bobs-savedqueries\" ]
    }
  )
  { labels }
}"
}
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 {
  removeSavedQueryLabels(
    input: { 
      viewName: \"humio\",
      id: \"abc123\",
      labels: [ \"bobs-savedqueries\" ]
    }
  )
  { labels }
}"
}
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 { ^
  removeSavedQueryLabels( ^
    input: {  ^
      viewName: \"humio\", ^
      id: \"abc123\", ^
      labels: [ \"bobs-savedqueries\" ] ^
    } ^
  ) ^
  { labels } ^
}" ^
} '
Windows Powershell and curl
powershell
curl.exe -X POST 
    -H "Authorization: Bearer $TOKEN"
    -H "Content-Type: application/json"
    -d '{"query" : "mutation {
  removeSavedQueryLabels(
    input: { 
      viewName: \"humio\",
      id: \"abc123\",
      labels: [ \"bobs-savedqueries\" ]
    }
  )
  { labels }
}"
}'
    "$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 {
  removeSavedQueryLabels(
    input: { 
      viewName: \"humio\",
      id: \"abc123\",
      labels: [ \"bobs-savedqueries\" ]
    }
  )
  { labels }
}";
$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 {
  removeSavedQueryLabels(
    input: { 
      viewName: \"humio\",
      id: \"abc123\",
      labels: [ \"bobs-savedqueries\" ]
    }
  )
  { labels }
}"
}'''

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 {
  removeSavedQueryLabels(
    input: { 
      viewName: \"humio\",
      id: \"abc123\",
      labels: [ \"bobs-savedqueries\" ]
    }
  )
  { labels }
}"
}
);


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": {
    "removeSavedQueryLabels": {
      "labels": [ "admin-focus" ],
    }
  }
}

Returned values

This mutation returns a SavedQuery object on success. Use labels to confirm which labels remain after the removal. The following table lists all available fields.