Summary

The checkLocalClusterConnection() GraphQL query validates a local cluster connection to confirm it is configured correctly and reachable.

Hide Query Example

Show Cluster Nodes Query

Syntax

graphql
checkLocalClusterConnection(
      input: CheckLocalClusterConnectionInput!
   ): LocalClusterConnectionStatus!

For the input, targetViewName (required) identifies the local view to connect with. connectionId is optional — omit it to perform a pre-flight check before creating a new connection. tags and queryPrefix can further restrict query visibility through the connection. See Input Parameters for details.

For the results, primarily request isValid and errorMessages. See Returned Values for all options.

Example

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

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" : "query {
	checkLocalClusterConnection(
	   input:
	     {targetViewName: \"humio\"} ) 
	  { id,
	    viewName, 
	    isValid, 
	    errorMessages{ error } }
}"
}
);


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": {
    "checkLocalClusterConnection": {
      "id": null,
      "viewName": "humio",
      "isValid": true,
      "errorMessages": []
    }
  }
}

Input Parameters

Supply at minimum the required targetViewName. Optionally provide connectionId to check an existing connection, tags to filter queries by tag, and queryPrefix to restrict the data visible through the connection. The parameters are listed here:

Table: CheckLocalClusterConnectionInput Input Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
connectionIdString    Id of the connection to check
queryPrefixString    Filter query that restricts the data visible through this connection
tagsClusterConnectionInputTagyes   Additional tags that can be used to filter queries
targetViewNameStringyes   Name or id of the local view to connect with

Returned Values

For the results, isValid indicates whether the connection is valid, and errorMessages lists any connection errors when it is not. You can also get the connection's id and the viewName of the local view. The available fields are listed here:

Table: LocalClusterConnectionStatus Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
errorMessages[ConnectionAspectErrorType]yes Short-Term Errors if the connection is invalid. See ConnectionAspectErrorType.
idstring  Short-Term The unique identifier of the connection.
isValidbooleanyes Short-Term Whether the connection is valid.
viewNamestring  Short-Term The name of the local view.