Subscribe

How to get Workflow Job Execution Status Reports via email: The Solution

Workflow Execution status reports can be very useful for WFA users, Admins and Architects even operators. I wanted to receive recurring email reports on how many workflows were executed in the last 7 days, and out of those how many passed or how many in Pending state. It helps to track jobs and workfflow executions. Like I wanted to know how many have been failing and how many times, which are stuck in Waiting for approval and need attention. Which workflows are being executed maximum no of times. How many workflow completed sucessfully etc. 

 

A weekly/daily execution status report email to a list of users is a very useful feaure. But its not available as yet with WFA. 

 

Making such a solution had some big challenges. BIG!!

 

  1. No rest API to get the list of all Workflow Execution jobs
  2. No mechanism to connect to DB and get job execution  information
  3. A job details can't be obtained unless you know the job ID and the workflow UUID. And I can’t get the job ID due to point 1.

 

However, considering that there is always a possibility of innovation and genius Robot Very Happy , let's build one.

 

The following logic is used for building the solution.

 

  1. Get this list of all workflows.
  2. For every workflow name, get its UUID.
  3. Use API SearchResource with context EXECUTION_STATUS to return the list of jobs for this particular workflow name. Search is based on name  pattern matching, so it is possible that jobs of other workflows which had common or similar words in their names will also get retuned. So returned list will be:

 

All jobs of our concerned workflow + (possibly) jobs of workflows with common patterns in their names.

 

We need to remove the latter.

 

  1. For every job in the list of jobs returned in step-3, call API to get Execution details using the workflow UUID . If this job didn't belong to our workflow, it will fail.
  1. Now we have been able to filter out which are our relevant jobs for this workflow. 70% of task done. 
  2. Assume you wanted weekly status report i.e. Execution status of the last 7 days. So get current date, get the date old date by subtracting 7 days from current date.
  3. If our current job has execution start date falls within this time duration, get its status, and put in in our report. Prepare as beautiful reports as you want. 
  4. Do it for every job
  5. Do the same for every workflow. 

Now I've designed a solution that generates the report and sends them by email. But you can use the above logic to generate your own reports the way you want them like in CSV or XL or PDF or just plain text.

 

Now, Lets look at the 3 commands.

 

  1. Workflow Execution Status Reporter: It gets the execution status details within the time duration provided by the user, prepares the report in beautiful HTML formats. But this is also going to be in a workflow, so its been designed to ignore its own job when preparing the job execution reports. You'll see as you go on.
  2. Send Email with Workflow Execution Status Reports : Send the Workflow execution status report as email to a list of recipients.
  3. Workflow Scheduler: The command to schedule this workflow for recurring executions so that the execution status reports can be generated and sent automatically every day or every week or as  once in 2 weeks or per the user decides.

Details on this command are available here: http://community.netapp.com/t5/OnCommand-Storage-Management-Software-Discussions/How-to-schedule-a-workflow-for-recurring-executions-The-solution/m-p/...

 

A sample workflow using the above 3 commands which sends Weekly Execution Status Report is attached. Just import it and execute it after getting the prerequisites done. You'll just love it.

 

Prerequisties:

 

  1. Minimum WFA version 3.0: I've used the new feature Password as a User-Input type in Send email command which is only availabe from WFA3.0 on wards. WFA 2.2 Users will need to slightly modify this command.
  2. You need PowerShell 3.0 on your WFA server. WFA is fully supported to work on Posh3.0. Its available by default in Win2012, Win2008 can be upgraded, Win2003 users can't use it.
  3. Add credentials of a WFA Admin/Architect in you WFA itself with Name/IP: localhost

Match: Exact
Type: Other
Name/IP: localhost
Username: <WFA Admin/Architect Username>
Password: <User Password>

 

Credentials_localhost.png

 

 

 

A sample Email of a Job execution report email will look as following. And it will be sent recurringly as per your schedule.

 

WFA Weekly Execution status report email.png

 

 

 

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

Re: How to get Workflow Job Execution Status Reports via email: The Solution

I took the code that you wrote for this and started playing with it from Powershell directly on a machine with WFA3.0P1 installed.  When I run the following:

 

$creds = get-credential

$URL = "http://localhost:8080/rest/search?term=Test Exit&context=EXECUTION_STATUS"

$results = Invoke-RestMethod -Method get -Uri $URL -Credential $creds -contenttype "application/xml"

 

I get a collection of results in the $results variable but all the job IDs are the same.  I see the correct number of entries, for example if the workflow was run 3 times I see 3 items in the collection, but all 3 are idential.

 

Bug?  Something I did wrong?  Thinking no on that because if I just use a browser and do essentially the same thing with the correct URL I get the same result.

Re: How to get Workflow Job Execution Status Reports via email: The Solution

Hi 2006FatBoy,

 

     I see that this is your first post on NetApp communities. So welcome to this forum.

 

 

@ Bug?  Something I did wrong?  Thinking no on that because if I just use a browser and do essentially the same thing with the correct URL I get the same result.

----

 

No bug but a user mistake. Your workflow name has <space> in it. So 

 

$URL = "http://localhost:8080/rest/search?term=Test Exit&context=EXECUTION_STATUS"

 

wont give the right results. Serach will not fail, but it won't give what you are looking for. Search engines are designed not to fail.

 

I've taken care of it in my code, seems like you missed it.

 

You need to use URL as below

 

http://localhost:8080/rest/search?term='Test Exit'&context=EXECUTION_STATUS

 

i.e. have single quotes in the parameter for term i.e. workflow name so that in cases where workflow names have <space>, it will still work.

 

Try it on your browser. single quotes and <space> gets translated to %27 and %20 respectively by browser. But you get what you were looking for.

 

 

sinhaa

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

Re: How to get Workflow Job Execution Status Reports via email: The Solution

Ok.  I had manually translated the [space] to %20 when I tried it in the browser but I did not add the quotes.  So that was my mistake.  Thanks for the assist.