Summary

PagerDuty actions let LogScale push incident notifications to PagerDuty when an alert fires. Each action stores a routing key that identifies the PagerDuty service or escalation policy to receive the event, an event severity that maps to the PagerDuty severity field, and a display name so the action can be reused across multiple alerts without reconfiguring the integration settings each time.

The createPagerDutyAction() mutation creates a new PagerDuty action in a LogScale repository or view. On success, it returns the PagerDutyAction object for the created action, including the generated ID. After creation, attach the action to an alert using createAggregateAlert(), createFilterAlert(), or their update counterparts.

Syntax

graphql
createPagerDutyAction(
      input: CreatePagerDutyAction!
   ): PagerDutyAction!

The input argument is required and takes a CreatePagerDutyAction object. Provide the repository or view name, a display name for the action, the PagerDuty routing key, and an event severity. The routing key is the integration key from the PagerDuty service or global ruleset that will receive the events. The severity maps directly to the PagerDuty event severity field and accepts the values critical, error, warning, and info. Creating a PagerDuty action requires the CreateActions API permission.

The mutation returns a non-null PagerDutyAction! object. The Returned Values section describes the available fields, including the generated action ID.

Example

Raw
graphql
mutation {
  createPagerDutyAction(input: 
         { viewName: "humio",
           name: "on-duty",
           severity: "high",
           routingKey: "123XYZabc",
           useProxy: false        
         } )
    {id, isAllowedToRun}
}
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 {
  createPagerDutyAction(input: 
         { viewName: \"humio\",
           name: \"on-duty\",
           severity: \"high\",
           routingKey: \"123XYZabc\",
           useProxy: false        
         } )
    {id, isAllowedToRun}
}"
}
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 {
  createPagerDutyAction(input: 
         { viewName: \"humio\",
           name: \"on-duty\",
           severity: \"high\",
           routingKey: \"123XYZabc\",
           useProxy: false        
         } )
    {id, isAllowedToRun}
}"
}
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 { ^
  createPagerDutyAction(input:  ^
         { viewName: \"humio\", ^
           name: \"on-duty\", ^
           severity: \"high\", ^
           routingKey: \"123XYZabc\", ^
           useProxy: false         ^
         } ) ^
    {id, isAllowedToRun} ^
}" ^
} '
Windows Powershell and curl
powershell
curl.exe -X POST 
    -H "Authorization: Bearer $TOKEN"
    -H "Content-Type: application/json"
    -d '{"query" : "mutation {
  createPagerDutyAction(input: 
         { viewName: \"humio\",
           name: \"on-duty\",
           severity: \"high\",
           routingKey: \"123XYZabc\",
           useProxy: false        
         } )
    {id, isAllowedToRun}
}"
}'
    "$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 {
  createPagerDutyAction(input: 
         { viewName: \"humio\",
           name: \"on-duty\",
           severity: \"high\",
           routingKey: \"123XYZabc\",
           useProxy: false        
         } )
    {id, isAllowedToRun}
}";
$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 {
  createPagerDutyAction(input: 
         { viewName: \"humio\",
           name: \"on-duty\",
           severity: \"high\",
           routingKey: \"123XYZabc\",
           useProxy: false        
         } )
    {id, isAllowedToRun}
}"
}'''

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 {
  createPagerDutyAction(input: 
         { viewName: \"humio\",
           name: \"on-duty\",
           severity: \"high\",
           routingKey: \"123XYZabc\",
           useProxy: false        
         } )
    {id, isAllowedToRun}
}"
}
);


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": {
    "createPagerDutyAction": {
      "id": "abc123",
      "isAllowedToRun": true
    }
  }
}

Input Parameters

The input argument takes a CreatePagerDutyAction object. Provide the repository or view name, a display name for the action, the PagerDuty routing key, and the event severity. The routing key is the integration key from the PagerDuty service or global ruleset that will receive the events; copy it from the PagerDuty service's Integrations page. The following table describes each available field.

Table: CreatePagerDutyAction Input Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
labelsStringyes   Labels for the action. There can be at most 10 labels with a max length of 60 characters per label.
nameStringyes Long-Term Name of the action.
routingKeyStringyes Long-Term Key to authenticate with OpsGenie.
severityStringyes Long-Term The routing key to authenticate with PagerDuty.
useProxyBooleanyes Long-Term Defines whether the action should use the configured proxy to make web requests.
viewNameStringyes Long-Term Name of the view of the action.

Returned Values

The mutation returns the created PagerDutyAction object. Include id in the return fields to capture the generated action identifier, which you need when attaching the action to alerts or calling testPagerDutyAction(). Include isAllowedToRun to confirm the caller has permission to execute the action.

Table: PagerDutyAction Datatype

ParameterTypeRequiredDefaultStabilityAvailabilityDescription
allowedActions[AssetAction]yes Short-Term The asset actions allowed. See AssetAction .
createdInfoAssetCommitMetadata  Long-Term Metadata related to the creation of the action. See AssetCommitMetadata.
displayNamestringyes Long-Term The display name of the action.
idstringyes Long-Term The unique identifier of the action.
isAllowedToRunbooleanyes Long-Term False if this type of action is disabled because of a security policy, true otherwise.
labels[string]  Preview Any labels associated with the action.
modifiedInfoAssetCommitMetadata  Long-Term Metadata related to the latest modification of the action. See AssetCommitMetadata.
namestringyes Long-Term The name of the action.
packagePackageInstallationyes Long-Term The package, if any, of which the action is part. See PackageInstallation.
packageIdVersionedPackageSpecifier  Long-Term The identifier of the package, if any. VersionedPackageSpecifier is a scalar.
requiresOrganizationOwnedQueriesPermissionToEditbooleanyes Long-Term True if this action is used by triggers, where the query is run by the organization. If true, then the OrganizationOwnedQueries permission is required to edit the action.
resourcestringyes Short-Term The resource identifier for the action.
routingKeystringyes Long-Term Routing key to authenticate with PagerDuty.
severitystringyes Long-Term Severity level to give to the message.
useProxybooleanyes Long-Term Defines whether the action should use the configured proxy to make web requests.
yamlTemplateYAMLyes Long-Term A template that can be used to recreate the action. YAML is a scalar.