Splunk Dev

After adding a custom field in Splunk, why am I getting error "In handler 'oneshotinput': Argument "dateofdata" is not supported by this handler."?

sdaruna
Explorer

Hi,

I need to add a field which represents the date of the indexed data. I need to fetch the results in a search based on data. So, I tried to add a custom field in Splunk.

I added a new field in fields.conf file as follows.

[dateofdata]
INDEXED = True
INDEXED_VALUE = False

As I need to index the data using Splunk Java API, I used it as follows.

Service service = new Service("localhost", 8089);
        connect(loginArgs);

        Args eventArgs = new Args();
        eventArgs.put("sourcetype", "whole_file");
        eventArgs.put("host", "local");
        eventArgs.put("dateofdata","20160125");

        IndexCollection myIndexes = service.getIndexes();
        Index index = myIndexes.get("my_index3");

        index.upload(
                "/Users/srini/imp_work/xml_dump/2016-01-16/xml_file_1.xml",
                eventArgs);

I got the following error when I executed it.

Exception in thread "main" com.splunk.HttpException: HTTP 400 -- 
 In handler 'oneshotinput': Argument "dateofdata" is not supported by this handler.
    at com.splunk.HttpException.create(HttpException.java:84)
    at com.splunk.HttpService.send(HttpService.java:452)
    at com.splunk.Service.send(Service.java:1293)
    at com.splunk.HttpService.post(HttpService.java:308)
    at com.splunk.EntityCollection.create(EntityCollection.java:95)
    at com.splunk.Index.upload(Index.java:1131)
    at com.srini.splunk.SplunkExample.main(SplunkExample.java:31)
0 Karma

stephane_cyrill
Builder

HI, _indextime might help you.

The _indextimefield contains the time that an event was indexed, expressed in
Unix time. You might use this field to focus on or filter out events that were
indexed within a specific range of time.

0 Karma

sdaruna
Explorer

Hi Stephane,

I do not need the exact indexed time. I could index any date data at any time. But, i need to fetch data by date when receiving.

It was same error, if i tried to set _indextime field through program.

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 ...