|
| 1 | +// Create a pipeline with Decoder Processor returns "OK" response |
| 2 | + |
| 3 | +import com.datadog.api.client.ApiClient; |
| 4 | +import com.datadog.api.client.ApiException; |
| 5 | +import com.datadog.api.client.v1.api.LogsPipelinesApi; |
| 6 | +import com.datadog.api.client.v1.model.LogsDecoderProcessor; |
| 7 | +import com.datadog.api.client.v1.model.LogsDecoderProcessorBinaryToTextEncoding; |
| 8 | +import com.datadog.api.client.v1.model.LogsDecoderProcessorInputRepresentation; |
| 9 | +import com.datadog.api.client.v1.model.LogsDecoderProcessorType; |
| 10 | +import com.datadog.api.client.v1.model.LogsFilter; |
| 11 | +import com.datadog.api.client.v1.model.LogsPipeline; |
| 12 | +import com.datadog.api.client.v1.model.LogsProcessor; |
| 13 | +import java.util.Collections; |
| 14 | + |
| 15 | +public class Example { |
| 16 | + public static void main(String[] args) { |
| 17 | + ApiClient defaultClient = ApiClient.getDefaultApiClient(); |
| 18 | + LogsPipelinesApi apiInstance = new LogsPipelinesApi(defaultClient); |
| 19 | + |
| 20 | + LogsPipeline body = |
| 21 | + new LogsPipeline() |
| 22 | + .filter(new LogsFilter().query("source:python")) |
| 23 | + .name("testDecoderProcessor") |
| 24 | + .processors( |
| 25 | + Collections.singletonList( |
| 26 | + new LogsProcessor( |
| 27 | + new LogsDecoderProcessor() |
| 28 | + .type(LogsDecoderProcessorType.DECODER_PROCESSOR) |
| 29 | + .isEnabled(true) |
| 30 | + .name("test_decoder") |
| 31 | + .source("encoded.field") |
| 32 | + .target("decoded.field") |
| 33 | + .binaryToTextEncoding(LogsDecoderProcessorBinaryToTextEncoding.BASE16) |
| 34 | + .inputRepresentation(LogsDecoderProcessorInputRepresentation.UTF_8)))); |
| 35 | + |
| 36 | + try { |
| 37 | + LogsPipeline result = apiInstance.createLogsPipeline(body); |
| 38 | + System.out.println(result); |
| 39 | + } catch (ApiException e) { |
| 40 | + System.err.println("Exception when calling LogsPipelinesApi#createLogsPipeline"); |
| 41 | + System.err.println("Status code: " + e.getCode()); |
| 42 | + System.err.println("Reason: " + e.getResponseBody()); |
| 43 | + System.err.println("Response headers: " + e.getResponseHeaders()); |
| 44 | + e.printStackTrace(); |
| 45 | + } |
| 46 | + } |
| 47 | +} |
0 commit comments