github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/ces/v1/metricdata/show_event_data.go (about)

     1  package metricdata
     2  
     3  import (
     4  	golangsdk "github.com/opentelekomcloud/gophertelekomcloud"
     5  	"github.com/opentelekomcloud/gophertelekomcloud/internal/extract"
     6  )
     7  
     8  type ShowEventDataOpts struct {
     9  	// Query the namespace of a service.
    10  	Namespace string `q:"namespace"`
    11  	// Specifies the dimension. For example, the ECS dimension is instance_id.
    12  	// For details about the dimensions corresponding to the monitoring metrics of each service,
    13  	// see the monitoring metrics description of the corresponding service in Services Interconnected with Cloud Eye.
    14  	//
    15  	// Specifies the dimension. A maximum of three dimensions are supported,
    16  	// and the dimensions are numbered from 0 in dim.{i}=key,value format.
    17  	// The key cannot exceed 32 characters and the value cannot exceed 256 characters.
    18  	Dim0 string `q:"dim.0"`
    19  	Dim1 string `q:"dim.1"`
    20  	Dim2 string `q:"dim.2"`
    21  	// Specifies the event type.
    22  	Type string `q:"type"`
    23  	// Specifies the start time of the query.
    24  	From string `q:"from"`
    25  	// Specifies the end time of the query.
    26  	To string `q:"to"`
    27  }
    28  
    29  func ListEventData(client *golangsdk.ServiceClient, opts ShowEventDataOpts) ([]EventDataInfo, error) {
    30  	url, err := golangsdk.NewURLBuilder().WithEndpoints("event-data").WithQueryParams(&opts).Build()
    31  	if err != nil {
    32  		return nil, err
    33  	}
    34  
    35  	// GET /V1.0/{project_id}/event-data
    36  	raw, err := client.Get(client.ServiceURL(url.String()), nil, nil)
    37  	if err != nil {
    38  		return nil, err
    39  	}
    40  
    41  	var res []EventDataInfo
    42  	err = extract.IntoSlicePtr(raw.Body, &res, "datapoints")
    43  
    44  	return res, err
    45  }
    46  
    47  type EventDataInfo struct {
    48  	// Specifies the event type, for example, instance_host_info.
    49  	Type string `json:"type"`
    50  	// Specifies when the event is reported. It is a UNIX timestamp and the unit is ms.
    51  	Timestamp int64 `json:"timestamp"`
    52  	// Specifies the host configuration information.
    53  	Value string `json:"value"`
    54  }