Summary

The searchDataDistribution() GraphQL query returns segment data distribution statistics for a repository or view within a time range. Views with multiple connections return per-repository results.

Syntax

graphql
searchDataDistribution(
      input: SearchDataDistributionInput!
   ): SearchDataDistributionResult!

Provide the query string for tag-based datasource filtering and the name of the search domain to analyze. See the Input Parameters section for more.

Returns a non-nullable SearchDataDistributionResult object. See the Returned Values section for more details.

Example

Raw
graphql
query {
  searchDataDistribution(
    input: { queryString: "something",
             searchDomainName: "our_view" }
  ) repositories { repositoryId, repositoryName }
}
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 {
  searchDataDistribution(
    input: { queryString: \"something\",
             searchDomainName: \"our_view\" }
  ) repositories { repositoryId, repositoryName }
}"
}
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 {
  searchDataDistribution(
    input: { queryString: \"something\",
             searchDomainName: \"our_view\" }
  ) repositories { repositoryId, repositoryName }
}"
}
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 { ^
  searchDataDistribution( ^
    input: { queryString: \"something\", ^
             searchDomainName: \"our_view\" } ^
  ) repositories { repositoryId, repositoryName } ^
}" ^
} '
Windows Powershell and curl
powershell
curl.exe -X POST 
    -H "Authorization: Bearer $TOKEN"
    -H "Content-Type: application/json"
    -d '{"query" : "query {
  searchDataDistribution(
    input: { queryString: \"something\",
             searchDomainName: \"our_view\" }
  ) repositories { repositoryId, repositoryName }
}"
}'
    "$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 {
  searchDataDistribution(
    input: { queryString: \"something\",
             searchDomainName: \"our_view\" }
  ) repositories { repositoryId, repositoryName }
}";
$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 {
  searchDataDistribution(
    input: { queryString: \"something\",
             searchDomainName: \"our_view\" }
  ) repositories { repositoryId, repositoryName }
}"
}'''

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 {
  searchDataDistribution(
    input: { queryString: \"something\",
             searchDomainName: \"our_view\" }
  ) repositories { repositoryId, repositoryName }
}"
}
);


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": {
    "searchDataDistribution": {
      "repositories" { 
          [{ "repositoryId": "abc123",
             "repositoryName": "repo_1" },
           { "repositoryId": "def456",
             "repositoryName": "repo_2" },
          ]
      },
    }
  }
}

Input Parameters

Provide the query string for tag-based datasource filtering and the name of the repository or view to analyze. There are a few optional parameters, listed and described in the table below:

Table: SearchDataDistributionInput Input Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
argumentsQueryArgumentInputTypeyes   Query arguments for parameterized queries.
includeEmptyRepositoriesBoolean   added in 1.267Whether to include repositories where no datasource matches the query or no matching datasource has segments in the time range. Repositories the query can never target are always excluded. Defaults to false.
maxDatasourcesInt    Maximum number of datasources to return. Defaults to 1000.
maxTagEntriesInt    Maximum number of tag distribution entries to return. Defaults to 200.
queryStringStringyes   Query string for tag-based datasource filtering. Empty string matches all datasources.
searchDomainNameStringyes   The repository or view to analyze. Views with multiple connections return per-repository results.
timeBucketsInt    Number of time buckets for the distribution histogram. Defaults to 50, max 50.
timeIntervalQueryTimeInterval    Optional time range. Defaults to last 24 hours if omitted.

Returned Values

Returns a non-nullable SearchDataDistributionResult object. The table below lists all fields:

Table: SearchDataDistributionResult Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
repositoriesSearchDataDistributionRepositoryyes Preview Per-repository distribution statistics.

The SearchDataDistributionResult type contains SearchDataDistributionRepository objects. For reference, the SearchDataDistributionRepository datatype table is included here:

Table: SearchDataDistributionRepository Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
datasourcesSearchDataDistributionDatasourceyes Preview Per-datasource segment statistics.
maxEventTimeLong  Preview Latest event timestamp (epoch ms) across all matching segments, if any.
maxIngestTimeLong  Preview Latest ingest timestamp (epoch ms) across all matching segments, if any.
minEventTimeLong  Preview Earliest event timestamp (epoch ms) across all matching segments, if any.
minIngestTimeLong  Preview Earliest ingest timestamp (epoch ms) across all matching segments, if any.
organizationIdString  Preview The organization that owns this repository, if any.
originStringyes Preview The query component that scans this repository. Values: 'query' for the main query, 'join-N' for join subqueries, 'defineTable-name' for table-building queries.
repositoryIdStringyes Preview The repository identifier.
repositoryNameStringyes Preview The repository name.
scanPercentageCompressedFloatyes Preview Percentage of repository compressed bytes that the search would scan.
scanPercentageOriginalFloatyes Preview Percentage of repository original bytes that the search would scan.
tagDistributionSearchDataDistributionTagDistributionEntryyes Preview Aggregated byte statistics per tag key-value pair across matching datasources.
timeDistributionSearchDataDistributionTimeDistributionyes Preview Segment distribution over time.
totalDatasourceCountIntyes Preview Total number of matching datasources before applying maxDatasources limit.
totalRepositoryCompressedBytesLongyes Preview Total compressed bytes across all datasources in the repository within the time range.
totalRepositoryOriginalBytesLongyes Preview Total original bytes across all datasources in the repository within the time range.
totalTagEntryCountIntyes Preview Total number of tag distribution entries before applying maxTagEntries limit.