Automic Workload Automation

Expand all | Collapse all

prep_process_report and pull a specific string help

  • 1.  prep_process_report and pull a specific string help

    Posted 06-13-2018 03:05 PM

    Hi. I could use the  communities help to prep process a report and create a variable of a specific string from a line (stored as a variable). The string characters might be from line 50-70 but I prefer not to hard code that values in case the position ever changes.

     

    Post-Processing results for the prep_process_report is:

    2018-06-13 14:39:16 - U00020408 OG alertId is : 2018-06-13 14:39:15 "alertId": "878520b4-2884-4f37-997e-aa80558f1eae-1528904520802",

     

    I need the alert id value without the quotes (e.g. 878520b4-2884-4f37-997e-aa80558f1eae-1528904520802)

     

    Original Report is:

     

    2018-06-13 14:39:15             Connect timeout set to 30 seconds 2018-06-13 14:39:15             Read timeout set to:60 2018-06-13 14:39:15             Using connection:CONN.WEBSERVICE.RESTCONNECTION.OPSGENIE 2018-06-13 14:39:15             Authentication type:None 2018-06-13 14:39:15             Request:GET https://api.opsgenie.com/v2/alerts/requests/36305b6c-42e1-4b74-86af-877ee1f5691c 2018-06-13 14:39:15             Request headers:[[Authorization, GenieKey 45ba-92a7-c3e7c0e34c74]] 2018-06-13 14:39:15             Sending request... 2018-06-13 14:39:15             Response: 2018-06-13 14:39:15             Status:200 OK 2018-06-13 14:39:15             Response headers:[Content-Type:[application/json;charset=UTF-8], Transfer-Encoding:[chunked], Connection:[keep-alive], Date:[Wed, 13 Jun 2018 18:39:16 GMT], X-Response-Time:[0.007], X-Request-ID:[b50b5935-9ed3-4925-b7d8-6b1ed51265d0], X-RateLimit-State:[OK], X-Cache:[Miss from cloudfront], Via:[1.1 1011122594527947f68957a1e79e0577.cloudfront.net (CloudFront)], X-Amz-Cf-Id:[alWoqKCdSDmC3_Fs1R2SJrP0DXUf5HSHCvsM2-WFye8JvvBzrpCzlQ==]] 2018-06-13 14:39:15             Response - application/json 2018-06-13 14:39:15             Start response pattern 2018-06-13 14:39:15             { 2018-06-13 14:39:15                 "data": { 2018-06-13 14:39:15                     "success": true, 2018-06-13 14:39:15                     "action": "Create", 2018-06-13 14:39:15                     "processedAt": "2018-06-13T15:42:00.893Z", 2018-06-13 14:39:15                     "integrationId": "b9f5bf78-7bec-49f2-9432-83a32a1619fc", 2018-06-13 14:39:15                     "isSuccess": true, 2018-06-13 14:39:15                     "status": "Created alert", 2018-06-13 14:39:15                     "alertId": "878520b4-2884-4f37-997e-aa80558f1eae-1528904520802", 2018-06-13 14:39:15                     "alias": "878520b4-2884-4f37-997e-aa80558f1eae-1528904520802" 2018-06-13 14:39:15                 }, 2018-06-13 14:39:15                 "took": 0.007, 2018-06-13 14:39:15                 "requestId": "b50b5935-9ed3-4925-b7d8-6b1ed51265d0" 2018-06-13 14:39:15             } 2018-06-13 14:39:15             End response pattern 2018-06-13 14:39:15             Writing response output to file:D:\Automic\Agents\WebService\bin\task_reports\restResp_61594372.json 2018-06-13 14:39:15             RESTful job complete


  • 2.  Re: prep_process_report and pull a specific string help

    Posted 06-13-2018 06:04 PM

    :SET &HND# = PREP_PROCESS_REPORT(,,"REP", '*"alertId": "*')
    :PROCESS &HND#
    : SET &RET# = GET_PROCESS_LINE(&HND#)
    : set &pos1# = str_find_reverse(&RET#,'"alertId": "')
    : set &pos1# = &pos1# + 12
    : set &AlertID# = substr(&RET#,&pos1#)
    : set &pos1# = str_find(&AlertID#,'"')
    : set &pos1# = &pos1# - 1
    : set &AlertID# = substr(&AlertID#,1,&pos1#)
    : print "Alertid=&AlertID#"
    :ENDPROCESS
    :close_process &hnd#



  • 3.  Re: prep_process_report and pull a specific string help

    Posted 06-14-2018 12:10 PM

    Thank you Pete. It worked without any mods. This was really helpful. Thanks gain!



  • 4.  Re: prep_process_report and pull a specific string help

    Posted 06-14-2018 12:27 PM

    I've been writing string manipulation scripts for over 40 years now.  I can do them in my sleep.  (and I still enjoy writing them!)



  • 5.  Re: prep_process_report and pull a specific string help

    Posted 10-18-2018 03:23 PM

    I have a similar problem and would appreciate any help at all. 

    I am extracting one line from the Report(REP) of a JOBS.   The following line is in the Report(REP) and I want to extract that line to send in an email

     

    NUMBER OF PAYMENTS UPLOADED: 23 PAYMENTS TOTAL AMOUNT: $619.01

     

    Below is my code that I placed in the Post Process of a job:

     

    :SET &TOTAL_COUNT# =""
    :SET &HND# = PREP_PROCESS_REPORT(,,,"NUMBER OF PAYMENTS UPLOADED*")
    :PROCESS &HND#
    :SET &TOTAL_COUNT# = GET_PROCESS_LINE(&HND#,1)
    :PRINT &TOTAL_COUNT#
    :ENDPROCESS

     

    I then pass &TOTAL_COUNT# to an email job that is a post condition of the job producing the report.

    When I view the email, I see the &TOTAL_COUNT# contents are: 

     

    NUMBER OF PAYMENTS UPLOADED: 23 PAYMENTS TOTAL AMOUNT: 19.01

     

    For some unknown reason, the TOTAL AMOUNT $619.01 is truncated to 19.01.  I do not understand why it is dropping the $6 in the variable.

     

    Thanks!

     

     

     

     

     

     

     



  • 6.  Re: prep_process_report and pull a specific string help

    Posted 10-18-2018 04:14 PM

    Somewhere along the line the $ symbol is being interpreted as the beginning of a variable name that needs to be substituted, with "6" being the name of that variable.   You'll need to display or "print" the contents of &TOTAL_COUNT# every step of the way until you figure out where this replacement is happening.

     

    My guess is that if you print the contents of &TOTAL_COUNT# before you pass it on, the $6 should still be there(?)  I suspect the replacement is taking place elsewhere...



  • 7.  Re: prep_process_report and pull a specific string help

    Posted 10-18-2018 04:22 PM

    Thank you for the prompt reply.  Below is my post processing report from the job:


    2018-10-18 14:50:31 - U00020206 Variable '&TOTAL_COUNT#' was stored with value ''. 2018-10-18 14:50:31 - U00020408 NUMBER OF PAYMENTS UPLOADED: 23 PAYMENTS TOTAL AMOUNT: $619.01



  • 8.  Re: prep_process_report and pull a specific string help

    Posted 10-18-2018 04:24 PM

    So what do you do with that variable next?  Do you use it in a PowerShell script?  In a DOS script?  Or do you build and send your email with UC4 scripting?



  • 9.  Re: prep_process_report and pull a specific string help

    Posted 10-18-2018 04:33 PM

    We build and send the email with UC4 scripting



  • 10.  Re: prep_process_report and pull a specific string help

    Posted 10-18-2018 04:41 PM

    I just tested this script without any problems.  The $ symbol arrived in my email.

     

    :set &MyEmailText# = "string with a dollar symbol in it $619.01"
    :set &EmailResult# = send_mail("petwir@saif.com",,"TestEmail from &$client#",&MyEmailText#)
    :print "results=&EmailResult#"

     

    Are you passing the variable off to another UC4 object?  Maybe its getting clobbered when it is being passed?



  • 11.  Re: prep_process_report and pull a specific string help

    Posted 10-18-2018 04:48 PM

    You are probably correct, it's getting lost in the scripting that creates/sends the email.  I will try that angle. 

     

    Thank you so much for your help!