Summary

The removeLegacyAlertLabels() mutation removes one or more labels from a legacy alert in a LogScale repository or view. Each legacy alert supports at most ten labels. Use this mutation to free up label capacity before adding new ones with addLegacyAlertLabels(). The mutation returns the updated legacy alert on success, or null with errors on failure.

Syntax

graphql
removeLegacyAlertLabels(
      input: RemoveLegacyAlertLabels!
   ): Alert

The required input argument takes a RemoveLegacyAlertLabels object specifying the target repository or view name, the legacy alert ID, and the list of labels to remove. See the Returned values section for the available return fields.

Hide Query Example

Show Legacy Alert Identifiers Query

Input parameters

Provide the viewName of the repository or view that owns the alert, the id of the legacy alert, and a labels array of label strings to remove. Use the query in the preceding Syntax section to retrieve alert identifiers.

Example

Raw
graphql
mutation {
  removeLegacyAlertLabels(input: {
    viewName: "humio",
    id: "abc123", 
    labels: [ "key-alerts" ]
  )
  {enabled, 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 {
  removeLegacyAlertLabels(input: {
    viewName: \"humio\",
    id: \"abc123\", 
    labels: [ \"key-alerts\" ]
  )
  {enabled, 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 {
  removeLegacyAlertLabels(input: {
    viewName: \"humio\",
    id: \"abc123\", 
    labels: [ \"key-alerts\" ]
  )
  {enabled, 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 { ^
  removeLegacyAlertLabels(input: { ^
    viewName: \"humio\", ^
    id: \"abc123\",  ^
    labels: [ \"key-alerts\" ] ^
  ) ^
  {enabled, labels } ^
}" ^
} '
Windows Powershell and curl
powershell
curl.exe -X POST 
    -H "Authorization: Bearer $TOKEN"
    -H "Content-Type: application/json"
    -d '{"query" : "mutation {
  removeLegacyAlertLabels(input: {
    viewName: \"humio\",
    id: \"abc123\", 
    labels: [ \"key-alerts\" ]
  )
  {enabled, 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 {
  removeLegacyAlertLabels(input: {
    viewName: \"humio\",
    id: \"abc123\", 
    labels: [ \"key-alerts\" ]
  )
  {enabled, 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 {
  removeLegacyAlertLabels(input: {
    viewName: \"humio\",
    id: \"abc123\", 
    labels: [ \"key-alerts\" ]
  )
  {enabled, 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 {
  removeLegacyAlertLabels(input: {
    viewName: \"humio\",
    id: \"abc123\", 
    labels: [ \"key-alerts\" ]
  )
  {enabled, 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": {
    "removeLegacyAlertLabels": {
      "enabled": true,
      "labels": [ "night-shift",
                  "admin-focus" ]
    }
  }
}

Returned values

The mutation returns the updated Alert object on success, or null with errors on failure. Include labels in your return fields to confirm which labels remain. queryString contains the LogScale query that triggers the alert. throttleTimeMillis specifies the suppression window in milliseconds; a null value indicates no throttle is active. lastError reports the most recent execution error from the alert.