<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: post execution script - synthetic HTTP - multiple conditions in Synthetic Monitoring</title>
    <link>https://community.dynatrace.com/t5/Synthetic-Monitoring/Post-execution-script-for-synthetic-HTTP-in-multiple-conditions/m-p/262217#M2753</link>
    <description>&lt;P&gt;There seem to be some issue in the script (always returns "All nodes are healthy."), but it's a great starting point for my anyway. Thanks!&lt;/P&gt;</description>
    <pubDate>Tue, 12 Nov 2024 15:18:02 GMT</pubDate>
    <dc:creator>mariusz_kuczeba</dc:creator>
    <dc:date>2024-11-12T15:18:02Z</dc:date>
    <item>
      <title>Post execution script for synthetic HTTP in multiple conditions</title>
      <link>https://community.dynatrace.com/t5/Synthetic-Monitoring/Post-execution-script-for-synthetic-HTTP-in-multiple-conditions/m-p/261843#M2747</link>
      <description>&lt;P&gt;We are monitoring JSON status page for an app, where multiple checks return Healthy or Unhealthy as it's status.&lt;/P&gt;
&lt;P&gt;I'm looking to somehow being able to tell which check fails exactly if my "Fail" condition will be "Unhealthy", and then be able to report on history of checks.&lt;/P&gt;
&lt;P&gt;I understand that I should be able to do that with post-execution script. Via probably getting html response with response.getResponseBody();, somehow comparing it with my regex, and then returning message that's interesting for me with api.fail(). I'm missing matching examples to build such post-execution script myself. Anyone bothers enough to help me out?&lt;/P&gt;
&lt;P&gt;Previously in SiteScope, I could cover that with regex, where while creating a regex condition, I could set a group with () that would be returned with error message.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example response body:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;{&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;"First": {&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;"status": "Healthy",&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;},&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;"Second": {&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;"status": "Unhealthy",&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;},&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;"Third": {&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;"status": "Healthy",&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;},&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;}&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Dec 2025 11:21:07 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Synthetic-Monitoring/Post-execution-script-for-synthetic-HTTP-in-multiple-conditions/m-p/261843#M2747</guid>
      <dc:creator>mariusz_kuczeba</dc:creator>
      <dc:date>2025-12-18T11:21:07Z</dc:date>
    </item>
    <item>
      <title>Re: post execution script - synthetic HTTP - multiple conditions</title>
      <link>https://community.dynatrace.com/t5/Synthetic-Monitoring/Post-execution-script-for-synthetic-HTTP-in-multiple-conditions/m-p/261858#M2748</link>
      <description>&lt;P&gt;&lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/39233"&gt;@mariusz_kuczeba&lt;/a&gt;&amp;nbsp;- not the perfect one , but an example you can use&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;var responseBody = response.getResponseBody();
var data = JSON.parse(responseBody);
var unhealthyNodes = [];

// Iterate through the nodes for unhealthy
for (var node in data) {
    if (data[node].status === "Unhealthy") {
      unhealthyNodes.push(node);
    }
}

// If found, fail the request and return the node names
if (unhealthyNodes.length &amp;gt; 0) {
    api.fail("Unhealthy nodes found: " + unhealthyNodes.join(","));
} else {
    api.info("All nodes are healthy.");
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Nov 2024 20:54:53 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Synthetic-Monitoring/Post-execution-script-for-synthetic-HTTP-in-multiple-conditions/m-p/261858#M2748</guid>
      <dc:creator>p_devulapalli</dc:creator>
      <dc:date>2024-11-12T20:54:53Z</dc:date>
    </item>
    <item>
      <title>Re: post execution script - synthetic HTTP - multiple conditions</title>
      <link>https://community.dynatrace.com/t5/Synthetic-Monitoring/Post-execution-script-for-synthetic-HTTP-in-multiple-conditions/m-p/262217#M2753</link>
      <description>&lt;P&gt;There seem to be some issue in the script (always returns "All nodes are healthy."), but it's a great starting point for my anyway. Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 12 Nov 2024 15:18:02 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Synthetic-Monitoring/Post-execution-script-for-synthetic-HTTP-in-multiple-conditions/m-p/262217#M2753</guid>
      <dc:creator>mariusz_kuczeba</dc:creator>
      <dc:date>2024-11-12T15:18:02Z</dc:date>
    </item>
  </channel>
</rss>

