-
Notifications
You must be signed in to change notification settings - Fork 11
/
DataCollectionRulesCreate.go
110 lines (107 loc) · 4.69 KB
/
DataCollectionRulesCreate.go
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
package armmonitor_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/monitor/armmonitor"
)
// x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2021-04-01/examples/DataCollectionRulesCreate.json
func ExampleDataCollectionRulesClient_Create() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
client := armmonitor.NewDataCollectionRulesClient("<subscription-id>", cred, nil)
res, err := client.Create(ctx,
"<resource-group-name>",
"<data-collection-rule-name>",
&armmonitor.DataCollectionRulesClientCreateOptions{Body: &armmonitor.DataCollectionRuleResource{
Location: to.StringPtr("<location>"),
Properties: &armmonitor.DataCollectionRuleResourceProperties{
DataFlows: []*armmonitor.DataFlow{
{
Destinations: []*string{
to.StringPtr("centralWorkspace")},
Streams: []*armmonitor.KnownDataFlowStreams{
armmonitor.KnownDataFlowStreams("Microsoft-Perf").ToPtr(),
armmonitor.KnownDataFlowStreams("Microsoft-Syslog").ToPtr(),
armmonitor.KnownDataFlowStreams("Microsoft-WindowsEvent").ToPtr()},
}},
DataSources: &armmonitor.DataCollectionRuleDataSources{
PerformanceCounters: []*armmonitor.PerfCounterDataSource{
{
Name: to.StringPtr("<name>"),
CounterSpecifiers: []*string{
to.StringPtr("\\Processor(_Total)\\% Processor Time"),
to.StringPtr("\\Memory\\Committed Bytes"),
to.StringPtr("\\LogicalDisk(_Total)\\Free Megabytes"),
to.StringPtr("\\PhysicalDisk(_Total)\\Avg. Disk Queue Length")},
SamplingFrequencyInSeconds: to.Int32Ptr(15),
Streams: []*armmonitor.KnownPerfCounterDataSourceStreams{
armmonitor.KnownPerfCounterDataSourceStreams("Microsoft-Perf").ToPtr()},
},
{
Name: to.StringPtr("<name>"),
CounterSpecifiers: []*string{
to.StringPtr("\\Process(_Total)\\Thread Count")},
SamplingFrequencyInSeconds: to.Int32Ptr(30),
Streams: []*armmonitor.KnownPerfCounterDataSourceStreams{
armmonitor.KnownPerfCounterDataSourceStreams("Microsoft-Perf").ToPtr()},
}},
Syslog: []*armmonitor.SyslogDataSource{
{
Name: to.StringPtr("<name>"),
FacilityNames: []*armmonitor.KnownSyslogDataSourceFacilityNames{
armmonitor.KnownSyslogDataSourceFacilityNames("cron").ToPtr()},
LogLevels: []*armmonitor.KnownSyslogDataSourceLogLevels{
armmonitor.KnownSyslogDataSourceLogLevels("Debug").ToPtr(),
armmonitor.KnownSyslogDataSourceLogLevels("Critical").ToPtr(),
armmonitor.KnownSyslogDataSourceLogLevels("Emergency").ToPtr()},
Streams: []*armmonitor.KnownSyslogDataSourceStreams{
armmonitor.KnownSyslogDataSourceStreams("Microsoft-Syslog").ToPtr()},
},
{
Name: to.StringPtr("<name>"),
FacilityNames: []*armmonitor.KnownSyslogDataSourceFacilityNames{
armmonitor.KnownSyslogDataSourceFacilityNames("syslog").ToPtr()},
LogLevels: []*armmonitor.KnownSyslogDataSourceLogLevels{
armmonitor.KnownSyslogDataSourceLogLevels("Alert").ToPtr(),
armmonitor.KnownSyslogDataSourceLogLevels("Critical").ToPtr(),
armmonitor.KnownSyslogDataSourceLogLevels("Emergency").ToPtr()},
Streams: []*armmonitor.KnownSyslogDataSourceStreams{
armmonitor.KnownSyslogDataSourceStreams("Microsoft-Syslog").ToPtr()},
}},
WindowsEventLogs: []*armmonitor.WindowsEventLogDataSource{
{
Name: to.StringPtr("<name>"),
Streams: []*armmonitor.KnownWindowsEventLogDataSourceStreams{
armmonitor.KnownWindowsEventLogDataSourceStreams("Microsoft-WindowsEvent").ToPtr()},
XPathQueries: []*string{
to.StringPtr("Security!")},
},
{
Name: to.StringPtr("<name>"),
Streams: []*armmonitor.KnownWindowsEventLogDataSourceStreams{
armmonitor.KnownWindowsEventLogDataSourceStreams("Microsoft-WindowsEvent").ToPtr()},
XPathQueries: []*string{
to.StringPtr("System![System[(Level = 1 or Level = 2 or Level = 3)]]"),
to.StringPtr("Application!*[System[(Level = 1 or Level = 2 or Level = 3)]]")},
}},
},
Destinations: &armmonitor.DataCollectionRuleDestinations{
LogAnalytics: []*armmonitor.LogAnalyticsDestination{
{
Name: to.StringPtr("<name>"),
WorkspaceResourceID: to.StringPtr("<workspace-resource-id>"),
}},
},
},
},
})
if err != nil {
log.Fatal(err)
}
log.Printf("Response result: %#v\n", res.DataCollectionRulesClientCreateResult)
}