Skip to content

dt-demos/problems

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overview

Example unix shell scripts related to problems and logs.

Setup

  • Copy the .env-template to .env
  • Make a Dyantrace API token and set the Dynatrace URL Token in .env file.
    • API v2 scopes
      • Ingest events
      • Read problems
      • Write problems
    • API v1 scopes
      • Access problem and event feed, metrics, and topology

Events

Send Problem from Dynatraces workflow

Add a Javascript task with this code and modify as required for you needs. Refer to Dynatrace developer docs for more details on the SDK.

import { EventIngest, EventIngestEventType, eventsClient } from '@dynatrace-sdk/client-classic-environment-v2';

export default async function () {

const now = new Date();
const terminationEvent: EventIngest = {
  eventType: EventIngestEventType.CustomAlert,
  title: 'Test Problem - ' + now.toLocaleTimeString(),
  properties: { 'Triggered by': 'Workflow' },
  entitySelector: 'type(SERVICE),entityName.equals(OrderController)',
};

return await eventsClient.createEvent({ body: terminationEvent });
}

Send Event Script

Use this script to send an event to one or more entities.
For an overview of Dynatrace events types, review Categories of Davis events help docs.

Running script

./pushevent.sh PERFORMANCE_EVENT "type(SERVICE),entityName.equals(OrderController)"

Within Dynatrace view the problem in the problems app on in a notebook with DQL

Get Problem Script

Use this script to get the details for a problem. The script passing the optional querystring parameters to get more details about the problem. $DT_BASEURL/api/v2/problems/$DT_PROBLEM_ID?evidenceDetails,impactAnalysis,recentComments

Running script and formatting output with jq utility.

./getproblem.sh -3923117663478183459_1752459060000V2 | jq '.'

Close Existing Problem Script

This script can be used to quickly close out an open problem. From the URL within Dynatrace you get obtain the Problem ID. For example: -7079974447799175602_1752266005311V2

Running script:

./closeproblem.sh 5194648246915255341_1752457020268V2

Within Dynatrace there view the problem and review that it is closed.

Logs

Send Log

Use this script to send a log line For an overview of Dynatrace log ingest API, review Dynatrace docs

Running script

./pushlog.sh 

Within Dynatrace view the log in the logs app.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages