Skip to content

Commit 0cabe5e

Browse files
Merge pull request #168 from SumoLogic/sumo_update_search_job_to_reflect_latest_values_set
SUMO-256760: update search job to reflect latest values set
2 parents ad04334 + 8eb9af4 commit 0cabe5e

5 files changed

Lines changed: 169 additions & 11 deletions

File tree

src/main/java/com/sumologic/client/SumoLogic.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,15 @@ String createSearchJob(
5858
* @return The search job ID.
5959
*/
6060
String createSearchJob(
61-
String query, String fromExpression, String toExpression, String timeZone, String byReceiptTime);
61+
String query,
62+
String fromExpression,
63+
String toExpression,
64+
String timeZone,
65+
String byReceiptTime,
66+
String intervalTimeType,
67+
String autoParsingMode,
68+
String parseMode,
69+
Boolean requiresRawMessages);
6270

6371
/**
6472
* Returns the current status of a search job.

src/main/java/com/sumologic/client/SumoLogicClient.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ private ConnectionConfig getConnectionConfig() {
115115
@Override
116116
public String createSearchJob(
117117
String query, String fromExpression, String toExpression, String timeZone) {
118-
return createSearchJob(query, fromExpression, toExpression, timeZone, "false");
118+
return createSearchJob(query, fromExpression, toExpression, timeZone, "false", null, "performance", "Manual", true);
119119
}
120120

121121

@@ -132,9 +132,17 @@ public String createSearchJob(
132132
*/
133133
@Override
134134
public String createSearchJob(
135-
String query, String fromExpression, String toExpression, String timeZone, String byReceiptTime) {
135+
String query,
136+
String fromExpression,
137+
String toExpression,
138+
String timeZone,
139+
String byReceiptTime,
140+
String intervalTimeType,
141+
String autoParsingMode,
142+
String parseMode,
143+
Boolean requiresRawMessages) {
136144
CreateSearchJobRequest createSearchJobRequest =
137-
new CreateSearchJobRequest(query, fromExpression, toExpression, timeZone, byReceiptTime);
145+
new CreateSearchJobRequest(query, fromExpression, toExpression, timeZone, byReceiptTime, intervalTimeType, autoParsingMode, parseMode, requiresRawMessages);
138146
return searchJobClient.createSearchJob(
139147
getConnectionConfig(), createSearchJobRequest);
140148
}

src/main/java/com/sumologic/client/searchjob/SearchJobExample.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,11 @@ public static void main(String[] args) throws Exception {
8383
"2013-03-10T13:10:00", // between this start time and
8484
"2013-03-10T13:11:00", // this end time, specified in ISO 8601 format
8585
"america/los_angeles", // and assuming we are in California.
86-
"false"); // use message time by default
86+
"false", // use message time by default
87+
null, // default to standard intervalType
88+
"performance", // choose performance in autoparse mode
89+
"Manual", // parse manually
90+
false); // default to no raw messages for agg query
8791

8892
// Note - above we are specifying the time
8993
// range using the ISO 8601 timestamp format.

src/main/java/com/sumologic/client/searchjob/SearchJobResultDumper.java

Lines changed: 74 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,14 @@ public static void main(String[] args) throws Exception {
7777

7878
String byReceiptTime = null;
7979

80+
String intervalTimeType = null;
81+
82+
String autoParsingMode = null;
83+
84+
String parseMode = null;
85+
86+
Boolean requiresRawMessages = true;
87+
8088
// In chunk mode, the number of hours to execute the search query in.
8189
long chunkIncrementMillis = -1;
8290

@@ -183,6 +191,22 @@ public static void main(String[] args) throws Exception {
183191
byReceiptTime = commandLine.getOptionValue("byReceiptTime");
184192
}
185193

194+
if (commandLine.hasOption("intervalTimeType")) {
195+
intervalTimeType = commandLine.getOptionValue("intervalTimeType");
196+
}
197+
198+
if (commandLine.hasOption("autoParsingMode")) {
199+
autoParsingMode = commandLine.getOptionValue("autoParsingMode");
200+
}
201+
if (commandLine.hasOption("parseMode")) {
202+
parseMode = commandLine.getOptionValue("parseMode");
203+
}
204+
205+
if (commandLine.hasOption("requiresRawMessages")) {
206+
requiresRawMessages = commandLine.hasOption("requiresRawMessages");
207+
}
208+
209+
186210
searchQuery = commandLine.getOptionValue("query");
187211
searchQueryFilename = commandLine.getOptionValue("file");
188212
if (commandLine.hasOption("json")) {
@@ -285,7 +309,11 @@ public static void main(String[] args) throws Exception {
285309
timezone,
286310
retry,
287311
lastEndFile,
288-
byReceiptTime);
312+
byReceiptTime,
313+
intervalTimeType,
314+
autoParsingMode,
315+
parseMode,
316+
requiresRawMessages);
289317
if (failure) {
290318
break;
291319
}
@@ -377,6 +405,31 @@ private static Options createOptions() {
377405
.withDescription("Search by receipt time instead of message time")
378406
.hasArg()
379407
.create("rt"));
408+
options.addOption(
409+
OptionBuilder.withLongOpt("intervalTimeType")
410+
.withArgName("intervalTimeType")
411+
.withDescription("Choose which interval type to query on")
412+
.hasArg()
413+
.create("itt"));
414+
options.addOption(
415+
OptionBuilder.withLongOpt("autoParsingMode")
416+
.withArgName("autoParsingMode")
417+
.withDescription("Decide whether the query has to be autoparsed or not")
418+
.hasArg()
419+
.create("apm"));
420+
options.addOption(
421+
OptionBuilder.withLongOpt("parseMode")
422+
.withArgName("parseMode")
423+
.withDescription("Deprecated old values such as performance, intelligent, and verbose")
424+
.hasArg()
425+
.create("pm"));
426+
options.addOption(
427+
OptionBuilder.withLongOpt("requiresRawMessages")
428+
.withArgName("requiresRawMessages")
429+
.withDescription("Check whether raw messages need to be fetched in results")
430+
.hasArg()
431+
.create("rrm"));
432+
380433
options.addOption(
381434
OptionBuilder.withLongOpt("hours")
382435
.withArgName("hours")
@@ -488,7 +541,11 @@ private static boolean executeSearchJobWithRetry(CSVWriter csvWriter,
488541
String timeZone,
489542
int retry,
490543
String lastEndFile,
491-
String byReceiptTime) {
544+
String byReceiptTime,
545+
String intervalTimeType,
546+
String autoParsingMode,
547+
String parseMode,
548+
Boolean requiresRawMessages) {
492549

493550
int triesLeft = retry;
494551
int attempt = 1;
@@ -512,7 +569,11 @@ private static boolean executeSearchJobWithRetry(CSVWriter csvWriter,
512569
timeZone,
513570
attempt,
514571
lastEndFile,
515-
byReceiptTime);
572+
byReceiptTime,
573+
intervalTimeType,
574+
autoParsingMode,
575+
parseMode,
576+
requiresRawMessages);
516577

517578
if (failure) {
518579
System.err.println(String.format(
@@ -539,15 +600,23 @@ private static boolean executeSearch(CSVWriter csvWriter,
539600
String timeZone,
540601
int attempt,
541602
String lastEndFile,
542-
String byReceiptTime) {
603+
String byReceiptTime,
604+
String intervalTimeType,
605+
String autoParsingMode,
606+
String parseMode,
607+
Boolean requiresRawMessages) {
543608

544609
// Create the search job.
545610
String searchJobId = sumoClient.createSearchJob(
546611
searchQuery,
547612
startTimestamp,
548613
endTimestamp,
549614
timeZone,
550-
byReceiptTime);
615+
byReceiptTime,
616+
intervalTimeType,
617+
autoParsingMode,
618+
parseMode,
619+
requiresRawMessages);
551620

552621
System.err.printf("[%s] %s - Search job ID: '%s', attempt: '%d'\n",
553622
new Date(), prefix, searchJobId, attempt);

src/main/java/com/sumologic/client/searchjob/model/CreateSearchJobRequest.java

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ public final class CreateSearchJobRequest implements HttpPostRequest {
2727
private String to;
2828
private String timeZone;
2929
private String byReceiptTime;
30+
private String intervalTimeType;
31+
private String autoParsingMode;
32+
private String parseMode;
33+
private Boolean requiresRawMessages;
34+
35+
36+
3037

3138
/**
3239
* Creates a search job request.
@@ -40,12 +47,20 @@ public CreateSearchJobRequest(String query,
4047
String from,
4148
String to,
4249
String timeZone,
43-
String byReceiptTime) {
50+
String byReceiptTime,
51+
String intervalTimeType,
52+
String autoParsingMode,
53+
String parseMode,
54+
Boolean requiresRawMessages) {
4455
this.query = query;
4556
this.from = from;
4657
this.to = to;
4758
this.timeZone = timeZone;
4859
this.byReceiptTime = byReceiptTime;
60+
this.intervalTimeType = intervalTimeType;
61+
this.autoParsingMode = autoParsingMode;
62+
this.parseMode = parseMode;
63+
this.requiresRawMessages = requiresRawMessages;
4964
}
5065

5166
/**
@@ -170,6 +185,39 @@ public void setByReceiptTime(String byReceiptTime) {
170185
this.byReceiptTime = byReceiptTime;
171186
}
172187

188+
public Boolean getRequiresRawMessages() {
189+
return requiresRawMessages;
190+
}
191+
192+
public void setRequiresRawMessages(Boolean requiresRawMessages) {
193+
this.requiresRawMessages = requiresRawMessages;
194+
}
195+
196+
public String getParseMode() {
197+
return parseMode;
198+
}
199+
200+
public void setParseMode(String parseMode) {
201+
this.parseMode = parseMode;
202+
}
203+
204+
public String getAutoParsingMode() {
205+
return autoParsingMode;
206+
}
207+
208+
public void setAutoParsingMode(String autoParsingMode) {
209+
this.autoParsingMode = autoParsingMode;
210+
}
211+
212+
public String getIntervalTimeType() {
213+
return intervalTimeType;
214+
}
215+
216+
public void setIntervalTimeType(String intervalTimeType) {
217+
this.intervalTimeType = intervalTimeType;
218+
}
219+
220+
173221
/**
174222
* Sets the by receipt time flag.
175223
*
@@ -180,4 +228,25 @@ public CreateSearchJobRequest withByReceiptTime(String byReceiptTime) {
180228
setByReceiptTime(byReceiptTime);
181229
return this;
182230
}
231+
232+
233+
public CreateSearchJobRequest withIntervalTimeType(String intervalTimeType) {
234+
setIntervalTimeType(intervalTimeType);
235+
return this;
236+
}
237+
238+
public CreateSearchJobRequest withAutoParsingMode(String autoParsingMode) {
239+
setAutoParsingMode(autoParsingMode);
240+
return this;
241+
}
242+
243+
public CreateSearchJobRequest withParseMode(String parseMode) {
244+
setParseMode(parseMode);
245+
return this;
246+
}
247+
public CreateSearchJobRequest withRequiresRawMessages(Boolean requiresRawMessages) {
248+
setRequiresRawMessages(requiresRawMessages);
249+
return this;
250+
}
251+
183252
}

0 commit comments

Comments
 (0)