Obtain the Access Key of the ByteHouse account number. For detailed steps, see 获取Access Key.
Select the appropriate SDK version below:
Programming language | Github address | Guidance document |
|---|---|---|
Python | ||
Java | ||
Go |
For specific request Body params, refer to the cloud monitor related articles: GetMetricData.
The following are some REQUIRED params:
Parameter name | Required | Remark |
|---|---|---|
ak/sk | Yes | The ak/sk of the current account number. For detailed steps, see 获取Access Key. |
region | Yes | For example: cn-beijing |
Namespace | Yes | Fixed as: VCM_ByteHouse |
StartTime | Yes | The start time of the time range to search, every sec timestamp, for example 1632904500. |
EndTime | Yes | The end time of the time range to search, every sec timestamp, for example 1632904801. |
Instances | Yes | Metric dimension information to search. For example, to search the Connection_Gateway_Connection_Count metric, the dimension needs to be configured as ResourceID. |
MetricName | Yes | The monitoring metrics name to search. |
SubNamespace | No | The dimension to which the metric belongs. |
Currently, you can view the total metrics available in ByteHouse cloud monitor at Monitoring metrics description.
warning
Each metric must pass ResourceID. In the current version, ResourceID equals envID. Just pass envID.
Using the Go SDK as an example, query the VirtualWarehouse_CPU_Usage_Percentage metric, with dimension filters set to ResourceID and VWID.
When using, please replace with the actual ResourceID and VWID. The method is as follows:
package main import ( "fmt" "github.com/volcengine/volcengine-go-sdk/service/volcobserve" "github.com/volcengine/volcengine-go-sdk/volcengine" "github.com/volcengine/volcengine-go-sdk/volcengine/session" ) func main() { // settings your ak ak := "xxx" // settings your sk sk := "xxx" // settings the region you want to access var region = "cn-beijing" //if use env Credentials //please //export VOLCSTACK_ACCESS_KEY=AK //export VOLCSTACK_SECRET_KEY=SK // and WithCredentials(credentials.NewEnvCredentials()) config := volcengine.NewConfig(). WithRegion(region). WithAkSk(ak, sk). // WithCredentials(credentials.NewEnvCredentials()). WithLogLevel(volcengine.LogDebugWithHTTPBody). WithDisableSSL(true) sess, _ := session.NewSession(config) svc := volcobserve.New(sess) in := &volcobserve.GetMetricDataInput{ StartTime: volcengine.Int64(1732848879), EndTime: volcengine.Int64(1732852479), Instances: []*volcobserve.InstanceForGetMetricDataInput{ { Dimensions: []*volcobserve.DimensionForGetMetricDataInput{ { Name: volcengine.String("ResourceID"), Value: volcengine.String("xxxxxxxxxx"), }, }, }, { Dimensions: []*volcobserve.DimensionForGetMetricDataInput{ { Name: volcengine.String("VWID"), Value: volcengine.String("vw-{vwID}-{vw_name}"), }, }, }, }, MetricName: volcengine.String("VirtualWarehouse_CPU_Usage_Percentage"), Namespace: volcengine.String("VCM_ByteHouse"), Period: volcengine.String("1m"), SubNamespace: volcengine.String(""), } resp, err := svc.GetMetricData(in) if err != nil { panic(err) } fmt.Printf("Response is %v", resp) }