-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathCreateLogsCustomDestination_1735989579.java
More file actions
62 lines (58 loc) · 3.4 KB
/
CreateLogsCustomDestination_1735989579.java
File metadata and controls
62 lines (58 loc) · 3.4 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
53
54
55
56
57
58
59
60
61
62
// Create a Microsoft Sentinel custom destination returns "OK" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.LogsCustomDestinationsApi;
import com.datadog.api.client.v2.model.CustomDestinationAttributeTagsRestrictionListType;
import com.datadog.api.client.v2.model.CustomDestinationCreateRequest;
import com.datadog.api.client.v2.model.CustomDestinationCreateRequestAttributes;
import com.datadog.api.client.v2.model.CustomDestinationCreateRequestDefinition;
import com.datadog.api.client.v2.model.CustomDestinationForwardDestination;
import com.datadog.api.client.v2.model.CustomDestinationForwardDestinationMicrosoftSentinel;
import com.datadog.api.client.v2.model.CustomDestinationForwardDestinationMicrosoftSentinelType;
import com.datadog.api.client.v2.model.CustomDestinationResponse;
import com.datadog.api.client.v2.model.CustomDestinationType;
import java.util.Arrays;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
LogsCustomDestinationsApi apiInstance = new LogsCustomDestinationsApi(defaultClient);
CustomDestinationCreateRequest body =
new CustomDestinationCreateRequest()
.data(
new CustomDestinationCreateRequestDefinition()
.attributes(
new CustomDestinationCreateRequestAttributes()
.enabled(false)
.forwardTags(false)
.forwardTagsRestrictionList(Arrays.asList("datacenter", "host"))
.forwardTagsRestrictionListType(
CustomDestinationAttributeTagsRestrictionListType.ALLOW_LIST)
.forwarderDestination(
new CustomDestinationForwardDestination(
new CustomDestinationForwardDestinationMicrosoftSentinel()
.type(
CustomDestinationForwardDestinationMicrosoftSentinelType
.MICROSOFT_SENTINEL)
.tenantId("f3c9a8a1-4c2e-4d2e-b911-9f3c28c3c8b2")
.clientId("9a2f4d83-2b5e-429e-a35a-2b3c4182db71")
.dataCollectionEndpoint(
"https://my-dce-5kyl.eastus-1.ingest.monitor.azure.com")
.dataCollectionRuleId(
"dcr-000a00a000a00000a000000aa000a0aa")
.streamName("Custom-MyTable")))
.name("Nginx logs")
.query("source:nginx"))
.type(CustomDestinationType.CUSTOM_DESTINATION));
try {
CustomDestinationResponse result = apiInstance.createLogsCustomDestination(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println(
"Exception when calling LogsCustomDestinationsApi#createLogsCustomDestination");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}