cancel

splunkjs.Service.Job.cancel
Endpoint: search/jobs/{search_id}/control

Cancels a search job.

Syntax

cancel: function(callback)

Parameters

Name Type Description
callback Function

A function to call when the search is done: (err).

Examples

 var job = service.jobs().item("mysid");
 job.cancel(function(err) {
     console.log("CANCELLED");
 });

disablePreview

splunkjs.Service.Job.disablePreview
Endpoint: search/jobs/{search_id}/control

Disables preview generation for a search job.

Syntax

disablePreview: function(callback)

Parameters

Name Type Description
callback Function

A function to call with this search job: (err, job).

Examples

 var job = service.jobs().item("mysid");
 job.disablePreview(function(err, job) {
     console.log("PREVIEW DISABLED");
 });

enablePreview

splunkjs.Service.Job.enablePreview
Endpoint: search/jobs/{search_id}/control

Enables preview generation for a search job.

Syntax

enablePreview: function(callback)

Parameters

Name Type Description
callback Function

A function to call with this search job: (err, job).

Examples

 var job = service.jobs().item("mysid");
 job.disablePreview(function(err, job) {
     console.log("PREVIEW ENABLED");
 });

events

splunkjs.Service.Job.events
Endpoint: search/jobs/{search_id}/events

Returns the events of a search job with given parameters.

Syntax

events: function(params, callback)

Parameters

Name Type Description
params Object

The parameters for retrieving events. For a list of available parameters, see the GET search/jobs/{search_id}/events endpoint in the REST API documentation.

callback Function

A function to call when the events are retrieved: (err, events, job).

Examples

 var job = service.jobs().item("mysid");
 job.events({count: 10}, function(err, events, job) {
     console.log("Fields: ", events.fields);
 });

finalize

splunkjs.Service.Job.finalize
Endpoint: search/jobs/{search_id}/control

Finalizes a search job.

Syntax

finalize: function(callback)

Parameters

Name Type Description
callback Function

A function to call with the job: (err, job).

Examples

 var job = service.jobs().item("mysid");
 job.finalize(function(err, job) {
     console.log("JOB FINALIZED");
 });

init

splunkjs.Service.Job.init

Constructor for splunkjs.Service.Job.

Syntax

init: function(service, sid, namespace)

Parameters

Name Type Description
service splunkjs.Service

A Service instance.

sid String

The search ID for this search job.

namespace Object

Namespace information:
- owner (string): The Splunk username, such as "admin". A value of "nobody" means no specific user. The "-" wildcard means all users.
- app (string): The app context for this resource (such as "search"). The "-" wildcard means all apps.
- sharing (string): A mode that indicates how the resource is shared. The sharing mode can be "user", "app", "global", or "system".

Return

splunkjs.Service.Job.

A new splunkjs.Service.Job instance.

iterator

splunkjs.Service.Job.iterator
Endpoint: search/jobs/{search_id}/results

Returns an iterator over this search job's events or results.

Syntax

iterator: function(type, params)

Parameters

Name Type Description
type String

One of {"events", "preview", "results"}.

params Object

A dictionary of optional parameters:
- pagesize (integer): The number of items to return on each request. Defaults to as many as possible.

Return

Object.

An iterator object with a next(callback) method, where callback is of the form (err, results, hasMoreResults).

path

splunkjs.Service.Job.path

Retrieves the REST endpoint path for this resource (with no namespace).

Syntax

path: function()

pause

splunkjs.Service.Job.pause
Endpoint: search/jobs/{search_id}/control

Pauses a search job.

Syntax

pause: function(callback)

Parameters

Name Type Description
callback Function

A function to call with the job: (err, job).

Examples

 var job = service.jobs().item("mysid");
 job.pause(function(err, job) {
     console.log("JOB PAUSED");
 });

preview

splunkjs.Service.Job.preview
Endpoint: search/jobs/{search_id}/results_preview

Gets the preview results for a search job with given parameters.

Syntax

preview: function(params, callback)

Parameters

Name Type Description
params Object

The parameters for retrieving preview results. For a list of available parameters, see the GET search/jobs/{search_id}/results_preview endpoint in the REST API documentation.

callback Function

A function to call when the preview results are retrieved : (err, results, job).

Examples

 var job = service.jobs().item("mysid");
 job.preview({count: 10}, function(err, results, job) {
     console.log("Fields: ", results.fields);
 });

results

splunkjs.Service.Job.results
Endpoint: search/jobs/{search_id}/results

Gets the results for a search job with given parameters.

The callback can get undefined for its results parameter if the job is not yet done. To avoid this, use the Job.track() method to wait until the job is complete prior to fetching the results with this method.

Syntax

results: function(params, callback)

Parameters

Name Type Description
params Object

The parameters for retrieving search results. For a list of available parameters, see the GET search/jobs/{search_id}/results endpoint in the REST API documentation.

callback Function

A function to call when the results are retrieved: (err, results, job).

Examples

 var job = service.jobs().item("mysid");
 job.results({count: 10}, function(err, results, job) {
     console.log("Fields: ", results.results);
 });

searchlog

splunkjs.Service.Job.searchlog
Endpoint: search/jobs/{search_id}/search.log

Gets the search log for this search job.

Syntax

searchlog: function(callback)

Parameters

Name Type Description
callback Function

A function to call with the search log and job: (err, searchlog, job).

Examples

 var job = service.jobs().item("mysid");
 job.searchlog(function(err, searchlog, job) {
     console.log(searchlog);
 });

setPriority

splunkjs.Service.Job.setPriority
Endpoint: search/jobs/{search_id}/control

Sets the priority for this search job.

Syntax

setPriority: function(value, callback)

Parameters

Name Type Description
value Number

The priority (an integer between 1-10). A higher value means a higher priority.

callback Function

A function to call with the search job: (err, job).

Examples

 var job = service.jobs().item("mysid");
 job.setPriority(6, function(err, job) {
     console.log("JOB PRIORITY SET");
 });

setTTL

splunkjs.Service.Job.setTTL
Endpoint: search/jobs/{search_id}/control

Sets the time to live (TTL) for the search job, which is the time before the search job expires after it has been completed and is still available.

Syntax

setTTL: function(value, callback)

Parameters

Name Type Description
value Number

The time to live, in seconds.

callback Function

A function to call with the search job: (err, job).

Examples

 var job = service.jobs().item("mysid");
 job.setTTL(1000, function(err, job) {
     console.log("JOB TTL SET");
 });

summary

splunkjs.Service.Job.summary
Endpoint: search/jobs/{search_id}/summmary

Gets the summary for this search job with the given parameters.

Syntax

summary: function(params, callback)

Parameters

Name Type Description
params Object

The parameters for retrieving the summary. For a list of available parameters, see the GET search/jobs/{search_id}/summary endpoint in the REST API documentation.

callback Function

A function to call with the summary and search job: (err, summary, job).

Examples

 var job = service.jobs().item("mysid");
 job.summary({top_count: 5}, function(err, summary, job) {
     console.log("Summary: ", summary);
 });

timeline

splunkjs.Service.Job.timeline
Endpoint: search/jobs/{search_id}/timeline

Gets the timeline for this search job.

Syntax

timeline: function(params, callback)

Parameters

Name Type Description
params Object

The parameters for retrieving the timeline. For a list of available parameters, see the GET search/jobs/{search_id}/timeline endpoint in the REST API documentation.

callback Function

A function to call with the timeline and search job: (err, timeline, job).

Examples

 var job = service.jobs().item("mysid");
 job.timeline({time_format: "%c"}, function(err, job, timeline) {
     console.log("Timeline: ", timeline);
 });

touch

splunkjs.Service.Job.touch
Endpoint: search/jobs/{search_id}/control

Touches a search job, which means extending the expiration time of the search to now plus the time to live (TTL).

Syntax

touch: function(callback)

Parameters

Name Type Description
callback Function

A function to call with the search job: (err, job).

Examples

 var job = service.jobs().item("mysid");
 job.touch(function(err) {
     console.log("JOB TOUCHED");
 });

track

splunkjs.Service.Job.track

Starts polling the status of this search job, and fires callbacks upon each status change.

Syntax

track: function(options, callbacks)

Parameters

Name Type Description
options Object

A dictionary of optional parameters:
- period (integer): The number of milliseconds to wait between each poll. Defaults to 500.

callbacks Object,Function

A dictionary of optional callbacks:
- ready: A function (job) invoked when the job's properties first become available.
- progress: A function (job) invoked whenever new job properties are available.
- done: A function (job) invoked if the job completes successfully. No further polling is done.
- failed: A function (job) invoked if the job fails executing on the server. No further polling is done.
- error: A function (err) invoked if an error occurs while polling. No further polling is done.
Or, if a function (job), equivalent to passing it as a done callback.

unpause

splunkjs.Service.Job.unpause
Endpoint: search/jobs/{search_id}/control

Resumes a search job.

Syntax

unpause: function(callback)

Parameters

Name Type Description
callback Function

A function to call with the search job: (err, job).

Examples

 var job = service.jobs().item("mysid");
 job.unpause(function(err) {
     console.log("JOB UNPAUSED");
 });

_load

splunkjs.Service.Entity._load

Loads the entity and stores the properties.

Syntax

_load: function(properties)

Parameters

Name Type Description
properties Object

The properties for this entity.

acl

splunkjs.Service.Entity.acl

Retrieves the access control list (ACL) information for this entity, which contains the permissions for accessing the entity.

Syntax

acl: function()

Return

Object.

The ACL.

author

splunkjs.Service.Entity.author

Retrieves the author information for this entity.

Syntax

author: function()

Return

String.

The author.

del

splunkjs.Service.Endpoint.del

Performs a relative DELETE request on an endpoint's path, combined with the parameters and a relative path if specified.

Syntax

del: function(relpath, params, callback)

Parameters

Name Type Description
relpath String

A relative path to append to the endpoint path.

params Object

A dictionary of entity-specific parameters to add to the query string.

callback Function

A function to call when the request is complete: (err, response).

Examples

 // Will make a request to {service.prefix}/search/jobs/123456
 var endpoint = new splunkjs.Service.Endpoint(service, "search/jobs/12345");
 endpoint.delete("", {}, function() { console.log("DELETED"))});

disable

splunkjs.Service.Entity.disable

Disables the entity on the server.

Syntax

disable: function(callback)

Parameters

Name Type Description
callback Function

A function to call when the object is disabled: (err, entity).

enable

splunkjs.Service.Entity.enable

Enables the entity on the server.

Syntax

enable: function(callback)

Parameters

Name Type Description
callback Function

A function to call when the object is enabled: (err, entity).

fetch

splunkjs.Service.Entity.fetch

Refreshes the entity by fetching the object from the server and loading it.

Syntax

fetch: function(options, callback)

Parameters

Name Type Description
options Object

An optional dictionary of collection filtering and pagination options:
- count (integer): The maximum number of items to return.
- offset (integer): The offset of the first item to return.
- search (string): The search query to filter responses.
- sort_dir (string): The direction to sort returned items: “asc” or “desc”.
- sort_key (string): The field to use for sorting (optional).
- sort_mode (string): The collating sequence for sorting returned items: “auto”, “alpha”, “alpha_case”, or “num”.

callback Function

A function to call when the object is retrieved: (err, resource).

fetchOnUpdate

splunkjs.Service.Entity.fetchOnUpdate

A static property that indicates whether to call fetch after an update to get the updated entity. By default, the entity is not fetched because the endpoint returns (echoes) the updated entity.

fields

splunkjs.Service.Entity.fields

Retrieves the fields information for this entity, indicating which fields are wildcards, required, and optional.

Syntax

fields: function()

Return

Object.

The fields information.

get

splunkjs.Service.Endpoint.get

Performs a relative GET request on an endpoint's path, combined with the parameters and a relative path if specified.

Syntax

get: function(relpath, params, callback)

Parameters

Name Type Description
relpath String

A relative path to append to the endpoint path.

params Object

A dictionary of entity-specific parameters to add to the query string.

callback Function

A function to call when the request is complete: (err, response).

Examples

 // Will make a request to {service.prefix}/search/jobs/123456/results?offset=1
 var endpoint = new splunkjs.Service.Endpoint(service, "search/jobs/12345");
 endpoint.get("results", {offset: 1}, function() { console.log("DONE"))});

post

splunkjs.Service.Endpoint.post

Performs a relative POST request on an endpoint's path, combined with the parameters and a relative path if specified.

Syntax

post: function(relpath, params, callback)

Parameters

Name Type Description
relpath String

A relative path to append to the endpoint path.

params Object

A dictionary of entity-specific parameters to add to the body.

callback Function

A function to call when the request is complete: (err, response).

Examples

 // Will make a request to {service.prefix}/search/jobs/123456/control
 var endpoint = new splunkjs.Service.Endpoint(service, "search/jobs/12345");
 endpoint.post("control", {action: "cancel"}, function() { console.log("CANCELLED"))});

properties

splunkjs.Service.Resource.properties

Retrieves the current properties for this resource.

Syntax

properties: function()

Return

Object.

The properties.

published

splunkjs.Service.Entity.published

Retrieves the published time for this entity.

Syntax

published: function()

Return

String.

The published time.

reload

splunkjs.Service.Entity.reload

Reloads the entity on the server.

Syntax

reload: function(callback)

Parameters

Name Type Description
callback Function

A function to call when the object is reloaded: (err, entity).

remove

splunkjs.Service.Entity.remove

Deletes the entity from the server.

Syntax

remove: function(callback)

Parameters

Name Type Description
callback Function

A function to call when the object is deleted: (err).

state

splunkjs.Service.Resource.state

Retrieves the current full state (properties and metadata) of this resource.

Syntax

state: function()

Return

Object.

The current full state of this resource.

update

splunkjs.Service.Entity.update

Updates the entity on the server.

Syntax

update: function(props, callback)

Parameters

Name Type Description
props Object

The properties to update the object with.

callback Function

A function to call when the object is updated: (err, entity).

updated

splunkjs.Service.Entity.updated

Retrieves the updated time for this entity.

Syntax

updated: function()

Return

String.

The updated time.