-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathCreateLogsPipeline_1267211320.java
More file actions
52 lines (48 loc) · 2.38 KB
/
CreateLogsPipeline_1267211320.java
File metadata and controls
52 lines (48 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Create a pipeline with Array Processor Select Operation returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v1.api.LogsPipelinesApi;
import com.datadog.api.client.v1.model.LogsArrayProcessor;
import com.datadog.api.client.v1.model.LogsArrayProcessorOperation;
import com.datadog.api.client.v1.model.LogsArrayProcessorOperationSelect;
import com.datadog.api.client.v1.model.LogsArrayProcessorOperationSelectType;
import com.datadog.api.client.v1.model.LogsArrayProcessorType;
import com.datadog.api.client.v1.model.LogsFilter;
import com.datadog.api.client.v1.model.LogsPipeline;
import com.datadog.api.client.v1.model.LogsProcessor;
import java.util.Collections;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
LogsPipelinesApi apiInstance = new LogsPipelinesApi(defaultClient);
LogsPipeline body =
new LogsPipeline()
.filter(new LogsFilter().query("source:python"))
.name("testPipelineArraySelect")
.processors(
Collections.singletonList(
new LogsProcessor(
new LogsArrayProcessor()
.type(LogsArrayProcessorType.ARRAY_PROCESSOR)
.isEnabled(true)
.name("extract_referrer")
.operation(
new LogsArrayProcessorOperation(
new LogsArrayProcessorOperationSelect()
.type(LogsArrayProcessorOperationSelectType.SELECT)
.source("httpRequest.headers")
.target("referrer")
.filter("name:Referrer")
.valueToExtract("value"))))));
try {
LogsPipeline result = apiInstance.createLogsPipeline(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling LogsPipelinesApi#createLogsPipeline");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}