cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Build workflow to send SMS notification for problems detected after business hours

Omkar_B
Dynatrace Enthusiast
Dynatrace Enthusiast

Hello Team,
Can someone help me to build workflow for below use case :

We want Dynatrace to send SMS notification for problems generated between 18:00 To 06:00(nextDay) monday to friday if the impacted entity falls under sev1 or sev2 category.
I am using Problem based trigger and need help to build query to filter problem where time stamp is after 18:00 or before 06:00 and day is between Monday to Friday.

11 REPLIES 11

PacoPorro
Dynatrace Leader
Dynatrace Leader

hi

Try your DQL with 

 

| fieldsAdd day_of_week = getDayOfWeek(timestamp), hour_of_day = getHour(timestamp)
| filter (hour_of_day > 18 OR hour_of_day < 6) AND day_of_week >= 1 AND day_of_week <= 5

 

Omkar_B
Dynatrace Enthusiast
Dynatrace Enthusiast

Hello @PacoPorro,

I have DQL query to fetch events with this filter but can I trigger workflow using this ? if yes, How ?
Do you know how can we use match phrase function in workflow ?

 

Thanks
 

Use a cron trigger in the workflow as step 1, run the dql as step 2, run the SMS http request as step 3

 

theharithsa
Dynatrace Champion
Dynatrace Champion

Hi @Omkar_B 

You can achieve this in 3 steps:

  1. Set the trigger to every morning at 9 AM (for example)
  2. In 2nd step add Task to execute JavaScript code. In the code you have to call APIs to fetch the problems that has come after 18:00 and within 06:00 and from their you can get the problems that has higher severity. You get the JSON as an output and that can be fed to the next step.
  3. In the 3rd step you can use HTTP request and configure your result in such a way that in will be sent to the person based on the web hook you get from the customer and respective headers for it. 

 

Note: You have to reconfigure your JSON output in 2nd step itself so that SMS messages will not be split in the 3rd step. 

Love more, hate less; Technology for all, together we grow.

Omkar_B
Dynatrace Enthusiast
Dynatrace Enthusiast

@theharithsa 
Why do we need to pull data via API if it is available in workflow or DQL. Can't we use those available options to achieve this ? 

theharithsa
Dynatrace Champion
Dynatrace Champion

You can use both, but you can't use Davis problem trigger as a task. For that, you'll need to run some JavaScript. There's a library that can fetch problems in the same tenant.

Love more, hate less; Technology for all, together we grow.

PacoPorro
Dynatrace Leader
Dynatrace Leader

Just tested the filter option, and seems to be working:

 (getHour(timestamp) > 18 OR getHour(timestamp) < 6) AND getDayOfWeek(timestamp) >= 1 AND getDayOfWeek(timestamp) <= 5

 

PacoPorro_0-1710244167210.png

 

It is good to get the problems. Thanks @PacoPorro 

Is this what you were looking for @Omkar_B

Love more, hate less; Technology for all, together we grow.

Omkar_B
Dynatrace Enthusiast
Dynatrace Enthusiast

Just wanted to share approach I used to achieve this - 
1. Used Davis Problem Trigger for problems in Open or Closed state and having certain conditions like tag="abc".
2. Task (JavaScript) to get output of trigger check conditions for time like hour after 6 PM and weekday or weekend and call SMS API if conditions are matching.

There are some SDKs available to get data of trigger or previous which we can use during workflow creation, but tedious task is to understand the syntax of JavaScript.

Hi Omkar, I'm having a hard time understanding how to use JavaScript to get the information, could you help me by indicating which SDK you used since I'm looking to make a similar workflow and with the trigger data it would help me define my flow

Omkar_B
Dynatrace Enthusiast
Dynatrace Enthusiast

Hello @JhonU,
If you're still looking for it, here are the SDKs you can use.
@dynatrace-sdk/automation-utils :- to get details from previous tasks or trigger within execution.

Featured Posts