Summary

The createOrganizationsViews() mutation creates a metric view, a usage view, and a log view for each organization in the system. This is a root operation, meaning it operates across all organizations rather than within a single repository or view context. Use specificOrganization to limit view creation to a single named organization. Run this mutation during initial organization setup or when provisioning new organizations that require standard views.

Syntax

graphql
createOrganizationsViews(
      includeDebugView: Boolean,
      specificOrganization: String
   ): Boolean!

Both input arguments are optional. The mutation returns a non-null Boolean! value confirming whether the operation succeeded.

Example

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

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 {
  createOrganizationsViews(
         specificOrganization: \"SINGLE_ORGANIZATION_ID\"  )
}"
}
);


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": {
    "createOrganizationsViews": true
  }
}

Input Parameters

Both input parameters are optional. Omit both to create views for all organizations without a debug view.

Table: Input Parameters and Datatypes

Parameter Type Required Default Description
This table contains all input parameters for this mutation.
includeDebugView Boolean   false Whether to create a debug view in addition to the standard metric, usage, and log views. Set to true to include the debug view. Omitting this argument or passing false skips debug view creation.
specificOrganization String     The name of a single organization for which to create views. When provided, the mutation targets only that organization instead of all organizations in the system. Omitting this argument causes the mutation to run across all organizations.

Returned Values

The mutation returns a non-null Boolean! value. A return value of true confirms the views were created successfully. A return value of false indicates the operation did not complete successfully.