<?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: job to update CSV file frequently using DBXquery in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-create-a-job-to-update-CSV-file-frequently-using-DBXquery/m-p/655563#M111067</link>
    <description>&lt;P&gt;So, for "on the SQL side", I am not a SQL DB expert, but I assume it's possible to detect changes made to a table, so if that occurs, use some database "magic" to run a process (I don't know how that is done) that calls the rest API.&lt;/P&gt;&lt;P&gt;As for the endpoints for search, they are all listed here&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/9.1.0/RESTREF/RESTsearch" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/9.1.0/RESTREF/RESTsearch&lt;/A&gt;&lt;/P&gt;&lt;P&gt;You can run _some_ of the rest commands in the Splunk UI, e.g.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rest /servicesNS/-/-/saved/searches
| table title&lt;/LI-CODE&gt;&lt;P&gt;will give you a list of all the saved searches&lt;/P&gt;&lt;P&gt;but when running the rest api via http request you need to authenticate, so you would call&lt;/P&gt;&lt;P&gt;&lt;A href="https://SplunkIP:8089/services/auth/login" target="_blank"&gt;https://SplunkIP:8089/services/auth/login&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/9.1.0/RESTREF/RESTaccess#auth.2Flogin" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/9.1.0/RESTREF/RESTaccess#auth.2Flogin&lt;/A&gt;&lt;/P&gt;&lt;P&gt;with username and password arguments and you will get back a sessionKey.&lt;/P&gt;&lt;P&gt;You can then use that sessionKey value as an Authorization header.&lt;/P&gt;&lt;P&gt;See this documentation&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/9.1.0/RESTUM/RESTusing#Authentication_and_authorization" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/9.1.0/RESTUM/RESTusing#Authentication_and_authorization&lt;/A&gt;&lt;/P&gt;&lt;P&gt;It is easy enough to manipulate JSON into another format, so if you have a search that is getting the data, then ask another question about how you can convert that to a format suitable to export a CSV&lt;/P&gt;</description>
    <pubDate>Fri, 25 Aug 2023 00:55:46 GMT</pubDate>
    <dc:creator>bowesmana</dc:creator>
    <dc:date>2023-08-25T00:55:46Z</dc:date>
    <item>
      <title>How to create a job to update CSV file frequently using DBXquery?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-create-a-job-to-update-CSV-file-frequently-using-DBXquery/m-p/655405#M111048</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;&lt;STRONG&gt;How do I create a job to update CSV file frequently using DBXquery?&lt;/STRONG&gt;&lt;BR /&gt;I have a company.csv file that was created by running a DBXquery search and uploaded into Splunk lookups. Whenever there is an update on the data, I need to manually run DBXquery search, download the CSV file, delete the existing CSV file, then re-upload it to Splunk lookups.&amp;nbsp; &amp;nbsp;In order to automate the process, I am thinking to use a job that executes DBXquery and outputlookup. Please suggest&lt;BR /&gt;Thank you All for your help.&lt;BR /&gt;&lt;BR /&gt;Query:&lt;BR /&gt;&lt;SPAN&gt;| dbxquery query="select * from tableCompany"&lt;BR /&gt;&lt;/SPAN&gt;&lt;BR /&gt;Table 1:&amp;nbsp;company.csv&lt;/P&gt;
&lt;TABLE border="1" width="467.00000000000006px"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="155.66666666666669px"&gt;ip_address&lt;/TD&gt;
&lt;TD width="155.66666666666669px"&gt;company&lt;/TD&gt;
&lt;TD width="155.66666666666669px"&gt;location&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="155.66666666666669px"&gt;192.168.1.1&lt;/TD&gt;
&lt;TD width="155.66666666666669px"&gt;Comp-A&lt;/TD&gt;
&lt;TD width="155.66666666666669px"&gt;Loc-A&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="155.66666666666669px"&gt;192.168.1.2&lt;/TD&gt;
&lt;TD width="155.66666666666669px"&gt;Comp-B&lt;/TD&gt;
&lt;TD width="155.66666666666669px"&gt;Loc-B&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="155.66666666666669px"&gt;192.168.1.5&lt;/TD&gt;
&lt;TD width="155.66666666666669px"&gt;Comp-E&lt;/TD&gt;
&lt;TD width="155.66666666666669px"&gt;Loc-E&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Thu, 24 Aug 2023 17:28:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-create-a-job-to-update-CSV-file-frequently-using-DBXquery/m-p/655405#M111048</guid>
      <dc:creator>LearningGuy</dc:creator>
      <dc:date>2023-08-24T17:28:31Z</dc:date>
    </item>
    <item>
      <title>Re: job to update CSV file frequently using DBXquery</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-create-a-job-to-update-CSV-file-frequently-using-DBXquery/m-p/655419#M111049</link>
      <description>&lt;P&gt;There are a couple of ways to get the updates&lt;/P&gt;&lt;P&gt;1. Make a saved search based on your dbquery that runs on a cron schedule (hourly/daily/weekly) and does your search + outputlookup - note that as this is run on a schedule, it will not guarantee a hit of the lookup if the Splunk vuln events contain a new IP that is not in the lookup and potentially if you are using DHCP and IP addresses change, it may actually give the wrong company data, but that's an issue in general.&lt;/P&gt;&lt;P&gt;2. Get a trigger on the SQL side to run a script that executes a REST API search on Splunk to run that search, so it will be updated immediately - the only issue with this is that it may end up triggering so often, it just runs all the time.&lt;/P&gt;&lt;P&gt;I notice all the IPs are 192.168 local addresses - do you have a company policy that allocates IPs based on subnets? Is there any way that if the lookup cannot find the address it makes calculations on the subnet to determine a 'default' company.&lt;/P&gt;&lt;P&gt;Note that any time you're using replicated data, there's potential for stale results - you will have the DB copy, the local search head copy and the copy replicated to the indexer. Depending on how often your data changes, you may need to factor this in.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Aug 2023 23:15:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-create-a-job-to-update-CSV-file-frequently-using-DBXquery/m-p/655419#M111049</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2023-08-23T23:15:59Z</dc:date>
    </item>
    <item>
      <title>Re: job to update CSV file frequently using DBXquery</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-create-a-job-to-update-CSV-file-frequently-using-DBXquery/m-p/655426#M111051</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;Can you provide an example or a website that shows an example for your suggestion no 1 and 2?&lt;BR /&gt;&lt;BR /&gt;Thank you for your help.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Aug 2023 01:58:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-create-a-job-to-update-CSV-file-frequently-using-DBXquery/m-p/655426#M111051</guid>
      <dc:creator>LearningGuy</dc:creator>
      <dc:date>2023-08-24T01:58:16Z</dc:date>
    </item>
    <item>
      <title>Re: job to update CSV file frequently using DBXquery</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-create-a-job-to-update-CSV-file-frequently-using-DBXquery/m-p/655441#M111056</link>
      <description>&lt;P&gt;You've already written the SQL&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| dbxquery query="select * from tableCompany"
| table ip_address company location
| outputlookup your_csv_file.csv&lt;/LI-CODE&gt;&lt;P&gt;and then just 'Save As' a Report and then in the Schedule window select the sort of frequency you want, e.g. for a cron schedule to run just after 11pm every day make the schedule&lt;/P&gt;&lt;P&gt;07 23 * * *&lt;/P&gt;&lt;P&gt;for 7 minutes past 11pm&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/9.1.0/Report/Configurethepriorityofscheduledreports" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/9.1.0/Report/Configurethepriorityofscheduledreports&lt;/A&gt;&lt;/P&gt;&lt;P&gt;and then it will run daily and create your lookup.&lt;/P&gt;&lt;P&gt;As for running it from the rest api - see&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/9.1.0/RESTREF/RESTsearch#saved.2Fsearches.2F.7Bname.7D.2Fdispatch" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/9.1.0/RESTREF/RESTsearch#saved.2Fsearches.2F.7Bname.7D.2Fdispatch&lt;/A&gt;&lt;/P&gt;&lt;P&gt;and&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.splunk.com/t5/forums/searchpage/tab/message?advanced=false&amp;amp;allow_punctuation=false&amp;amp;filter=location&amp;amp;location=forum-board:getting-data-in&amp;amp;q=rest%20api%20savedsearch" target="_blank"&gt;https://community.splunk.com/t5/forums/searchpage/tab/message?advanced=false&amp;amp;allow_punctuation=false&amp;amp;filter=location&amp;amp;location=forum-board:getting-data-in&amp;amp;q=rest%20api%20savedsearch&lt;/A&gt;&lt;/P&gt;&lt;P&gt;which has a bunch of questions about running saved searches.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Aug 2023 06:49:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-create-a-job-to-update-CSV-file-frequently-using-DBXquery/m-p/655441#M111056</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2023-08-24T06:49:08Z</dc:date>
    </item>
    <item>
      <title>Re: job to update CSV file frequently using DBXquery</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-create-a-job-to-update-CSV-file-frequently-using-DBXquery/m-p/655501#M111064</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;I have accepted your suggestion no 1 as a solution.&amp;nbsp; &amp;nbsp;Thank you for your assistance.&lt;BR /&gt;For your suggestion no 2,&amp;nbsp; you said "&lt;EM&gt;Get a trigger on the &lt;STRONG&gt;SQL side&lt;/STRONG&gt; to run a script that executes a REST API search&lt;/EM&gt;"&amp;nbsp; &amp;nbsp; I read some of the documentation you sent about REST API Splunk&lt;BR /&gt;&lt;STRONG&gt;1) What do you mean on the SQL side?&lt;/STRONG&gt;&lt;BR /&gt;My understanding is we can call REST API &lt;A href="https://splunkserverIP:8089/search" target="_blank"&gt;https://splunkserverIP:8089/search&lt;/A&gt;&amp;nbsp; (not sure the exact URL) that contains DBX query search that output the result to a CSV file&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;2) How do I see what endpoint is available to access?&amp;nbsp;&lt;/STRONG&gt;&lt;BR /&gt;I tried to access&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://127.0.0.1:8089/servicesNS/admin/search/saved/searches" rel="nofollow noopener noreferrer" target="_blank"&gt;https://SplunkIP:8089/servicesNS/admin/search/saved/searches,&lt;/A&gt;&lt;BR /&gt;but it wasn't reachable, I am assuming I am not the admin&lt;BR /&gt;&lt;BR /&gt;3) The data from DBXquery was obtained from another source. We provided JSON file to Splunk admin to import into Splunk DB. The JSON file was generated by&amp;nbsp; python script pulling the data via API.&lt;BR /&gt;Is it possible If I create python script to parse JSON file to generate CSV file and have a job running to pull CSV file?&amp;nbsp; &amp;nbsp; If yes, which one is better solution compared to generating CSV from Splunk search?&lt;BR /&gt;Thank you!!&lt;/P&gt;</description>
      <pubDate>Thu, 24 Aug 2023 14:16:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-create-a-job-to-update-CSV-file-frequently-using-DBXquery/m-p/655501#M111064</guid>
      <dc:creator>LearningGuy</dc:creator>
      <dc:date>2023-08-24T14:16:20Z</dc:date>
    </item>
    <item>
      <title>Re: job to update CSV file frequently using DBXquery</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-create-a-job-to-update-CSV-file-frequently-using-DBXquery/m-p/655563#M111067</link>
      <description>&lt;P&gt;So, for "on the SQL side", I am not a SQL DB expert, but I assume it's possible to detect changes made to a table, so if that occurs, use some database "magic" to run a process (I don't know how that is done) that calls the rest API.&lt;/P&gt;&lt;P&gt;As for the endpoints for search, they are all listed here&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/9.1.0/RESTREF/RESTsearch" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/9.1.0/RESTREF/RESTsearch&lt;/A&gt;&lt;/P&gt;&lt;P&gt;You can run _some_ of the rest commands in the Splunk UI, e.g.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rest /servicesNS/-/-/saved/searches
| table title&lt;/LI-CODE&gt;&lt;P&gt;will give you a list of all the saved searches&lt;/P&gt;&lt;P&gt;but when running the rest api via http request you need to authenticate, so you would call&lt;/P&gt;&lt;P&gt;&lt;A href="https://SplunkIP:8089/services/auth/login" target="_blank"&gt;https://SplunkIP:8089/services/auth/login&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/9.1.0/RESTREF/RESTaccess#auth.2Flogin" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/9.1.0/RESTREF/RESTaccess#auth.2Flogin&lt;/A&gt;&lt;/P&gt;&lt;P&gt;with username and password arguments and you will get back a sessionKey.&lt;/P&gt;&lt;P&gt;You can then use that sessionKey value as an Authorization header.&lt;/P&gt;&lt;P&gt;See this documentation&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/9.1.0/RESTUM/RESTusing#Authentication_and_authorization" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/9.1.0/RESTUM/RESTusing#Authentication_and_authorization&lt;/A&gt;&lt;/P&gt;&lt;P&gt;It is easy enough to manipulate JSON into another format, so if you have a search that is getting the data, then ask another question about how you can convert that to a format suitable to export a CSV&lt;/P&gt;</description>
      <pubDate>Fri, 25 Aug 2023 00:55:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-create-a-job-to-update-CSV-file-frequently-using-DBXquery/m-p/655563#M111067</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2023-08-25T00:55:46Z</dc:date>
    </item>
  </channel>
</rss>

