Summary

The createLogCollectorConfiguration() mutation creates a named Log Collector configuration in LogScale. A configuration holds the YAML settings that control how a Log Collector instance ingests and forwards data. Newly created configurations are inactive — they do not affect any Log Collector instance until you assign the configuration with assignLogCollectorConfiguration() and publish it with publishLogCollectorConfiguration().

You can optionally supply a draft at creation time using the draft argument. The draft is a staging area separate from the active published YAML. If you omit draft, the configuration is created with no content; add content later with updateDraftLogCollectorConfiguration(). Retrieve the id from the response — all subsequent mutations that modify or assign this configuration require it.

Syntax

graphql
createLogCollectorConfiguration(
      name: String!, draft: String
   ): LogCollectorConfiguration!

The name argument is required and sets the human-readable identifier for the configuration. This name appears in the LogScale UI and in API responses that list configurations. The optional draft argument supplies initial YAML content conforming to the Log Collector configuration schema. Draft content is separate from the active published YAML; it does not affect running Log Collector instances until you call publishLogCollectorConfiguration().

The mutation returns a non-null LogCollectorConfiguration object. On a newly created configuration, yaml is null because no version has been published yet. Request id to obtain the configuration identifier required by subsequent mutations.

Example

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

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 {
  createLogCollectorConfiguration(
         name: \"my-lc-config\" )
  { id, name }
}"
}
);


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": {
    "createLogCollectorConfiguration": {
      "id": "abc123",
      "name": "my-lc-config"
    }
  }
}

Input Parameters

Provide a unique name for the new configuration. Optionally, provide initial YAML draft content to populate the staging area at creation time.

Table: Input Parameters & Datatypes

Parameter Type Required Default Description
This table contains all input parameters for this mutation.
draft String     The initial YAML content for the configuration staging area. The YAML must conform to the Log Collector configuration schema. Draft content is held separately from the active published configuration and does not affect running Log Collector instances until you call publishLogCollectorConfiguration(). Omitting this argument creates the configuration with no draft content; add content later with updateDraftLogCollectorConfiguration().
name String yes   The unique name for the new Log Collector configuration. This name is displayed in the LogScale UI and returned in API responses that list configurations. Use it to identify the configuration when assigning it to a Log Collector instance.

Returned Values

The mutation returns a LogCollectorConfiguration object representing the newly created configuration. Always request id — all subsequent mutations that modify, assign, or delete this configuration require it.

The version field is an integer counter that starts at 0 on a new configuration and increments with each call to publishLogCollectorConfiguration(). Store this value and pass it as currentVersion in that mutation to enforce optimistic concurrency control: the publish fails if another caller has updated the configuration since you last read it.

The yaml field is null on a newly created configuration because no version has been published yet; it contains the active published YAML only after the first call to publishLogCollectorConfiguration(). The yamlCharactersCount field reflects the character count of that published YAML, and is 0 until a version is published. The draft field holds the YAML content passed in the draft argument, or null if you omitted it; the draftModifiedAt field records when the draft was last modified, or null if no draft has been set.

The instances field is 0 on a newly created configuration; it increments as Log Collector instances are assigned with assignLogCollectorConfiguration(). The isTestRunning field is false on a new configuration; it becomes true when a configuration test is started with startLogCollectorConfigurationTest(). The description field is null at creation time; set it after creation with updateLogCollectorConfigurationDescription(). The modifiedAt and modifiedBy fields record when the configuration was created and by which user.

Table: LogCollectorConfiguration Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
descriptionString  Short-Term A description of the Log Collector configuration.
draftString  Short-Term The configuration draft.
draftModifiedAtDateTime  Short-Term The date and time of the last draft of the configuration.
idStringyes Short-Term The unique identifier for the log collector configuration.
instancesIntyes Short-Term The number of instances.
isTestRunningBooleanyes Short-Term Whether a test is running.
modifiedAtDateTimeyes Short-Term The date and time of the current configuration.
modifiedByStringyes Short-Term Who last modified the configuration.
nameStringyes Short-Term The name assigned to the log collector configuration.
versionIntyes Short-Term The version used.
yamlString  Short-Term Configuration in YAML format.
yamlCharactersCountIntyes Short-Term The yaml character count.