Skip to content

Commit

Permalink
Merge pull request #188 from linrunqi08/feature/taiye/fix_machine_gro…
Browse files Browse the repository at this point in the history
…up_sample

fix machine group sample
  • Loading branch information
shabicheng authored Nov 30, 2022
2 parents c2336b8 + 574478a commit bd4d56f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
27 changes: 23 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,13 @@ totalLogCount := 0
参考 [machine_group_sample.go](https://github.com/aliyun/aliyun-log-go-sdk/blob/master/example/machine_group/machine_group_sample.go)
机器组分为IP型机器组和标识型机器组,二选一
创建标识型机器组
```go
attribute := sls.MachinGroupAttribute{
ExternalName: "",
TopicName: "",
}
machineList := []string{"mac-user-defined-id-value"}
machineList := []string{"mac-user-defined-id-value_XX"}
var machineGroup = &sls.MachineGroup{
Name: groupName,
MachineIDType: "userdefined",
Expand All @@ -210,6 +211,24 @@ if err != nil {
}
```
创建IP型机器组
```go
attribute := sls.MachinGroupAttribute{
}
machineList := []string{"192.168.XX.XX"}
var machineGroup = &sls.MachineGroup{
Name: groupName,
MachineIDType: "ip",
MachineIDList: machineList,
Attribute: attribute,
}
err = util.Client.CreateMachineGroup(ProjectName, machineGroup)
if err != nil {
fmt.Println(err)
}
```
8. **创建logtail 采集配置**
logtail 采集配置,目前通过sdk 支持创建下列几种模式的采集配置,分别为 [完整正则](https://github.com/aliyun/aliyun-log-go-sdk/blob/master/example/config/log_config_common_regex.go),[分隔符模式](https://github.com/aliyun/aliyun-log-go-sdk/blob/master/example/config/log_config_delimiter.go),[json模式](https://github.com/aliyun/aliyun-log-go-sdk/blob/master/example/config/log_config_json.go) ,[插件模式](https://github.com/aliyun/aliyun-log-go-sdk/blob/master/example/config/log_config_plugin.go),这里展示的完整正则模式的创建。
Expand Down Expand Up @@ -259,4 +278,4 @@ if err != nil {
```
protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/gogo/protobuf/protobuf --gofast_out=. log.proto
```
```
5 changes: 1 addition & 4 deletions example/machine_group/machine_group_sample.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,7 @@ func deleteMachineGroup(groupName string) (err error) {
}

func createMachineGroup(groupName string) (err error) {
attribute := sls.MachinGroupAttribute{
ExternalName: "",
TopicName: "",
}
attribute := sls.MachinGroupAttribute{}
machineList := []string{"mac-user-defined-id-value"}
var machineGroup = &sls.MachineGroup{
Name: groupName,
Expand Down

0 comments on commit bd4d56f

Please sign in to comment.