<?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 Help Needed with Extracting Metrics from Kong API Gateway Logs in DQL</title>
    <link>https://community.dynatrace.com/t5/DQL/Help-Needed-with-Extracting-Metrics-from-Kong-API-Gateway-Logs/m-p/269009#M1652</link>
    <description>&lt;P&gt;Hi Dynatrace Community,&lt;/P&gt;
&lt;P&gt;As a newbie navigating Dynatrace, I'm on a mission to create great dashboards from Kong API Gateway logs. Things are going well so far, OpenPipeline makes it pretty smooth to generate metrics from the logs and visualize them on dashboards. However, I've hit a couple of bumps on this journey.&lt;/P&gt;
&lt;P&gt;First what works with processing in OpenPipeline:&lt;BR /&gt;Adding fields like&amp;nbsp;status_count: 1 and dt.source_entity: HOST-***&lt;BR /&gt;Using DQL for transformations like:&lt;BR /&gt;&lt;SPAN&gt;fieldsAdd upstream_status_code = if(upstream_status == "-", "499", else:substring(upstream_status, from:0, to:3))&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;The Issues are:&lt;BR /&gt;1️) Missing Metric Mystery:&lt;BR /&gt;I have a DQL statement that works perfectly when testing with "Run sample data." However, despite waiting patiently for days, the metric doesn’t show up anywhere. Here's the snippet:&lt;/P&gt;
&lt;DIV class=""&gt;
&lt;DIV class=""&gt;&lt;SPAN&gt;parse latencies, "JSON:latenciesJson"&lt;BR /&gt;| fieldsFlatten latenciesJson, prefix: "lat."&lt;BR /&gt;| fieldsAdd upstream_latency = if(toDouble(lat.proxy) &amp;lt; 1000, ceil(toDouble(lat.proxy) / 100) * 100, else:ceil(toDouble(lat.proxy) / 1000) * 1000) &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;2️) Array Field Extraction Troubles:&lt;BR /&gt;I'm trying to extract the IP from the first object in the tries array. I've tried various combinations of parse try, "JSON:tryJson" and JSON_ARRAY: without success.&lt;/P&gt;
&lt;P&gt;Current Metrics field extraction is status_count&lt;BR /&gt;With dimensions:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;route.name&lt;/LI&gt;
&lt;LI&gt;`request.headers.x-field`&lt;/LI&gt;
&lt;LI&gt;kong_env&lt;/LI&gt;
&lt;LI&gt;dt.source_entity&lt;/LI&gt;
&lt;LI&gt;upstream_status_code&lt;/LI&gt;
&lt;LI&gt;upstream_latency&lt;/LI&gt;
&lt;LI&gt;service.name&lt;/LI&gt;
&lt;LI&gt;consumer.username&lt;/LI&gt;
&lt;LI&gt;service.host&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;I’ve attached a sample JSON for reference. If you have any insights or DQL wizardry up your sleeve, I’d love to hear them.&lt;/P&gt;
&lt;P&gt;Thanks in advance for your help, and for sympathizing with a newbie learning the ropes! &lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;BR /&gt;Erwin&lt;/P&gt;</description>
    <pubDate>Mon, 10 Feb 2025 11:20:47 GMT</pubDate>
    <dc:creator>ErwinB</dc:creator>
    <dc:date>2025-02-10T11:20:47Z</dc:date>
    <item>
      <title>Help Needed with Extracting Metrics from Kong API Gateway Logs</title>
      <link>https://community.dynatrace.com/t5/DQL/Help-Needed-with-Extracting-Metrics-from-Kong-API-Gateway-Logs/m-p/269009#M1652</link>
      <description>&lt;P&gt;Hi Dynatrace Community,&lt;/P&gt;
&lt;P&gt;As a newbie navigating Dynatrace, I'm on a mission to create great dashboards from Kong API Gateway logs. Things are going well so far, OpenPipeline makes it pretty smooth to generate metrics from the logs and visualize them on dashboards. However, I've hit a couple of bumps on this journey.&lt;/P&gt;
&lt;P&gt;First what works with processing in OpenPipeline:&lt;BR /&gt;Adding fields like&amp;nbsp;status_count: 1 and dt.source_entity: HOST-***&lt;BR /&gt;Using DQL for transformations like:&lt;BR /&gt;&lt;SPAN&gt;fieldsAdd upstream_status_code = if(upstream_status == "-", "499", else:substring(upstream_status, from:0, to:3))&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;The Issues are:&lt;BR /&gt;1️) Missing Metric Mystery:&lt;BR /&gt;I have a DQL statement that works perfectly when testing with "Run sample data." However, despite waiting patiently for days, the metric doesn’t show up anywhere. Here's the snippet:&lt;/P&gt;
&lt;DIV class=""&gt;
&lt;DIV class=""&gt;&lt;SPAN&gt;parse latencies, "JSON:latenciesJson"&lt;BR /&gt;| fieldsFlatten latenciesJson, prefix: "lat."&lt;BR /&gt;| fieldsAdd upstream_latency = if(toDouble(lat.proxy) &amp;lt; 1000, ceil(toDouble(lat.proxy) / 100) * 100, else:ceil(toDouble(lat.proxy) / 1000) * 1000) &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;2️) Array Field Extraction Troubles:&lt;BR /&gt;I'm trying to extract the IP from the first object in the tries array. I've tried various combinations of parse try, "JSON:tryJson" and JSON_ARRAY: without success.&lt;/P&gt;
&lt;P&gt;Current Metrics field extraction is status_count&lt;BR /&gt;With dimensions:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;route.name&lt;/LI&gt;
&lt;LI&gt;`request.headers.x-field`&lt;/LI&gt;
&lt;LI&gt;kong_env&lt;/LI&gt;
&lt;LI&gt;dt.source_entity&lt;/LI&gt;
&lt;LI&gt;upstream_status_code&lt;/LI&gt;
&lt;LI&gt;upstream_latency&lt;/LI&gt;
&lt;LI&gt;service.name&lt;/LI&gt;
&lt;LI&gt;consumer.username&lt;/LI&gt;
&lt;LI&gt;service.host&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;I’ve attached a sample JSON for reference. If you have any insights or DQL wizardry up your sleeve, I’d love to hear them.&lt;/P&gt;
&lt;P&gt;Thanks in advance for your help, and for sympathizing with a newbie learning the ropes! &lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;BR /&gt;Erwin&lt;/P&gt;</description>
      <pubDate>Mon, 10 Feb 2025 11:20:47 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Help-Needed-with-Extracting-Metrics-from-Kong-API-Gateway-Logs/m-p/269009#M1652</guid>
      <dc:creator>ErwinB</dc:creator>
      <dc:date>2025-02-10T11:20:47Z</dc:date>
    </item>
    <item>
      <title>Re: Help Needed with Extracting Metrics from Kong API Gateway Logs</title>
      <link>https://community.dynatrace.com/t5/DQL/Help-Needed-with-Extracting-Metrics-from-Kong-API-Gateway-Logs/m-p/269123#M1665</link>
      <description>&lt;P&gt;Hi Erwin.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I created a sample record using the JSON you have provided. By the looks, that is valid JSON meaning you are able to add a simple&amp;nbsp;&lt;EM&gt;"|parse content, "JSON:j"&amp;nbsp;&lt;/EM&gt;at the end of the DQL query. This should end up looking something like this.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="KeeganNelson_0-1738610231952.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/26163iF1BD1A59A66936E7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="KeeganNelson_0-1738610231952.png" alt="KeeganNelson_0-1738610231952.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="KeeganNelson_1-1738610252561.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/26164i81A3D5A9D2FF0F5B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="KeeganNelson_1-1738610252561.png" alt="KeeganNelson_1-1738610252561.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Hope this helps!&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2025 19:18:00 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Help-Needed-with-Extracting-Metrics-from-Kong-API-Gateway-Logs/m-p/269123#M1665</guid>
      <dc:creator>KeeganNelson</dc:creator>
      <dc:date>2025-02-03T19:18:00Z</dc:date>
    </item>
    <item>
      <title>Re: Help Needed with Extracting Metrics from Kong API Gateway Logs</title>
      <link>https://community.dynatrace.com/t5/DQL/Help-Needed-with-Extracting-Metrics-from-Kong-API-Gateway-Logs/m-p/269164#M1668</link>
      <description>&lt;P&gt;Hi Keegan,&lt;/P&gt;&lt;P&gt;Thanks for checking, and confirming the validity of the json. Indeed I'm parsing the json, and with the processing instruction&lt;BR /&gt;fieldsAdd upstream_status_code = if(upstream_status == "-", "499", else:substring(upstream_status, from:0, to:3))&lt;BR /&gt;The json is parsed implicitly, with the following instruction I explicitly parse the json:&lt;BR /&gt;parse latencies, "JSON:latenciesJson"&lt;BR /&gt;| fieldsFlatten latenciesJson, prefix: "lat."&lt;BR /&gt;| fieldsAdd upstream_latency = if(toDouble(lat.proxy) &amp;lt; 1000, ceil(toDouble(lat.proxy) / 100) * 100, else:ceil(toDouble(lat.proxy) / 1000) * 1000)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ErwinB_0-1738646415512.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/26171iE905F2D8CD17C95B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ErwinB_0-1738646415512.png" alt="ErwinB_0-1738646415512.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;And in OpenPipeline this looks good, however the metric is afterwards not available when querying the metric, like in notebook it should be available to select:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ErwinB_1-1738646610113.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/26172i86C831B4975BB49B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ErwinB_1-1738646610113.png" alt="ErwinB_1-1738646610113.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;upstream_latency is also added to dimensions in the Metrics Extraction tab of the OpenPipeline, imho it should work but it doesn't&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;Or should I first parse the content as you show and then the "Complex record" latencies? How can you get the field proxy out of content.latencies?&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;Again thanks for your help!&lt;BR /&gt;Have a nice day,&lt;/DIV&gt;&lt;DIV class=""&gt;Erwin&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 04 Feb 2025 05:29:10 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Help-Needed-with-Extracting-Metrics-from-Kong-API-Gateway-Logs/m-p/269164#M1668</guid>
      <dc:creator>ErwinB</dc:creator>
      <dc:date>2025-02-04T05:29:10Z</dc:date>
    </item>
    <item>
      <title>Re: Help Needed with Extracting Metrics from Kong API Gateway Logs</title>
      <link>https://community.dynatrace.com/t5/DQL/Help-Needed-with-Extracting-Metrics-from-Kong-API-Gateway-Logs/m-p/269174#M1670</link>
      <description>&lt;P&gt;OK, found it, solution is easier then thought &lt;span class="lia-unicode-emoji" title=":rolling_on_the_floor_laughing:"&gt;🤣&lt;/span&gt;&lt;/P&gt;&lt;P&gt;When not parsing JSON explicitly it's parsed implicitly, with the following DQL&lt;BR /&gt;fieldsAdd upstream_latency = if(toDouble(latencies.proxy) &amp;lt; 1000, ceil(toDouble(latencies.proxy) / 100) * 100, else:ceil(toDouble(latencies.proxy) / 1000) * 1000)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ErwinB_0-1738653358751.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/26174i03347A330F15BC25/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ErwinB_0-1738653358751.png" alt="ErwinB_0-1738653358751.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The "Run sample data" in open pipeline shows null, however, the metric&amp;nbsp;upstream_latency is available in notebook/dashboard, my&amp;nbsp;&lt;SPAN&gt;mission to create great dashboards from Kong API Gateway logs continues...&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2025 07:21:20 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Help-Needed-with-Extracting-Metrics-from-Kong-API-Gateway-Logs/m-p/269174#M1670</guid>
      <dc:creator>ErwinB</dc:creator>
      <dc:date>2025-02-04T07:21:20Z</dc:date>
    </item>
    <item>
      <title>Re: Help Needed with Extracting Metrics from Kong API Gateway Logs</title>
      <link>https://community.dynatrace.com/t5/DQL/Help-Needed-with-Extracting-Metrics-from-Kong-API-Gateway-Logs/m-p/269377#M1675</link>
      <description>&lt;P&gt;Final addition to this question, the above solution is the answer on the first question, the second question was how to get metrics from the first object in the tries array.&lt;BR /&gt;The answer to this is:&lt;BR /&gt;parse arrayFirst(tries),"JSON:my_try"&lt;BR /&gt;| fieldsFlatten my_try, prefix: "try."&lt;BR /&gt;| fieldsAdd upstream_system = concat( try.ip, ":", toString(try.port) )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this answer helps future similar questions&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Feb 2025 08:41:28 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Help-Needed-with-Extracting-Metrics-from-Kong-API-Gateway-Logs/m-p/269377#M1675</guid>
      <dc:creator>ErwinB</dc:creator>
      <dc:date>2025-02-06T08:41:28Z</dc:date>
    </item>
  </channel>
</rss>

