FastQuery操作
更新时间:2024-09-11
创建FastQuery
创建快速查询的实例名称必须遵循以下准则:
- 每个账户每个区域快速查询名称不能相同
- 快速查询名称长度不能超过128个字符
- 快速查询名称包含的字符仅限于:
a-z, A-Z, 0-9, '_', '-', '.'
通过以下代码,可以创建一个快速查询。
createFastQueryRequest := CreateFastQueryRequest{
FastQueryName: "test",
Query: "match *",
Description: "",
Project: "defautl",
LogStoreName: "test",
StartDateTime: time.Now().UTC().Format("2006-01-02T15:04:05Z"),
EndDateTime: time.Now().UTC().Format("2006-01-02T15:04:05Z"),
}
err := BLS_CLIENT.CreateLogStoreV2(createLogStoreRequest)
if err != nil {
fmt.Println("Create fastQuery failed: ", err)
} else {
fmt.Println('Create fastQuery success.')
}
提示:
- 详细的参数配置及限制条件,可以参考BLS API 文档CreateFastQuery
获取指定FastQuery
通过以下代码,获取指定名称的快速查询的详细信息
describeFastQueryRequest := DescribeFastQueryRequest{
FastQueryName: "test",
}
res, err := BLS_CLIENT.DescribeFastQueryV2(describeFastQueryRequest)
if err != nil {
fmt.Println("Get fastQuery failed: ", err)
} else {
fmt.Println("Fastquery info: ", res)
}
提示:
- 详细的参数配置及限制条件,可以参考BLS API 文档DescribeFastQuery
更新指定FastQuery
通过以下代码,更新指定名称的快速查询实例信息
updateFastQueryRequest := UpdateFastQueryRequest{
FastQueryName: "test",
Query: "select * limit 10",
Description: "test",
Project: "default",
LogStoreName: "test",
LogStreamName: "test",
StartDateTime: time.Now().UTC().Format("2006-01-02T15:04:05Z"),
EndDateTime: time.Now().UTC().Format("2006-01-02T15:04:05Z"),
}
err := BLS_CLIENT.UpdateFastQueryV2(updateFastQueryRequest)
if err != nil {
fmt.Println("Update fastQuery failed: ", err)
} else {
fmt.Println("Update fastQuery success.")
}
提示:
- 详细的参数配置及限制条件,可以参考BLS API 文档UpdateFastQuery
获取FastQuery列表
通过以下代码,获取当前用户保存的快速查询列表。
// 可选参数列表
listFastQueryRequest := ListFastQueryRequest{
Project: "default",
NamePattern: "m",
Order: "desc",
OrderBy: "",
PageNo: 1,
PageSize: 20,
}
res, err := BLS_CLIENT.ListFastQueryV2(listFastQueryRequest)
if err != nil {
fmt.Println("List fastQuery failed: ", err)
} else {
fmt.Println("FastQuery list: ", res)
}
提示:
- 详细的参数配置及限制条件,可以参考BLS API 文档ListFastQuery
删除指定FastQuery
通过以下代码,删除指定名称的快速查询示例。
deleteFastQueryRequest := DeleteFastQueryRequest{
FastQueryName: "test",
}
err := BLS_CLIENT.DeleteFastQueryV2(deleteFastQueryRequest)
if err != nil {
fmt.Println("Delete fastQuery failed: ", err)
} else {
fmt.Println("Delete fastQuery success.")
}
提示:
- 详细的参数配置及限制条件,可以参考BLS API 文档DeleteFastQuery