Summary

The deleteLostCollectors() mutation removes collector registrations that have not sent data to LogScale for at least a specified number of days. LogScale considers a collector lost when it exceeds the configured inactivity threshold. Use this mutation to remove stale registrations from your fleet. Because this operation is irreversible, the dryRun argument defaults to true, letting you confirm the count of affected collectors before you commit the deletion.

Syntax

graphql
deleteLostCollectors(
      dryRun: Boolean! = true, days: Int!
   ): Int!

The mutation requires two arguments. days specifies the minimum number of days of inactivity that qualifies a collector for deletion โ€” collectors last seen more than this many days ago are considered lost. dryRun controls whether the mutation performs the deletion or only counts matching collectors. The mutation returns the number of collectors deleted or, in dry-run mode, the number that would be deleted.

Example

Raw
graphql
mutation {
  deleteLostCollectors( 
     dryRun: false,
     days: 1
  )
}
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 {
  deleteLostCollectors( 
     dryRun: false,
     days: 1
  )
}"
}
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 {
  deleteLostCollectors( 
     dryRun: false,
     days: 1
  )
}"
}
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 { ^
  deleteLostCollectors(  ^
     dryRun: false, ^
     days: 1 ^
  ) ^
}" ^
} '
Windows Powershell and curl
powershell
curl.exe -X POST 
    -H "Authorization: Bearer $TOKEN"
    -H "Content-Type: application/json"
    -d '{"query" : "mutation {
  deleteLostCollectors( 
     dryRun: false,
     days: 1
  )
}"
}'
    "$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 {
  deleteLostCollectors( 
     dryRun: false,
     days: 1
  )
}";
$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 {
  deleteLostCollectors( 
     dryRun: false,
     days: 1
  )
}"
}'''

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 {
  deleteLostCollectors( 
     dryRun: false,
     days: 1
  )
}"
}
);


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": {
    "deleteLostCollectors": 2
  }
}

Input Parameters

Specify the minimum number of days of inactivity that qualifies a collector for deletion, and whether to perform a dry run or commit the deletion.

Table: Input Parameters and Datatypes

Parameter Type Required Default Description
This table contains all input parameters for this mutation.
days Int yes ย  The minimum number of days since a collector last communicated with LogScale for it to qualify for deletion. Collectors that have been inactive for at least this many days are considered lost and removed.
dryRun Boolean yes true When true, the mutation counts matching collectors but does not delete them. Set to false to perform the deletion. Run with true first to confirm the count before committing an irreversible deletion.

Returned Values

The mutation returns a non-null integer (Int!). When dryRun is false, the value is the number of collector registrations deleted. When dryRun is true, the value is the number of collectors that would be deleted if the mutation were run with dryRun set to false. A return value of 0 indicates no collectors matched the specified inactivity threshold.