百度智能云

All Product Document

          Log Service

          FastQuery Operations

          Create fast query

          To create the fast query instance name, the following guidelines must be met:

          • Fast query names must be unique per account and per region.
          • The fast query name shall not be longer than 128 characters
          • Only these characters are permitted for fast query name: a-z, A-Z, 0-9, '_', '-', '.'"

          Use the following code to create a fast query.

          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.')
          }

          Prompt:

          • Detailed parameter configuration and restrictions may refer to BLS API document Create Fast Query

          Obtain the specified fast query

          With following codes, get the fast query details of the specified name

          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)
          }

          Prompt:

          • Detailed parameter configuration and restrictions may refer to BLS API document Describe Fast Query

          Update the specified fast query

          With following codes, update the fast query instance information of the specified name

          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.")
          }

          Prompt:

          • Detailed parameter configuration and restrictions may refer to BLS API document Update Fast Query

          Get the fast query list

          Use the following code to retrieve the list of fast queries saved by the current user.

          //Optional parameter list
          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)
          }

          Prompt:

          • Detailed parameter configuration and restrictions may refer to BLS API document List Fast Query

          Delete the specified fast query

          Use the following code to delete the fast query example with the specified name.

          deleteFastQueryRequest := DeleteFastQueryRequest{
              FastQueryName: "test",
          }
          err := BLS_CLIENT.DeleteFastQueryV2(deleteFastQueryRequest)
          if err != nil {
            fmt.Println("Delete fastQuery failed: ", err)
          } else {
            fmt.Println("Delete fastQuery success.")
          }

          Prompt:

          • Detailed parameter configuration and restrictions may refer to BLS API document Delete Fast Query
          Previous
          Download Task Operations
          Next
          Index Operations