Splunk Search

How to delete Queried results from Splunk DB which are indexed?

dhsetty
Explorer
event_start=1
event_stop=500

search_parms = {'date_from': '1/10/2016:05:00', 'start': event_start, 'stop': event_stop, 'timeout': 60, 'date_to': '02/22/2017:23:39', 'mask_prvs': 0, 'maxresults': 100000},

SEARCH "mid=*" OR "icid=*" starttime::03/08/2017:00:00:00 endtime::03/15/2017:23:49:59maxtime::-1 maxevents::150000 GET events::101-600 OUTPUT splunkui::2.1

So, the Splunk response is for the above query search.

a. How to delete these results from Splunk DB which are indexed?
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Below is the code snippet, which uses "api_data" & does a "rpc" call. Can we tweek the below code snippet for deleting the Queried data from the Splunk DB?

cancel_id_token = '%s' % (cancel_id,)

    search_token = '<query>%s</query>' % (query,)
    user_token = '<user>livesplunkuser</user>'

    api_data = '<call name="executeQuery"> \
                    <params>' + \
                        self.auth_token + \
                        query_id_token + \
                        search_token + \
                        cancel_id_token + \
                        user_token + \
                   '</params> \
                </call>'

    if self.debug:
        P('api_data=%s'%(api_data,))

    try:
        self.server.request("POST", "/rpc", api_data)
        result = self.server.getresponse().read()
        return result
    except Exception, e:
        try:
            # The self.server might be used by other request, so try to use a new connection.
            server = get_proxy_server(self.url, self.port)
            server.request("POST", "/rpc", api_data)
            result = server.getresponse().read()
            server.close()
        except Exception, e:
            raise SplunkException('Could not connect to server to perform search (%s): %s'%(self.server, str(e),))
    return result

NOTE:
1. My another query, is there any option in api_data "call name" for deleting the query results from Splunk DB completely?
2. The above code snippet is from Email Security Appliance, which uses Splunk DB.

Thanks & Regards,
Dharmendra Setty

0 Karma

jplumsdaine22
Influencer

You can make individual events unsearchable using the delete command, (see here http://docs.splunk.com/Documentation/Splunk/6.5.2/SearchReference/Delete) or you can delete all the events in an index using the splunk clean (see here: http://docs.splunk.com/Documentation/Splunk/6.5.2/Admin/CLIadmincommands)

0 Karma

dhsetty
Explorer

Hi,
Basically Iam looking for connecting to Splunk from Email Security Appliance, then DELETE the
queried data between Time Time-1 & Time-2 from Splunk DB completely.

Thanks & Regards,
Dharmendra Setty

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...