<?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 do I Email results from Python script to users through REST API? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-Email-results-from-Python-script-to-users-through-REST/m-p/432863#M75687</link>
    <description>&lt;P&gt;Hello Experts,&lt;/P&gt;

&lt;P&gt;I have created a machine learning model and am  fetching data from Splunk to generate real-time predictions for my problem. I'm extracting the data from Splunk using REST API python library. &lt;/P&gt;

&lt;P&gt;Question:&lt;/P&gt;

&lt;P&gt;Once I generate the prediction from Python script, I have to email the result to specific users. I'm not sure how do I do that?&lt;/P&gt;

&lt;P&gt;Through REST API is there an Option to send the results using "sendemail" command? ( how do I pass result variable through REST ?)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;import splunklib.client as client
import splunklib.results as results
import sys
from time import sleep

service = client.connect(
  host=HOST,
  port=PORT,
  username=USERNAME,
  password=PASSWORD)
searchquery_normal = r"search criteria " 

kwargs_normalsearch = {"exec_mode": "normal"}
job = service.jobs.create(searchquery_normal, **kwargs_normalsearch)

#results as a dataframe
lst = list(results.ResultsReader(job.results()))
df = pd.DataFrame(lst)

#Apply the ML model and print the prediction
prediction = fittedModel.predict(np.array(df.head(1)))
print('Prediction = '+'{:,}'.format(int(p)))

#Send the prediction to a receipient


####something like
####searchquery_normal = r"|sendemail prediction value recipientaddress " 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I would really appreciate your help here.&lt;/P&gt;

&lt;P&gt;Thanks!&lt;BR /&gt;
Best,&lt;BR /&gt;
Harsha&lt;/P&gt;</description>
    <pubDate>Tue, 28 Aug 2018 15:20:12 GMT</pubDate>
    <dc:creator>harshavelocity</dc:creator>
    <dc:date>2018-08-28T15:20:12Z</dc:date>
    <item>
      <title>How do I Email results from Python script to users through REST API?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-I-Email-results-from-Python-script-to-users-through-REST/m-p/432863#M75687</link>
      <description>&lt;P&gt;Hello Experts,&lt;/P&gt;

&lt;P&gt;I have created a machine learning model and am  fetching data from Splunk to generate real-time predictions for my problem. I'm extracting the data from Splunk using REST API python library. &lt;/P&gt;

&lt;P&gt;Question:&lt;/P&gt;

&lt;P&gt;Once I generate the prediction from Python script, I have to email the result to specific users. I'm not sure how do I do that?&lt;/P&gt;

&lt;P&gt;Through REST API is there an Option to send the results using "sendemail" command? ( how do I pass result variable through REST ?)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;import splunklib.client as client
import splunklib.results as results
import sys
from time import sleep

service = client.connect(
  host=HOST,
  port=PORT,
  username=USERNAME,
  password=PASSWORD)
searchquery_normal = r"search criteria " 

kwargs_normalsearch = {"exec_mode": "normal"}
job = service.jobs.create(searchquery_normal, **kwargs_normalsearch)

#results as a dataframe
lst = list(results.ResultsReader(job.results()))
df = pd.DataFrame(lst)

#Apply the ML model and print the prediction
prediction = fittedModel.predict(np.array(df.head(1)))
print('Prediction = '+'{:,}'.format(int(p)))

#Send the prediction to a receipient


####something like
####searchquery_normal = r"|sendemail prediction value recipientaddress " 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I would really appreciate your help here.&lt;/P&gt;

&lt;P&gt;Thanks!&lt;BR /&gt;
Best,&lt;BR /&gt;
Harsha&lt;/P&gt;</description>
      <pubDate>Tue, 28 Aug 2018 15:20:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-I-Email-results-from-Python-script-to-users-through-REST/m-p/432863#M75687</guid>
      <dc:creator>harshavelocity</dc:creator>
      <dc:date>2018-08-28T15:20:12Z</dc:date>
    </item>
  </channel>
</rss>

