<?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 How to do loop on array? in Monitoring Splunk</title>
    <link>https://community.splunk.com/t5/Monitoring-Splunk/How-to-do-loop-on-array/m-p/624181#M9242</link>
    <description>&lt;P&gt;How to loop the array values after split with delimiter&amp;nbsp;&lt;/P&gt;
&lt;P&gt;| eval&amp;nbsp;&lt;SPAN&gt;json="{"key1":"key1value","key2":"key2value","key3":"key3value","key4":"key4Value" }"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;| eval keyNames ="key1,key2,key3,key4" // key names can add or remove based on search string the requirement&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;| eval keys=split(keyNames ,";")&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;How to loop these keys and perform some operation.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I have tired with some MV commands but no luck.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Example:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;| eval count = mvcount(keys)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;| streamstats count as counter&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;| eval jsonKey= mvindex(keys,count) | eval keyValue = json_extract(json, jsonKey)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I am not sure how to achieve&amp;nbsp;this use case, can some one please help me on it.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 14 Dec 2022 07:34:32 GMT</pubDate>
    <dc:creator>bhanusaketi</dc:creator>
    <dc:date>2022-12-14T07:34:32Z</dc:date>
    <item>
      <title>How to do loop on array?</title>
      <link>https://community.splunk.com/t5/Monitoring-Splunk/How-to-do-loop-on-array/m-p/624181#M9242</link>
      <description>&lt;P&gt;How to loop the array values after split with delimiter&amp;nbsp;&lt;/P&gt;
&lt;P&gt;| eval&amp;nbsp;&lt;SPAN&gt;json="{"key1":"key1value","key2":"key2value","key3":"key3value","key4":"key4Value" }"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;| eval keyNames ="key1,key2,key3,key4" // key names can add or remove based on search string the requirement&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;| eval keys=split(keyNames ,";")&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;How to loop these keys and perform some operation.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I have tired with some MV commands but no luck.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Example:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;| eval count = mvcount(keys)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;| streamstats count as counter&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;| eval jsonKey= mvindex(keys,count) | eval keyValue = json_extract(json, jsonKey)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I am not sure how to achieve&amp;nbsp;this use case, can some one please help me on it.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Dec 2022 07:34:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Monitoring-Splunk/How-to-do-loop-on-array/m-p/624181#M9242</guid>
      <dc:creator>bhanusaketi</dc:creator>
      <dc:date>2022-12-14T07:34:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to do loop on array</title>
      <link>https://community.splunk.com/t5/Monitoring-Splunk/How-to-do-loop-on-array/m-p/624182#M9243</link>
      <description>&lt;P&gt;SPL is not a procedural language so there isn't a "loop through" construct per se. However, it depends on what it is you are trying to achieve as to whether there is another way to do it. For example, if you want to simply extract the key-value pairs from the json string use spath&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval json="{\"key1\":\"key1value\",\"key2\":\"key2value\",\"key3\":\"key3value\",\"key4\":\"key4Value\" }"
| spath input=json&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 14 Dec 2022 04:33:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Monitoring-Splunk/How-to-do-loop-on-array/m-p/624182#M9243</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-12-14T04:33:31Z</dc:date>
    </item>
  </channel>
</rss>

