Summary

The refreshClusterManagementStats() mutation forces a recalculation of the ClusterManagementStats cache for a specified cluster node. It bypasses cached values to query live node state and returns the reasonsNodeCannotBeSafelyUnregistered field for that node.

Call this mutation before calling clusterUnregisterNode() when automating the removal of evicted cluster nodes. Check the returned reasonsNodeCannotBeSafelyUnregistered field to determine whether the node can be safely removed. If isAlive is true, the node is still responding and must not be unregistered. If hasUnderReplicatedData is true, the node holds data not yet replicated to other nodes. Both conditions must be false before you unregister the node, to prevent data loss. Because this mutation performs live cluster queries, it is resource-intensive. Do not call it in polling loops or at high frequency.

Syntax

graphql
refreshClusterManagementStats(
      nodeId: Int!
   ): RefreshClusterManagementStatsMutation!

The required nodeId argument identifies the cluster node for which to retrieve refreshed statistics. Use the cluster() query to find node IDs before calling this mutation.

The mutation returns a non-null RefreshClusterManagementStatsMutation object. Request the isAlive and hasUnderReplicatedData sub-fields on reasonsNodeCannotBeSafelyUnregistered to evaluate whether the node is safe to unregister.

Example

Raw
graphql
mutation {
  refreshClusterManagementStats( nodeId: 3 )
    { reasonsNodeCannotBeSafelyUnregistered { isAlive, hasUnderReplicatedData } }
}
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 {
  refreshClusterManagementStats( nodeId: 3 )
    { reasonsNodeCannotBeSafelyUnregistered { isAlive, hasUnderReplicatedData } }
}"
}
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 {
  refreshClusterManagementStats( nodeId: 3 )
    { reasonsNodeCannotBeSafelyUnregistered { isAlive, hasUnderReplicatedData } }
}"
}
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 { ^
  refreshClusterManagementStats( nodeId: 3 ) ^
    { reasonsNodeCannotBeSafelyUnregistered { isAlive, hasUnderReplicatedData } } ^
}" ^
} '
Windows Powershell and curl
powershell
curl.exe -X POST 
    -H "Authorization: Bearer $TOKEN"
    -H "Content-Type: application/json"
    -d '{"query" : "mutation {
  refreshClusterManagementStats( nodeId: 3 )
    { reasonsNodeCannotBeSafelyUnregistered { isAlive, hasUnderReplicatedData } }
}"
}'
    "$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 {
  refreshClusterManagementStats( nodeId: 3 )
    { reasonsNodeCannotBeSafelyUnregistered { isAlive, hasUnderReplicatedData } }
}";
$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 {
  refreshClusterManagementStats( nodeId: 3 )
    { reasonsNodeCannotBeSafelyUnregistered { isAlive, hasUnderReplicatedData } }
}"
}'''

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 {
  refreshClusterManagementStats( nodeId: 3 )
    { reasonsNodeCannotBeSafelyUnregistered { isAlive, hasUnderReplicatedData } }
}"
}
);


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();

Input Parameters

Provide the ID of the cluster node for which to retrieve refreshed statistics. Use the cluster() query to find node IDs before calling this mutation.

Table: Input Parameters & Datatypes

Parameter Type Required Default Description
This table contains all input parameters for this mutation.
nodeId Int yes   The integer ID of the cluster node for which to retrieve refreshed management statistics. Obtain this value from the cluster() query.

Returned Values

The mutation returns a RefreshClusterManagementStatsMutation object. The key field is reasonsNodeCannotBeSafelyUnregistered, which lists conditions that prevent safe unregistration. When this field returns an empty result, the node is safe to unregister. The sub-fields isAlive and hasUnderReplicatedData identify specific blocking conditions: a node that is still alive or holds data not yet replicated to other nodes must not be unregistered.

Table: RefreshClusterManagementStatsMutation Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
reasonsNodeCannotBeSafelyUnregisteredReasonsNodeCannotBeSafelyUnregisteredyes Preview The reasons the node cannot be safely unregistered. See ReasonsNodeCannotBeSafelyUnregistered.