Skip to content

Commit d38b04f

Browse files
author
Praveenrajmani
committed
redefine API event
1 parent 47f9620 commit d38b04f

File tree

3 files changed

+35
-22
lines changed

3 files changed

+35
-22
lines changed

audit-event.go renamed to api-events.go

+7-11
Original file line numberDiff line numberDiff line change
@@ -29,29 +29,27 @@ import (
2929
"github.com/minio/madmin-go/v3/event"
3030
)
3131

32+
// GetAPIEvents fetches the persisted API events from MinIO
3233
func (adm AdminClient) GetAPIEvents(ctx context.Context, node string, api string) <-chan event.API {
33-
logCh := make(chan event.API)
34+
eventCh := make(chan event.API)
3435

3536
// Only success, start a routine to start reading line by line.
36-
go func(logCh chan<- event.API) {
37-
defer close(logCh)
37+
go func(eventCh chan<- event.API) {
38+
defer close(eventCh)
3839
urlValues := make(url.Values)
3940
urlValues.Set("node", node)
4041
urlValues.Set("api", api)
41-
// for {
4242
reqData := requestData{
4343
relPath: adminAPIPrefix + "/events/api",
4444
queryValues: urlValues,
4545
}
46-
// Execute GET to call log handler
4746
resp, err := adm.executeMethod(ctx, http.MethodGet, reqData)
4847
if err != nil {
4948
closeResponse(resp)
5049
return
5150
}
5251

5352
if resp.StatusCode != http.StatusOK {
54-
// logCh <- LogInfo{Err: httpRespToErrorResponse(resp)}
5553
return
5654
}
5755
dec := json.NewDecoder(resp.Body)
@@ -64,13 +62,11 @@ func (adm AdminClient) GetAPIEvents(ctx context.Context, node string, api string
6462
select {
6563
case <-ctx.Done():
6664
return
67-
case logCh <- info:
65+
case eventCh <- info:
6866
}
6967
}
70-
// }
7168

72-
}(logCh)
69+
}(eventCh)
7370

74-
// Returns the log info channel, for caller to start reading from.
75-
return logCh
71+
return eventCh
7672
}

event/api.go

+28-11
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,36 @@ import "time"
2222
// API represents the api event
2323
type API struct {
2424
Version string `json:"version"`
25+
Type string `json:"type,omitempty"`
2526
DeploymentID string `json:"deploymentid,omitempty"`
2627
SiteName string `json:"siteName,omitempty"`
2728
Time time.Time `json:"time"`
28-
Event string `json:"event"`
29-
30-
Type string `json:"type,omitempty"`
31-
32-
API struct {
33-
Name string `json:"name,omitempty"`
34-
Bucket string `json:"bucket,omitempty"`
35-
Object string `json:"object,omitempty"`
36-
StatusCode int `json:"statusCode,omitempty"`
37-
} `json:"api"`
29+
Name string `json:"name,omitempty"`
30+
Bucket string `json:"bucket,omitempty"`
31+
Object string `json:"object,omitempty"`
32+
VersionID string `json:"versionId,omitempty"`
33+
External bool `json:"external,omitempty"`
34+
CallInfo *CallInfo `json:"callInfo,omitempty"`
35+
}
3836

39-
Error string `json:"error,omitempty"`
37+
// CallInfo represents the info for the external call
38+
type CallInfo struct {
39+
StatusCode int `json:"statusCode,omitempty"`
40+
InputBytes int64 `json:"rx"`
41+
OutputBytes int64 `json:"tx"`
42+
HeaderBytes int64 `json:"txHeaders,omitempty"`
43+
TimeToFirstByte string `json:"timeToFirstByte,omitempty"`
44+
TimeToResponse string `json:"timeToResponse,omitempty"`
45+
RemoteHost string `json:"remotehost,omitempty"`
46+
RequestID string `json:"requestID,omitempty"`
47+
UserAgent string `json:"userAgent,omitempty"`
48+
ReqPath string `json:"requestPath,omitempty"`
49+
ReqHost string `json:"requestHost,omitempty"`
50+
ReqNode string `json:"requestNode,omitempty"`
51+
ReqClaims map[string]interface{} `json:"requestClaims,omitempty"`
52+
ReqQuery map[string]string `json:"requestQuery,omitempty"`
53+
ReqHeader map[string]string `json:"requestHeader,omitempty"`
54+
RespHeader map[string]string `json:"responseHeader,omitempty"`
55+
AccessKey string `json:"accessKey,omitempty"`
56+
ParentUser string `json:"parentUser,omitempty"`
4057
}
File renamed without changes.

0 commit comments

Comments
 (0)