Summary

The addDashboardLabels() mutation adds one or more labels to an existing dashboard. Labels help you organize and filter dashboards in LogScale. Use this mutation to add labels after dashboard creation; a dashboard supports at most ten labels, each with a maximum length of sixty characters.

Syntax

graphql
addDashboardLabels(
      input: AddDashboardLabels!
   ): Dashboard

The mutation takes a single required input argument of type AddDashboardLabels!. The input requires a view or repository name, a dashboard ID, and a list of labels to add. The mutation returns a Dashboard object on success, or null on failure.

For the full list of available fields on the returned Dashboard object, see the Returned Values section.

Hide Query Example

Show Dashboard Identifiers Query

Example

Raw
graphql
mutation {
  addDashboardLabels(
    input: { 
      viewName: "humio",
      id: "sales-dasher",
      labels: [ "sales_dept",
                "sales-assistants",
                "admin-focus" ]
    }
  )
  {displayName, createdInfo { author {displayString} } }
}
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 {
  addDashboardLabels(
    input: { 
      viewName: \"humio\",
      id: \"sales-dasher\",
      labels: [ \"sales_dept\",
                \"sales-assistants\",
                \"admin-focus\" ]
    }
  )
  {displayName, createdInfo { author {displayString} } }
}"
}
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 {
  addDashboardLabels(
    input: { 
      viewName: \"humio\",
      id: \"sales-dasher\",
      labels: [ \"sales_dept\",
                \"sales-assistants\",
                \"admin-focus\" ]
    }
  )
  {displayName, createdInfo { author {displayString} } }
}"
}
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 { ^
  addDashboardLabels( ^
    input: {  ^
      viewName: \"humio\", ^
      id: \"sales-dasher\", ^
      labels: [ \"sales_dept\", ^
                \"sales-assistants\", ^
                \"admin-focus\" ] ^
    } ^
  ) ^
  {displayName, createdInfo { author {displayString} } } ^
}" ^
} '
Windows Powershell and curl
powershell
curl.exe -X POST 
    -H "Authorization: Bearer $TOKEN"
    -H "Content-Type: application/json"
    -d '{"query" : "mutation {
  addDashboardLabels(
    input: { 
      viewName: \"humio\",
      id: \"sales-dasher\",
      labels: [ \"sales_dept\",
                \"sales-assistants\",
                \"admin-focus\" ]
    }
  )
  {displayName, createdInfo { author {displayString} } }
}"
}'
    "$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 {
  addDashboardLabels(
    input: { 
      viewName: \"humio\",
      id: \"sales-dasher\",
      labels: [ \"sales_dept\",
                \"sales-assistants\",
                \"admin-focus\" ]
    }
  )
  {displayName, createdInfo { author {displayString} } }
}";
$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 {
  addDashboardLabels(
    input: { 
      viewName: \"humio\",
      id: \"sales-dasher\",
      labels: [ \"sales_dept\",
                \"sales-assistants\",
                \"admin-focus\" ]
    }
  )
  {displayName, createdInfo { author {displayString} } }
}"
}'''

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 {
  addDashboardLabels(
    input: { 
      viewName: \"humio\",
      id: \"sales-dasher\",
      labels: [ \"sales_dept\",
                \"sales-assistants\",
                \"admin-focus\" ]
    }
  )
  {displayName, createdInfo { author {displayString} } }
}"
}
);


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": {
    "addDashboardLabels": {
      "displayName": "Sales Dashboard",
      "createdInfo": {
        "author": "teddy"
      }
    }
  }
}

Input Parameters

The input argument requires three fields: the view or repository name (viewName), the unique identifier of the dashboard (id), and a list of labels to add (labels). The viewName field accepts either a repository name or a view name; views are read-only abstractions over one or more repositories and are valid scopes for this mutation. The id field is the system-generated unique identifier for the dashboard, not its display name. Use the repository() query to retrieve dashboard IDs, as shown in the Syntax section. Each label in labels can be at most sixty characters; a dashboard supports at most ten labels in total.

Returned Values

This mutation returns a Dashboard object on success. The labels field contains the full updated list of labels for the dashboard. The following table lists all available fields.