Summary

The setSegmentReplicationFactor() mutation controls how many copies of each segment the cluster maintains. LogScale stores ingested data as immutable compressed segment files distributed across nodes. The replication factor determines how many distinct node copies of each segment exist. A factor of 1 means a single copy with no redundancy. If that node becomes unavailable, the segment data is inaccessible until the node recovers. A higher factor provides fault tolerance. LogScale can serve segment data from a surviving replica when a node fails. Each additional copy increases storage proportionally. The replication factor cannot meaningfully exceed the number of available nodes. This mutation applies to segments written after the change. To also move existing segments to satisfy the new factor, use setAllowRebalanceExistingSegments().

Syntax

graphql
setSegmentReplicationFactor(
      segmentReplicationFactor: Int!
   ): Int!

The segmentReplicationFactor argument specifies the target number of segment copies across cluster nodes. Pass 1 to disable replication and maintain a single copy per segment. Pass a higher integer to enable redundancy across that many nodes. The mutation returns Int!.

Input parameters

Provide a positive integer specifying the number of segment copies to maintain across cluster nodes.

Table: Input parameters and datatypes

Parameter Type Required Default Description
This table contains all input parameters for this mutation.
segmentReplicationFactor Int! yes ย  The number of copies LogScale maintains for each segment across cluster nodes. A value of 1 disables replication; a single copy exists per segment with no redundancy. Higher values distribute that many copies across separate nodes. This provides fault tolerance at the cost of additional storage. Setting this higher than the node count has no additional effect.

Example

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

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 {
  setSegmentReplicationFactor(
       segmentReplicationFactor: 10
  )
}"
}
);


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": {
    "setSegmentReplicationFactor": 10
  }
}

Returned values

The mutation returns Int! reflecting the applied replication factor. Confirm this value matches the integer you provided to verify the mutation succeeded.