github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/dis/v2/monitors/GetPartitionMonitor.go (about)

     1  package monitors
     2  
     3  import (
     4  	golangsdk "github.com/opentelekomcloud/gophertelekomcloud"
     5  	"github.com/opentelekomcloud/gophertelekomcloud/internal/extract"
     6  )
     7  
     8  type GetPartitionMonitorOpts struct {
     9  	// Name of the stream to be queried.
    10  	// Maximum: 60
    11  	StreamName string
    12  	// Partition No.
    13  	// The value can be in either of the following formats:
    14  	//  - shardId-0000000000
    15  	//  - 0
    16  	// For example, if a stream has three partitions, the partition identifiers are 0, 1, and 2, or
    17  	// shardId-0000000000,
    18  	// shardId-0000000001,
    19  	// and shardId-0000000002,
    20  	// respectively.
    21  	PartitionId string
    22  	// Partition monitoring metric.
    23  	// (Either label or label_list must be specified.
    24  	// If both label_list and label are specified, label_list prevails.)
    25  	// - total_put_bytes_per_stream: total input traffic (byte)
    26  	// - total_get_bytes_per_stream: total output traffic (byte)
    27  	// - total_put_records_per_stream: total number of input records
    28  	// - total_get_records_per_stream: total number of output records
    29  	// Enumeration values:
    30  	//  total_put_bytes_per_stream
    31  	//  total_get_bytes_per_stream
    32  	//  total_put_records_per_stream
    33  	//  total_get_records_per_stream
    34  	Label string `q:"label,omitempty"`
    35  	// List of labels separated by commas (,) to query multiple labels in batches.
    36  	// (Either label or label_list must be specified.
    37  	// If both label_list and label exist, label_list prevails.)
    38  	LabelList string `q:"label_list,omitempty"`
    39  	// Monitoring start time, which is a 10-digit timestamp.
    40  	StartTime int64 `q:"start_time"`
    41  	// Monitoring end time, which is a 10-digit timestamp.
    42  	EndTime int64 `q:"end_time"`
    43  }
    44  
    45  func GetPartitionMonitor(client *golangsdk.ServiceClient, opts GetPartitionMonitorOpts) (*GetPartitionMonitorResponse, error) {
    46  	url, err := golangsdk.NewURLBuilder().WithEndpoints("streams", opts.StreamName, "partitions", opts.PartitionId, "metrics").WithQueryParams(&opts).Build()
    47  	if err != nil {
    48  		return nil, err
    49  	}
    50  
    51  	// GET /v2/{project_id}/streams/{stream_name}/partitions/{partition_id}/metrics
    52  	raw, err := client.Get(client.ServiceURL(url.String()), nil, nil)
    53  	if err != nil {
    54  		return nil, err
    55  	}
    56  
    57  	var res GetPartitionMonitorResponse
    58  	err = extract.Into(raw.Body, &res)
    59  	return &res, err
    60  }
    61  
    62  type GetPartitionMonitorResponse struct {
    63  	// Data object.
    64  	Metrics Metrics `json:"metrics,omitempty"`
    65  }