You need to enable JavaScript to run this app.
ByteHouse Cloud Data Warehouse Version

ByteHouse Cloud Data Warehouse Version

Copy page
Download PDF
Alarm
Query ByteHouse monitoring data using SDK
Copy page
Download PDF
Query ByteHouse monitoring data using SDK

prerequisites

Obtain the Access Key of the ByteHouse account number. For detailed steps, see 获取Access Key.

Download/install SDK

Select the appropriate SDK version below:

Programming language

Github address

Guidance document

Python

volcengine-python-sdk

Python example

Java

volcengine-Java-sdk

Java example

Go

volcengine-go-sdk

Go example

parameter description

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.
EndTime > StartTime。
EndTime cannot input future time.
EndTime < product allowed search days + StartTime.

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.
When there are multiple instances, the logical relationship between instance and instance is or.
If the instance param is not passed, it will return all monitoring data for all instances in the region. Large data volume may cause max-select-point limit exceeded, affecting business. Please operate with caution.

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.

Example

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:

  • ResourceID: That is, envID. You can log in to the ByteHouse cloud data warehouse console, click the top Tenant management, and in the Basic information tab under Current environment, view and copy the current environment name.
    Image
  • VWID: That is, virtual warehouse group ID. You can log in to the ByteHouse console, click the top virtual warehouse, and in the virtual warehouse list, view and copy the required virtual warehouse group ID.
    Image
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)
}
Last updated: 2026.03.31 16:25:02