Summary

The createReadonlyToken() mutation creates a shareable read-only token for a LogScale dashboard. Use it to generate links that allow unauthenticated access to a specific dashboard, for example on a wall monitor or public display. To restrict access by IP address, supply an IP filter when creating the token.

Syntax

graphql
createReadonlyToken(
      id: String!,
      name: String!,
      ipFilterId: String,
      queryOwnershipType: QueryOwnershipType = User,
      timezone: String
   ): DashboardLink!

Provide the dashboard ID (id) and a display name (name) for the token. Both are required. Optionally supply an IP filter ID (ipFilterId) to restrict access by IP address, a queryOwnershipType to control whose credentials run the dashboard queries (defaults to User), and a timezone string to override the account or dashboard timezone. See the Input Parameters section for details.

The mutation returns a DashboardLink object. This includes the token string, the associated IP filter, and other dashboard link data. See the Returned Values section for the full field list.

Example

Raw
graphql
mutation CreatePublicDashboardLink {
  createReadonlyToken(
    id: "abc123"
    name: "Wall Monitor - Overview"
    queryOwnershipType: Organization) 
  { name, token }
}
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 CreatePublicDashboardLink {
  createReadonlyToken(
    id: \"abc123\"
    name: \"Wall Monitor - Overview\"
    queryOwnershipType: Organization) 
  { name, token }
}"
}
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 CreatePublicDashboardLink {
  createReadonlyToken(
    id: \"abc123\"
    name: \"Wall Monitor - Overview\"
    queryOwnershipType: Organization) 
  { name, token }
}"
}
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 CreatePublicDashboardLink { ^
  createReadonlyToken( ^
    id: \"abc123\" ^
    name: \"Wall Monitor - Overview\" ^
    queryOwnershipType: Organization)  ^
  { name, token } ^
}" ^
} '
Windows Powershell and curl
powershell
curl.exe -X POST 
    -H "Authorization: Bearer $TOKEN"
    -H "Content-Type: application/json"
    -d '{"query" : "mutation CreatePublicDashboardLink {
  createReadonlyToken(
    id: \"abc123\"
    name: \"Wall Monitor - Overview\"
    queryOwnershipType: Organization) 
  { name, token }
}"
}'
    "$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 CreatePublicDashboardLink {
  createReadonlyToken(
    id: \"abc123\"
    name: \"Wall Monitor - Overview\"
    queryOwnershipType: Organization) 
  { name, token }
}";
$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 CreatePublicDashboardLink {
  createReadonlyToken(
    id: \"abc123\"
    name: \"Wall Monitor - Overview\"
    queryOwnershipType: Organization) 
  { name, token }
}"
}'''

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 CreatePublicDashboardLink {
  createReadonlyToken(
    id: \"abc123\"
    name: \"Wall Monitor - Overview\"
    queryOwnershipType: Organization) 
  { name, token }
}"
}
);


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": {
    "createReadonlyToken": {
      "name": "Wall Monitor - Overview",
      "token": "abc123-def456-ghi789"
    }
  }
}

The queryOwnershipType argument sets the ownership of queries that the shared dashboard runs. The returned token can be used in a URL such as http://company.com/shared/dashboards?token=def456Ghi789 to access the dashboard from a wall monitor without logging in.

Input Parameters

Provide the dashboard ID and token name. Optionally supply an IP filter ID to restrict access by IP address, a query ownership type, and a timezone override. The Related section includes a query example that retrieves dashboard IDs and existing read-only tokens.

Table: Input Parameters and Datatypes

Parameter Type Required Default Description
This table contains all input parameters for this mutation. Because one parameter uses a special datatype, an additional table is included below with its values.
id String yes   The unique identifier of the dashboard for which to create the read-only token.
name String yes   A display name for the read-only token. Use this to identify the token's purpose, for example Wall Display - NOC.
ipFilterId String     The unique identifier of an IP filter to associate with the token. When provided, only requests from the allowed IP ranges can use the token. Omitting this value applies no IP restriction.
queryOwnershipType QueryOwnershipType   User Controls whose credentials run the queries on the shared dashboard. When set to User, the calling user's credentials run the queries. See the table below for all available values.
timezone String     An optional timezone string to override the account or dashboard timezone for this token's viewers. Omitting this value uses the dashboard's configured timezone.

The QueryOwnershipType enum controls whether a user or an organization owns the queries that the shared dashboard runs.

Returned Values

The mutation returns a non-nullable DashboardLink object. The returned fields include the token string required to construct a shareable dashboard URL, the associated IP filter, and other link metadata.