Summary

The disableLegacyAlert() mutation disables an existing legacy alert in a repository or view, preventing it from firing. Use this mutation to suspend an alert without deleting its configuration. To resume the alert later, use enableLegacyAlert().

Syntax

graphql
disableLegacyAlert(
      input: DisableAlert!
   ): Alert

The input argument is required and takes a DisableAlert object. Provide the unique identifier of the alert to disable and the name of the associated view or repository. Use the following expandable query to retrieve alert identifiers.

The mutation returns a nullable Alert object. The Returned Values section describes the available fields, including the alert's current state, query string, associated actions, and any error messages from its last execution.

Hide Query Example

Show Alert Identifiers Query

Example

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

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 {
  disableLegacyAlert( input:
    { viewName: \"humio\",
      id: \"abc123\"
    } )
  { id, enabled }
}"
}
);


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": {
    "disableLegacyAlert": {
      "id": "abc123",
      "enabled": false
    }
  }
}

Input Parameters

Provide the unique identifier of the legacy alert to disable and the name of the associated view or repository. Use the expandable query in the Syntax section to retrieve alert identifiers.

Returned Values

The mutation returns a nullable Alert object containing the alert's updated state, including its query string, associated actions, and any error messages from its last execution. The mutation returns null if the alert is not found. The following table lists the available fields.