Summary

The createFleetInstallToken() mutation creates a Fleet installation token in LogScale. Fleet installation tokens authorize the LogScale Collector to register with a Fleet management configuration during initial installation. Provision tokens before deploying collectors to new hosts. You can scope a token to a specific Fleet configuration at creation time by supplying configId, or leave it unbound and associate it later using updateFleetInstallTokenConfigId().

Syntax

graphql
createFleetInstallToken(
      name: String!,
      configId: String,
      expiresAt: Long
   ): FleetInstallationToken!

The name argument is required. The configId and expiresAt arguments are optional. The mutation returns a non-null FleetInstallationToken object containing the token value, installation commands, and configuration details.

Example

Raw
graphql
mutation {
  createFleetInstallToken(
        name: "my-token",
        configId: "123456")
  { token, jwtToken }
}
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 {
  createFleetInstallToken(
        name: \"my-token\",
        configId: \"123456\")
  { token, jwtToken }
}"
}
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 {
  createFleetInstallToken(
        name: \"my-token\",
        configId: \"123456\")
  { token, jwtToken }
}"
}
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 { ^
  createFleetInstallToken( ^
        name: \"my-token\", ^
        configId: \"123456\") ^
  { token, jwtToken } ^
}" ^
} '
Windows Powershell and curl
powershell
curl.exe -X POST 
    -H "Authorization: Bearer $TOKEN"
    -H "Content-Type: application/json"
    -d '{"query" : "mutation {
  createFleetInstallToken(
        name: \"my-token\",
        configId: \"123456\")
  { token, jwtToken }
}"
}'
    "$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 {
  createFleetInstallToken(
        name: \"my-token\",
        configId: \"123456\")
  { token, jwtToken }
}";
$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 {
  createFleetInstallToken(
        name: \"my-token\",
        configId: \"123456\")
  { token, jwtToken }
}"
}'''

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 {
  createFleetInstallToken(
        name: \"my-token\",
        configId: \"123456\")
  { token, jwtToken }
}"
}
);


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

The following table describes all input parameters for this mutation.

Table: Input Parameters & Datatypes

Parameter Type Required Default Description
This table contains all input parameters for this mutation.
configId string     The unique identifier of the Fleet installation configuration to associate with this token. When omitted, the token is not bound to a specific configuration. You can associate it later using updateFleetInstallTokenConfigId().
expiresAt long     The expiration time for the token, expressed as a Unix timestamp in milliseconds. After this time, the token cannot authorize new collector registrations. Collectors already registered before expiration are not affected. When omitted, the token does not expire.
name string yes   A display name for the installation token. This name identifies the token in Fleet management views and query results.

Returned Values

The mutation returns a non-null FleetInstallationToken object. Request the token field to obtain the token string to embed in collector installation commands. The jwtToken field returns a JWT-encoded form of the same token for use in secure transmission contexts. The following table lists all available fields.

Table: FleetInstallationToken Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
assignedConfigurationLogCollectorConfiguration  Short-Term The assigned configuration. See LogCollectorConfiguration.
expiresAtLong  Short-Term Stability: Short-term
installationCommandsLogCollectorInstallCommandyes Short-Term The installation commands. See LogCollectorInstallCommand.
jwtTokenStringyes Short-Term The JSON web token used.
nameStringyes Short-Term The name of the Fleet installation token.
tokenStringyes Short-Term The Fleet installation token used.