Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Splunk Java SDK Example - Client/Server state
/**
* Set an Entity's property locally then update the state to the Splunk
* server
*/
public static void pushStateToServerExample() {
Service splunkService = connectAndLoginToSplunkExample();
EventTypeCollection eventTypeCollection = splunkService.getEventTypes();
EventType eventType = eventTypeCollection.create("test",
"index=_internal *");
eventType.setDescription("This is a test");
eventType.setPriority(3);
// update the state to the server
eventType.update();
}
/**
* Refresh an Entity's state locally from the Splunk server
*/
public static void getStateFromServerExample() {
Service splunkService = connectAndLoginToSplunkExample();
EventTypeCollection eventTypeCollection = splunkService.getEventTypes();
EventType eventType = eventTypeCollection.get("test");
// refresh the state locally
eventType.refresh();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.