addBooleanColumnSplit

splunkjs.Service.PivotSpecification.addBooleanColumnSplit

Add a column split on a boolean valued field.

Syntax

addBooleanColumnSplit: function(fieldName, trueDisplayValue, falseDisplayValue)

Parameters

Name Type Description
fieldName String

The name of field to split on.

trueDisplayValue String

A string to display in the true valued column label.

falseDisplayValue String

A string to display in the false valued column label.

Return

splunkjs.Service.PivotSpecification.

The updated pivot specification.

addBooleanRowSplit

splunkjs.Service.PivotSpecification.addBooleanRowSplit

Add a row split on a boolean valued field.

Syntax

addBooleanRowSplit: function(field, label, trueDisplayValue, falseDisplayValue)

Parameters

Name Type Description
fieldName String

The name of field to split on.

label String

A human readable name for this set of rows.

trueDisplayValue String

A string to display in the true valued row label.

falseDisplayValue String

A string to display in the false valued row label.

Return

splunkjs.Service.PivotSpecification.

The updated pivot specification.

addCellValue

splunkjs.Service.PivotSpecification.addCellValue

Add an aggregate to each cell of the pivot.

Syntax

addCellValue: function(fieldName, label, statsFunction)

Parameters

Name Type Description
fieldName String

The name of field to aggregate.

label String

a human readable name for this aggregate.

statsFunction String

The function to use for aggregation, see class docs for valid stats functions.

Return

splunkjs.Service.PivotSpecification.

The updated pivot specification.

addColumnSplit

splunkjs.Service.PivotSpecification.addColumnSplit

Add a column split on a string or number valued field, producing a column for each distinct value of the field.

Syntax

addColumnSplit: function(fieldName)

Parameters

Name Type Description
fieldName String

The name of field to split on.

Return

splunkjs.Service.PivotSpecification.

The updated pivot specification.

addFilter

splunkjs.Service.PivotSpecification.addFilter

Add a filter on a boolean valued field. The filter will be a constraint of the form fieldcomparisoncompareTo, for example: is_remote = false.

Syntax

addFilter: function(fieldName, comparisonType, comparisonOp, compareTo)

Parameters

Name Type Description
fieldName String

The name of field to filter on

comparisonType String

The type of comparison, see class docs for valid types.

comparisonOp String

The comparison, see class docs for valid comparisons, based on type.

compareTo String

The value to compare the field to.

Return

splunkjs.Service.PivotSpecification.

The updated pivot specification.

addLimitFilter

splunkjs.Service.PivotSpecification.addLimitFilter

Add a limit on the events shown in a pivot by sorting them according to some field, then taking the specified number from the beginning or end of the list.

Syntax

addLimitFilter: function(fieldName, sortAttribute, sortDirection, limit, statsFunction)

Parameters

Name Type Description
fieldName String

The name of field to filter on.

sortAttribute String

The name of the field to use for sorting.

sortDirection String

The direction to sort events, see class docs for valid types.

limit String

The number of values from the sorted list to allow through this filter.

statsFunction String

The stats function to use for aggregation before sorting, see class docs for valid types.

Return

splunkjs.Service.PivotSpecification.

The updated pivot specification.

addRangeColumnSplit

splunkjs.Service.PivotSpecification.addRangeColumnSplit

Add a column split on a numeric field, splitting the values into ranges.

Syntax

addRangeColumnSplit: function(fieldName, ranges)

Parameters

Name Type Description
fieldName String

The field to split on.

options Object

An optional dictionary of collection filtering and pagination options:
- start (integer): The value of the start of the first range, or null to take the lowest value in the events.
- end (integer): The value for the end of the last range, or null to take the highest value in the events.
- step (integer): The the width of each range, or null to have Splunk calculate it.
- limit (integer): The maximum number of ranges to split into, or null for no limit.

Return

splunkjs.Service.PivotSpecification.

The updated pivot specification.

addRangeRowSplit

splunkjs.Service.PivotSpecification.addRangeRowSplit

Add a row split on a numeric field, splitting into numeric ranges.

This split generates bins with edges equivalent to the classic loop 'for i in to by ' but with a maximum number of bins . This dispatches to the stats and xyseries search commands. See their documentation for more details.

Syntax

addRangeRowSplit: function(field, label, ranges)

Parameters

Name Type Description
fieldName String

The field to split on.

label String

A human readable name for this set of rows.

options Object

An optional dictionary of collection filtering and pagination options:
- start (integer): The value of the start of the first range, or null to take the lowest value in the events.
- end (integer): The value for the end of the last range, or null to take the highest value in the events.
- step (integer): The the width of each range, or null to have Splunk calculate it.
- limit (integer): The maximum number of ranges to split into, or null for no limit.

Return

splunkjs.Service.PivotSpecification.

The updated pivot specification.

addRowSplit

splunkjs.Service.PivotSpecification.addRowSplit

Add a row split on a numeric or string valued field, splitting on each distinct value of the field.

Syntax

addRowSplit: function(fieldName, label)

Parameters

Name Type Description
fieldName String

The name of field to split on.

label String

A human readable name for this set of rows.

Return

splunkjs.Service.PivotSpecification.

The updated pivot specification.

addTimestampColumnSplit

splunkjs.Service.PivotSpecification.addTimestampColumnSplit

Add a column split on a timestamp valued field, binned by the specified bucket size.

Syntax

addTimestampColumnSplit: function(field, binning)

Parameters

Name Type Description
fieldName String

The name of field to split on.

binning String

The size of bins to use, see class docs for valid types.

Return

splunkjs.Service.PivotSpecification.

The updated pivot specification.

addTimestampRowSplit

splunkjs.Service.PivotSpecification.addTimestampRowSplit

Add a row split on a timestamp valued field, binned by the specified bucket size.

Syntax

addTimestampRowSplit: function(field, label, binning)

Parameters

Name Type Description
fieldName String

The name of field to split on.

label String

A human readable name for this set of rows.

binning String

The size of bins to use, see class docs for valid types.

Return

splunkjs.Service.PivotSpecification.

The updated pivot specification.

init

splunkjs.Service.PivotSpecification.init

Constructor for a pivot specification.

Syntax

init: function(dataModelObject)

Parameters

Name Type Description
parentDataModel splunkjs.Service.DataModel

The DataModel that owns this data model object.

pivot

splunkjs.Service.PivotSpecification.pivot

Query Splunk for SPL queries corresponding to a pivot report for this data model, defined by this PivotSpecification.

Syntax

pivot: function(callback)

Parameters

Name Type Description
callback Function

A function to call when done getting the pivot: (err, pivot).

Examples

 service.dataModels().fetch(function(err, dataModels) {
     var searches = dataModels.item("internal_audit_logs").objectByName("searches");
     var pivotSpec = searches.createPivotSpecification();
     // Use of the fluent API
     pivotSpec.addRowSplit("user", "Executing user")
         .addRangeColumnSplit("exec_time", {start: 0, end: 12, step: 5, limit: 4})
         .addCellValue("search", "Search Query", "values")
         .pivot(function(pivotErr, pivot) {
             console.log("Pivot search is:", pivot.search);
         });
 });

run

splunkjs.Service.PivotSpecification.run

Convenience method to wrap up the PivotSpecification.pivot() and Pivot.run() function calls.

Query Splunk for SPL queries corresponding to a pivot report for this data model, defined by this PivotSpecification; then, starts a search job running this pivot, accelerated if possible.

 service.dataModels().fetch(function(fetchErr, dataModels) {
     var searches = dataModels.item("internal_audit_logs").objectByName("searches");
     var pivotSpec = searches.createPivotSpecification();
     // Use of the fluent API
     pivotSpec.addRowSplit("user", "Executing user")
         .addRangeColumnSplit("exec_time", {start: 0, end: 12, step: 5, limit: 4})
         .addCellValue("search", "Search Query", "values")
         .run(function(err, job, pivot) {
             console.log("Job SID is:", job.sid);
             console.log("Pivot search is:", pivot.search);
         });
 });

Syntax

run: function(args, callback)

Parameters

Name Type Description
args Object

A dictionary of properties for the search job (optional). For a list of available parameters, see Search job parameters on Splunk Developer Portal.
Note: This method throws an error if the exec_mode=oneshot parameter is passed in with the properties dictionary.

callback Function

A function to call when done getting the pivot: (err, job, pivot).

setAccelerationJob

splunkjs.Service.PivotSpecification.setAccelerationJob

Set the acceleration cache for this pivot specification to a job, usually generated by createLocalAccelerationJob on a DataModelObject instance, as the acceleration cache for this pivot specification.

Syntax

setAccelerationJob: function(sid)

Parameters

Name Type Description
sid String,splunkjs.Service.Job

The sid of an acceleration job,
or, a splunkjs.Service.Job instance.

Return

splunkjs.Service.PivotSpecification.

The updated pivot specification.

toJsonObject

splunkjs.Service.PivotSpecification.toJsonObject

Returns a JSON ready object representation of this pivot specification.

Syntax

toJsonObject: function()

Return

Object.

The JSON ready object representation of this pivot specification.