Get specific data in xml as result of query, Using JAVA API


Suppose i create a Query and its output in XML contains 100+ elements(to be specific , using JAVA API). As per my need there are only few fields(like 4-5 out of 100+) that is important.

When i apply a query and get result as XML , it will be 100+ fields in one result . But i want to get only 3-4 fields as result out of 100+ elements.

As an example , consider this XML output file :-

<?xml version='1.0' encoding='UTF-8'?>
<results preview='0'>
    <result offset='0'>
        <field k='_bkt'>
        <field k='_cd'>
        <field k='_indextime'>
        <field k='_serial'>
        <field k='_si'>
        <field k='_sourcetype'>
        <field k='_subsecond'>
        <field k='_time'>
        <field k='index'>
        <field k='linecount'>
        <field k='source'>
        <field k='sourcetype'>
        <field k='splunk_server'>

From above XML file i need only 4 fields as result but what i am getting is more than 10 fields.

Is there any way to limit output of query?

I am doing all of this using JAVA API, not with Splunk UI

Tags (1)
0 Karma

0 Karma

0 Karma