/** * Returns the tsidx namespace which holds global acceleration events for this * data model. The namespace will be returned whether acceleration is enabled * or not. * * @return The tsidx namespace for global acceleration of this data model. */ public String getAccelerationNamespace() { // For the moment, the acceleration namespace for global acceleration of // data models is the name of the data model. return getName(); }
@Override Entity load(AtomObject value) { Entity result = super.load(value); // After loading the Atom entity as we would for any other Splunk entity, // we have to parse the JSON description of the data model and its acceleration // status. parseDescription(getString(RAW_JSON_LABEL)); parseAcceleration(getString(ACCELERATION_LABEL)); return result; }
DataModel(Service service, String path) { super(service, path); // The data provided by the collection is incomplete. Go ahead and refresh so we don't // have to worry about it. this.refresh(); }
/** * Local acceleration is tsidx acceleration of a data model object that is handled * manually by a user. You create a job which generates an index, and then use that * index in your pivots on the data model object. * * The namespace created by the job is 'sid={sid}' where {sid} is the job's sid. You * would use it in another job by starting your search query with * * | tstats ... from sid={sid} | ... * * The tsidx index created by this job is deleted when the job is garbage collected * by Splunk. * * It is the user's responsibility to manage this job, including cancelling it. * * @param earliestTime A time modifier (e.g., "-2w") setting the earliest time to index. * @return a Job writing a tsidx index. */ public Job createLocalAccelerationJob(String earliestTime) { String query = "| datamodel " + this.model.getName() + " " + this.getName() + " search | tscollect"; JobArgs args = new JobArgs(); if (earliestTime != null) { args.setEarliestTime(earliestTime); } return this.model.getService().search(query, args); }
PivotSpecification(DataModelObject dataModelObject) { this.dataModelObject = dataModelObject; if (dataModelObject.getDataModel().isAccelerated()) { this.accelerationNamespace = dataModelObject.getDataModel().getName(); } else { this.accelerationNamespace = null; } }
/** * @return The raw JSON describing this data model and its objects. */ public String getRawJson() { return getString(RAW_JSON_LABEL); }
/** * @return the data model object this one inherits from if it is a user defined data model object * in the same data model; otherwise returns null (for example if the data model object inherits from BaseEvent * or BaseTransaction). */ public DataModelObject getParent() { return this.getDataModel().getObject(this.parentName); }
/** * Start a job that applies querySuffix to all the events in this data model object. * * @param querySuffix a search query, starting with a '|' that will be appended to the command to fetch * the contents of this data model object (e.g., "| head 3"). * @param args arguments to control the job. * @return a Job object. */ public Job runQuery(String querySuffix, JobArgs args) { return getDataModel().getService().search(getQuery() + querySuffix, args); }
/** * Query Splunk for SPL queries corresponding to this pivot. * * @return a Pivot object encapsulating the returned queries. */ public Pivot pivot() { Service service = this.dataModelObject.getDataModel().getService(); Args args = new Args(); args.put("pivot_json", toJson()); if (this.accelerationNamespace != null) { args.put("namespace", this.accelerationNamespace); } ResponseMessage response = service.get( "datamodel/pivot/" + this.dataModelObject.getDataModel().getName(), args ); if (response.getStatus() != 200) { throw HttpException.create(response); } else { return Pivot.parseStream(service, response.getContent()); } } }
/** * @return the human readable name of this data model. */ public String getDisplayName() { return getString(DISPLAY_NAME_LABEL); }
/** * @return a JSON serialization of this object. */ JsonObject toJson() { JsonObject root = new JsonObject(); root.addProperty("dataModel", this.dataModelObject.getDataModel().getName()); root.addProperty("baseClass", this.dataModelObject.getName()); JsonArray filterArray = new JsonArray(); for (PivotFilter p : filters) { filterArray.add(p.toJson()); } root.add("filters", filterArray); JsonArray rowsplitArray = new JsonArray(); for (PivotRowSplit p : rows) { rowsplitArray.add(p.toJson()); } root.add("rows", rowsplitArray); JsonArray cellvalueArray = new JsonArray(); for (PivotCellValue p : cells) { cellvalueArray.add(p.toJson()); } root.add("cells", cellvalueArray); JsonArray columnsplitArray = new JsonArray(); for (PivotColumnSplit p : columns) { columnsplitArray.add(p.toJson()); } root.add("columns", columnsplitArray); return root; }
public String getQuery() { return "| datamodel " + this.getDataModel().getName() + " " + this.getName() + " search"; }