<?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: Access Splunk app using Python SDK? in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Access-Splunk-app-using-Python-SDK/m-p/29738#M337</link>
    <description>&lt;P&gt;enter code hereIt seems that error 404 is "app template does not exist"&lt;BR /&gt;
Your API endpoint doesn't exist, as specified in &lt;A href="http://docs.splunk.com/Documentation/Splunk/4.2.4/RESTAPI/RESTapps#apps.2Flocal"&gt;API endpoint&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;If you want to get index in specified app namespace in Splunk:&lt;BR /&gt;
.splunkrc&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host=localhost
port=8089
username=admin
password=changeme
scheme=https
app=yourapp
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Code&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;usage = 'usage: %prog [options] &amp;lt;filename&amp;gt;*'
opts = parse(argv, RULES, ".splunkrc", usage=usage)

kwargs_splunk = dslice(opts.kwargs, FLAGS_SPLUNK)
service = client.connect(**kwargs_splunk)
name = opts.kwargs['index']
if not service.indexes.contains(name):
    error("Index '%s' does not exist." % name, 2)
index = service.indexes[name]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can change the configuration file to JSON format to get service instance.&lt;BR /&gt;
I hope it'll work&lt;/P&gt;</description>
    <pubDate>Sat, 10 Nov 2012 13:32:00 GMT</pubDate>
    <dc:creator>sieutruc</dc:creator>
    <dc:date>2012-11-10T13:32:00Z</dc:date>
    <item>
      <title>Access Splunk app using Python SDK?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Access-Splunk-app-using-Python-SDK/m-p/29737#M336</link>
      <description>&lt;P&gt;I am building a web app using Python to service a dashboard to users that we don't want to have direct access to Splunk.&lt;/P&gt;

&lt;P&gt;On Splunk search head, URL to the app is &lt;CODE&gt;&lt;A href="https://my.splunk.search.hear:8000/en-US/app/myapp/summary" target="test_blank"&gt;https://my.splunk.search.hear:8000/en-US/app/myapp/summary&lt;/A&gt;&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;So, here is a little Python code snippet:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;import splunklib.client as client

spconf = appconf['splunk']
splunk = client.connect(**spconf['server'])
result = splunk.get(spconf['index'])
return dict(content=result.body.read())
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Where, &lt;CODE&gt;appconf&lt;/CODE&gt; is read out of a JSON file like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    {
            "splunk":
            {
                    "server":
                    {
                            "host":         "*my.splunk.search.head*",
                            "port":         8089,
                            "username":     "*username*",
                            "password":     "*password*",
                            "app":          "myapp"
                    },
                    "index":        "summary"
            }
}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But all I am getting is 404 on the splunk.get() call.&lt;/P&gt;

&lt;P&gt;Thanks in advance for any insights.&lt;/P&gt;</description>
      <pubDate>Sat, 10 Nov 2012 00:31:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Access-Splunk-app-using-Python-SDK/m-p/29737#M336</guid>
      <dc:creator>ww9rivers</dc:creator>
      <dc:date>2012-11-10T00:31:32Z</dc:date>
    </item>
    <item>
      <title>Re: Access Splunk app using Python SDK?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Access-Splunk-app-using-Python-SDK/m-p/29738#M337</link>
      <description>&lt;P&gt;enter code hereIt seems that error 404 is "app template does not exist"&lt;BR /&gt;
Your API endpoint doesn't exist, as specified in &lt;A href="http://docs.splunk.com/Documentation/Splunk/4.2.4/RESTAPI/RESTapps#apps.2Flocal"&gt;API endpoint&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;If you want to get index in specified app namespace in Splunk:&lt;BR /&gt;
.splunkrc&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host=localhost
port=8089
username=admin
password=changeme
scheme=https
app=yourapp
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Code&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;usage = 'usage: %prog [options] &amp;lt;filename&amp;gt;*'
opts = parse(argv, RULES, ".splunkrc", usage=usage)

kwargs_splunk = dslice(opts.kwargs, FLAGS_SPLUNK)
service = client.connect(**kwargs_splunk)
name = opts.kwargs['index']
if not service.indexes.contains(name):
    error("Index '%s' does not exist." % name, 2)
index = service.indexes[name]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can change the configuration file to JSON format to get service instance.&lt;BR /&gt;
I hope it'll work&lt;/P&gt;</description>
      <pubDate>Sat, 10 Nov 2012 13:32:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Access-Splunk-app-using-Python-SDK/m-p/29738#M337</guid>
      <dc:creator>sieutruc</dc:creator>
      <dc:date>2012-11-10T13:32:00Z</dc:date>
    </item>
    <item>
      <title>Re: Access Splunk app using Python SDK?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Access-Splunk-app-using-Python-SDK/m-p/29739#M338</link>
      <description>&lt;P&gt;Thanks. OK. I replaced this line:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;result = splunk.get(spconf['index'])
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;with:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;result = splunk.indexes[spconf['index']].get()
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I got a result in XML, which seems to be data &lt;EM&gt;about&lt;/EM&gt; the app I want to access, not the result &lt;EM&gt;from&lt;/EM&gt; the app.&lt;/P&gt;

&lt;P&gt;I think I may be going at it in the wrong way. I think I need to get results from the app through the splunk web, rather through the splunkd (I am guessing that's what port 8089 is).&lt;/P&gt;</description>
      <pubDate>Sat, 10 Nov 2012 15:58:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Access-Splunk-app-using-Python-SDK/m-p/29739#M338</guid>
      <dc:creator>ww9rivers</dc:creator>
      <dc:date>2012-11-10T15:58:54Z</dc:date>
    </item>
    <item>
      <title>Re: Access Splunk app using Python SDK?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Access-Splunk-app-using-Python-SDK/m-p/29740#M339</link>
      <description>&lt;P&gt;It sounds like you want to be searching Splunk for some results and perhaps that search is embedded in a particular app somewhere.  So, the optimal way to expose results from Splunk in this scenario would be to execute the search from the python SDK and then return the results to your custom web app that is serving those customers/end users who are not logging in directly to the Splunk UI.  &lt;/P&gt;

&lt;P&gt;We have a number of search examples for the Python SDK here:  &lt;A href="http://dev.splunk.com/view/SP-CAAAEE5"&gt;http://dev.splunk.com/view/SP-CAAAEE5&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Mar 2013 15:23:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Access-Splunk-app-using-Python-SDK/m-p/29740#M339</guid>
      <dc:creator>psanford_splunk</dc:creator>
      <dc:date>2013-03-11T15:23:38Z</dc:date>
    </item>
  </channel>
</rss>

