<?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: Getting data from referenced sources if no data found in selected source? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Getting-data-from-referenced-sources-if-no-data-found-in/m-p/635054#M220631</link>
    <description>&lt;P&gt;After reading the question again and again, I think I get the gist of the setup: the key is the differentiation between "&lt;SPAN&gt;selected source" and "referenced source". (The repeated use of Source_A and Source_B in both contexts makes the question extremely confusing.)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;But it is still unclear what "data" means in each of the word's four occurrences, and what "no data found" or "get data" really mean. &amp;nbsp;Let me make the following assumptions:&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN&gt;"data" simply means some value of a given field, or values of select fields.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;"no data found" mean that given field has no value in the "selected source". &amp;nbsp;Whether the field appeared in the source as null value or the field name doesn't appear in that source is unimportant.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;For simplicity, I will be looking for a field named 'data'.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=sample_index data=* (source="D:\datasource\*\release.xml" OR souce=D:\datasource\$selected_source$\referenced_source.txt)
| eval referenced_source = if(source == "D:\datasource\$selected_source$\referenced_source.txt", split(_raw, ","), null())
| eval referenced_source = mvmap(referenced_source, "D:\datasource\\" . referenced_source . "\release.xml")
| where source == "D:\datasource\$selected_source$\release.xml" OR source == referenced_source
| eval selected_data = if(source == "D:\datasource\$selected_source$\release.xml", data, null())
| stats latest(data) as latest_data values(selected_data) as selected_data
| eval data = coalesce(selected_data, latest_data)&lt;/LI-CODE&gt;&lt;P&gt;So, it is possible to do what you wanted if the assumptions are correct. &amp;nbsp;But it is not going to be particularly efficient because all sources have to be retrieved.&lt;/P&gt;</description>
    <pubDate>Sun, 19 Mar 2023 07:54:01 GMT</pubDate>
    <dc:creator>yuanliu</dc:creator>
    <dc:date>2023-03-19T07:54:01Z</dc:date>
    <item>
      <title>Getting data from referenced sources if no data found in selected source?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Getting-data-from-referenced-sources-if-no-data-found-in/m-p/634235#M220304</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I want to get data from an xml file from a selected source ( eg: &lt;STRONG&gt;Source_A&lt;/STRONG&gt;, &lt;STRONG&gt;Source_B&lt;/STRONG&gt;, ...). When there is no data found in xml file, is it possible to get data from the referenced xml sources and pick the latest one to display the data? The referenced sources are in a text file in the same location of selected source.&lt;/P&gt;&lt;P&gt;The structure of folders look like this:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;D:\datasource\&lt;STRONG&gt;&amp;lt;source_name&amp;gt;&lt;/STRONG&gt;\release.xml&lt;/LI&gt;&lt;LI&gt;D:\datasource\&lt;STRONG&gt;&amp;lt;source_name&amp;gt;&lt;/STRONG&gt;\referenced_sources.txt&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;The referenced_source text file contains values seperated by commas. Example:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Source_A,Source_B&lt;/LI-CODE&gt;&lt;P&gt;And my current SPL to retrieve data is:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=sample_index source=*$selected_source$* source="*.xml"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Mon, 13 Mar 2023 10:09:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Getting-data-from-referenced-sources-if-no-data-found-in/m-p/634235#M220304</guid>
      <dc:creator>boxmetal</dc:creator>
      <dc:date>2023-03-13T10:09:31Z</dc:date>
    </item>
    <item>
      <title>Re: Getting data from referenced sources if no data found in selected source?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Getting-data-from-referenced-sources-if-no-data-found-in/m-p/635054#M220631</link>
      <description>&lt;P&gt;After reading the question again and again, I think I get the gist of the setup: the key is the differentiation between "&lt;SPAN&gt;selected source" and "referenced source". (The repeated use of Source_A and Source_B in both contexts makes the question extremely confusing.)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;But it is still unclear what "data" means in each of the word's four occurrences, and what "no data found" or "get data" really mean. &amp;nbsp;Let me make the following assumptions:&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN&gt;"data" simply means some value of a given field, or values of select fields.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;"no data found" mean that given field has no value in the "selected source". &amp;nbsp;Whether the field appeared in the source as null value or the field name doesn't appear in that source is unimportant.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;For simplicity, I will be looking for a field named 'data'.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=sample_index data=* (source="D:\datasource\*\release.xml" OR souce=D:\datasource\$selected_source$\referenced_source.txt)
| eval referenced_source = if(source == "D:\datasource\$selected_source$\referenced_source.txt", split(_raw, ","), null())
| eval referenced_source = mvmap(referenced_source, "D:\datasource\\" . referenced_source . "\release.xml")
| where source == "D:\datasource\$selected_source$\release.xml" OR source == referenced_source
| eval selected_data = if(source == "D:\datasource\$selected_source$\release.xml", data, null())
| stats latest(data) as latest_data values(selected_data) as selected_data
| eval data = coalesce(selected_data, latest_data)&lt;/LI-CODE&gt;&lt;P&gt;So, it is possible to do what you wanted if the assumptions are correct. &amp;nbsp;But it is not going to be particularly efficient because all sources have to be retrieved.&lt;/P&gt;</description>
      <pubDate>Sun, 19 Mar 2023 07:54:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Getting-data-from-referenced-sources-if-no-data-found-in/m-p/635054#M220631</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-03-19T07:54:01Z</dc:date>
    </item>
  </channel>
</rss>

