<?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 Can Splunk index .gzip'd XMLs from a SQL database? in All Apps and Add-ons</title>
    <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Can-Splunk-index-gzip-d-XMLs-from-a-SQL-database/m-p/497239#M61162</link>
    <description>&lt;P&gt;We have a SQL table where a &lt;CODE&gt;binary_log_content&lt;/CODE&gt; field is a .gzip'd XML for the logs we'd like to ingest.&lt;/P&gt;

&lt;P&gt;How can I ingest these logs, short of using Python to query and save to a disk location that Splunk then monitors and auto-extracts?&lt;/P&gt;</description>
    <pubDate>Wed, 02 Oct 2019 23:27:57 GMT</pubDate>
    <dc:creator>nick405060</dc:creator>
    <dc:date>2019-10-02T23:27:57Z</dc:date>
    <item>
      <title>Can Splunk index .gzip'd XMLs from a SQL database?</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Can-Splunk-index-gzip-d-XMLs-from-a-SQL-database/m-p/497239#M61162</link>
      <description>&lt;P&gt;We have a SQL table where a &lt;CODE&gt;binary_log_content&lt;/CODE&gt; field is a .gzip'd XML for the logs we'd like to ingest.&lt;/P&gt;

&lt;P&gt;How can I ingest these logs, short of using Python to query and save to a disk location that Splunk then monitors and auto-extracts?&lt;/P&gt;</description>
      <pubDate>Wed, 02 Oct 2019 23:27:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Can-Splunk-index-gzip-d-XMLs-from-a-SQL-database/m-p/497239#M61162</guid>
      <dc:creator>nick405060</dc:creator>
      <dc:date>2019-10-02T23:27:57Z</dc:date>
    </item>
    <item>
      <title>Re: Can Splunk index .gzip'd XMLs from a SQL database?</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Can-Splunk-index-gzip-d-XMLs-from-a-SQL-database/m-p/497240#M61163</link>
      <description>&lt;P&gt;Splunk understands how to eat gzipped files so you do not have to do anything.  Because you already have this data in a database, there is no reason to archive the extracts so I suggest something like this so that Splunk deletes the files after it forwards them:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[batch:///path/to/your/files/*.xml.gz]
move_policy = sinkhole
sourcetype=foo
index=bar
host_segment=bat
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 02 Oct 2019 23:44:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Can-Splunk-index-gzip-d-XMLs-from-a-SQL-database/m-p/497240#M61163</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-10-02T23:44:13Z</dc:date>
    </item>
    <item>
      <title>Re: Can Splunk index .gzip'd XMLs from a SQL database?</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Can-Splunk-index-gzip-d-XMLs-from-a-SQL-database/m-p/497241#M61164</link>
      <description>&lt;P&gt;I don't think this actually answers my question @woodcock &lt;/P&gt;</description>
      <pubDate>Thu, 03 Oct 2019 17:55:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Can-Splunk-index-gzip-d-XMLs-from-a-SQL-database/m-p/497241#M61164</guid>
      <dc:creator>nick405060</dc:creator>
      <dc:date>2019-10-03T17:55:42Z</dc:date>
    </item>
    <item>
      <title>Re: Can Splunk index .gzip'd XMLs from a SQL database?</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Can-Splunk-index-gzip-d-XMLs-from-a-SQL-database/m-p/497242#M61165</link>
      <description>&lt;P&gt;You definitely cannot do it using dbconnect. If you do, you get the non-displayable column type image message:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://answers.splunk.com/answers/587501/splunk-db-connect-checkpoint-set-to-null.html"&gt;https://answers.splunk.com/answers/587501/splunk-db-connect-checkpoint-set-to-null.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Oct 2019 18:01:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Can-Splunk-index-gzip-d-XMLs-from-a-SQL-database/m-p/497242#M61165</guid>
      <dc:creator>nick405060</dc:creator>
      <dc:date>2019-10-09T18:01:15Z</dc:date>
    </item>
    <item>
      <title>Re: Can Splunk index .gzip'd XMLs from a SQL database?</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Can-Splunk-index-gzip-d-XMLs-from-a-SQL-database/m-p/497243#M61166</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;How can I ingest these logs, short of using Python to query and save to a disk location that Splunk then monitors and auto-extracts?&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;Okay well ignoring the "short of" part... this is how you do this. Despite being in the db_connect directory, this does not use db_connect. You can move things to system/local or another directory that you think is more correct, if desired.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;crontab -e&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;#!/usr/bin/env python3
* * * * * python3 /opt/splunk/etc/apps/splunk_app_db_connect/HOSTNAME_query.py
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;/opt/splunk/etc/apps/splunk_app_db_connect/HOSTNAME_query.py&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;import pymssql

conn = pymssql.connect(server='HOSTNAME:PORT',user='USERNAME',password='PASSWORD',database = 'DATABASE')
cursor = conn.cursor()
cursor.execute('SELECT MYFIELD,log_date FROM DATABASE.dbo.log_history WHERE log_date &amp;gt; DATEADD(day, -1, GETDATE())')

row = cursor.fetchone()
count = 0
while row:
    count = count+1
    row = cursor.fetchone()
    date=str(row[1])[:str(row[1]).index(' ')]
    open('/opt/splunk/var/run/splunk/xmlballs/'+date+'.gz','wb').write(row[0])
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;/opt/splunk/etc/apps/splunk_app_db_connect/local/inputs.conf&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[monitor:///opt/splunk/var/run/splunk/xmlballs]
disabled = 0
sourcetype=compressed_xml
index=MYINDEX
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 30 Sep 2020 02:30:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Can-Splunk-index-gzip-d-XMLs-from-a-SQL-database/m-p/497243#M61166</guid>
      <dc:creator>nick405060</dc:creator>
      <dc:date>2020-09-30T02:30:47Z</dc:date>
    </item>
    <item>
      <title>Re: Can Splunk index .gzip'd XMLs from a SQL database?</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Can-Splunk-index-gzip-d-XMLs-from-a-SQL-database/m-p/497244#M61167</link>
      <description>&lt;P&gt;You are correct, it was not immediately clear that it is a field in the CSV that is gzipped.  #cribl can do this.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Oct 2019 00:48:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Can-Splunk-index-gzip-d-XMLs-from-a-SQL-database/m-p/497244#M61167</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-10-11T00:48:19Z</dc:date>
    </item>
  </channel>
</rss>

