github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/rds/v3/logs/ListSlowLog.go (about) 1 package logs 2 3 import ( 4 "github.com/opentelekomcloud/gophertelekomcloud" 5 "github.com/opentelekomcloud/gophertelekomcloud/internal/extract" 6 "github.com/opentelekomcloud/gophertelekomcloud/openstack" 7 ) 8 9 type DbSlowLogOpts struct { 10 // Specifies the ID of the queried DB instance. 11 InstanceId string `json:"-"` 12 // Specifies the start date in the "yyyy-mm-ddThh:mm:ssZ" format. 13 // T is the separator between the calendar and the hourly notation of time. Z indicates the time zone offset. 14 StartDate string `q:"start_date" required:"true"` 15 // Specifies the end time in the "yyyy-mm-ddThh:mm:ssZ" format. 16 // T is the separator between the calendar and the hourly notation of time. Z indicates the time zone offset. You can only query slow logs generated within a month. 17 EndDate string `q:"end_date" required:"true"` 18 // Specifies the page offset, such as 1, 2, 3, or 4. The parameter value is 1 by default if it is not specified. 19 Offset string `q:"offset"` 20 // Specifies the number of records on a page. Its value range is from 1 to 100. The parameter value is 10 by default if it is not specified. 21 Limit string `q:"limit"` 22 // Specifies the statement type. If it is left blank, all statement types are queried. Valid value: 23 // 24 // INSERT 25 // UPDATE 26 // SELECT 27 // DELETE 28 // CREATE 29 Level string `q:"level"` 30 } 31 32 func ListSlowLog(client *golangsdk.ServiceClient, opts DbSlowLogOpts) (*SlowLogResp, error) { 33 query, err := golangsdk.BuildQueryString(opts) 34 if err != nil { 35 return nil, err 36 } 37 38 // GET https://{Endpoint}/v3/{project_id}/instances/{instance_id}/slowlog 39 url := client.ServiceURL("instances", opts.InstanceId, "slowlog") + query.String() 40 raw, err := client.Get(url, nil, openstack.StdRequestOpts()) 41 if err != nil { 42 return nil, err 43 } 44 45 var res SlowLogResp 46 err = extract.Into(raw.Body, &res) 47 return &res, err 48 } 49 50 type SlowLogResp struct { 51 // Indicates detailed information. 52 Slowloglist []Slowloglist `json:"slow_log_list"` 53 // Indicates the total number of records. 54 TotalRecord int `json:"total_record"` 55 } 56 57 type Slowloglist struct { 58 // Indicates the number of executions. 59 Count string `json:"count"` 60 // Indicates the execution time. 61 Time string `json:"time"` 62 // Indicates the lock wait time. 63 // This parameter is not present in the response for PostgreSQL DB engine. 64 LockTime string `json:"lock_time"` 65 // Indicates the number of sent rows. 66 // This parameter is not present in the response for PostgreSQL DB engine. 67 RowsSent string `json:"rows_sent"` 68 // Indicates the number of scanned rows. 69 // This parameter is not present in the response for PostgreSQL DB engine. 70 RowsExamined string `json:"rows_examined"` 71 // Indicates the database which the slow log belongs to. 72 Database string `json:"database"` 73 // Indicates the account. 74 Users string `json:"users"` 75 // Indicates the execution syntax. 76 QuerySample string `json:"query_sample"` 77 // Indicates the statement type. 78 Type string `json:"type"` 79 // Indicates the time in the UTC format. 80 StartTime string `json:"start_time"` 81 // Indicates the IP address. 82 ClientIp string `json:"client_ip"` 83 }