Documentation
¶
Index ¶
- Constants
- type API
- type DBClient
- func (c *DBClient) CreateIndices(ctx context.Context) error
- func (c *DBClient) CreateParentIndices(ctx context.Context, optses []indexOpts) error
- func (c *DBClient) CreatePartitionIndices(ctx context.Context, optses []indexOpts, partition string) (indexed bool, err error)
- func (c *DBClient) InitDBTables(ctx context.Context) error
- func (c *DBClient) InsertEvent(ctx context.Context, eventBytes []byte) (err error)
- func (c *DBClient) Search(ctx context.Context, s *SearchQuery, w io.Writer) error
- type Entry
- type Event
- type LogEventRow
- type LogSearch
- type QTemplate
- type ReqInfoRow
- type SearchQuery
- type Table
Constants ¶
const ( // QueryAuthTokenEnv environment variable QueryAuthTokenEnv = "MINIO_LOG_QUERY_AUTH_TOKEN" // PgConnStrEnv environment variable PgConnStrEnv = "LOGSEARCH_PG_CONN_STR" // AuditAuthTokenEnv environment variable AuditAuthTokenEnv = "LOGSEARCH_AUDIT_AUTH_TOKEN" // DiskCapacityEnv environment variable DiskCapacityEnv = "LOGSEARCH_DISK_CAPACITY_GB" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API struct { Name string `json:"name,omitempty"` AccessKey string `json:"accessKey,omitempty"` Bucket string `json:"bucket,omitempty"` Object string `json:"object,omitempty"` Status string `json:"status,omitempty"` StatusCode int `json:"statusCode,omitempty"` TimeToFirstByte *time.Duration `json:"timeToFirstByte,omitempty"` TimeToResponse time.Duration `json:"timeToResponse,omitempty"` }
API is struct with same info an Entry.API, but with more strong types.
type DBClient ¶
DBClient is a client object that makes requests to the DB.
func NewDBClient ¶
NewDBClient creates a new DBClient.
func (*DBClient) CreateIndices ¶
CreateIndices creates table indexes for audit_log_events and request_info tables. See auditLogIndices, reqInfoIndices functions for actual indices details.
func (*DBClient) CreateParentIndices ¶
CreateParentIndices creates all indices specified by optses on the parent table.
func (*DBClient) CreatePartitionIndices ¶
func (c *DBClient) CreatePartitionIndices(ctx context.Context, optses []indexOpts, partition string) (indexed bool, err error)
CreatePartitionIndices creates all indices described by optses on partition. It returns true if a new index was created on this partition. Note: this function ignores the index already exists error.
func (*DBClient) InitDBTables ¶
InitDBTables Creates tables in the DB.
func (*DBClient) InsertEvent ¶
InsertEvent inserts audit event in the DB.
type Entry ¶
type Entry struct { Version string `json:"version"` DeploymentID string `json:"deploymentid,omitempty"` Time string `json:"time"` Trigger string `json:"trigger"` API struct { Name string `json:"name,omitempty"` AccessKey string `json:"accessKey,omitempty"` Bucket string `json:"bucket,omitempty"` Object string `json:"object,omitempty"` Status string `json:"status,omitempty"` StatusCode int `json:"statusCode,omitempty"` TimeToFirstByte string `json:"timeToFirstByte,omitempty"` TimeToResponse string `json:"timeToResponse,omitempty"` } `json:"api"` RemoteHost string `json:"remotehost,omitempty"` RequestID string `json:"requestID,omitempty"` UserAgent string `json:"userAgent,omitempty"` ReqClaims map[string]interface{} `json:"requestClaims,omitempty"` ReqQuery map[string]string `json:"requestQuery,omitempty"` ReqHeader map[string]string `json:"requestHeader,omitempty"` RespHeader map[string]string `json:"responseHeader,omitempty"` Tags map[string]interface{} `json:"tags,omitempty"` }
Entry - audit entry logs.
type Event ¶
type Event struct { Version string `json:"version"` DeploymentID string `json:"deploymentid,omitempty"` Time time.Time `json:"time"` API API `json:"api"` RemoteHost string `json:"remotehost,omitempty"` RequestID string `json:"requestID,omitempty"` UserAgent string `json:"userAgent,omitempty"` ReqClaims map[string]interface{} `json:"requestClaims,omitempty"` ReqQuery map[string]string `json:"requestQuery,omitempty"` ReqHeader map[string]string `json:"requestHeader,omitempty"` RespHeader map[string]string `json:"responseHeader,omitempty"` }
Event is the same as Entry but with more typed values.
func EventFromEntry ¶
EventFromEntry performs a type conversion
type LogEventRow ¶
type LogEventRow struct { EventTime time.Time `json:"event_time"` Log map[string]interface{} `json:"log"` }
LogEventRow holds a raw log record
type LogSearch ¶
type LogSearch struct { // Configuration PGConnStr string AuditAuthToken, QueryAuthToken string DiskCapacityGBs int // Runtime DBClient *DBClient *http.ServeMux }
LogSearch represents the Log Search API server
func NewLogSearch ¶
func NewLogSearch(pgConnStr, auditAuthToken string, queryAuthToken string, diskCapacity int) (ls *LogSearch, err error)
NewLogSearch creates a LogSearch
func (*LogSearch) StartServer ¶
func (ls *LogSearch) StartServer()
StartServer starts the webserver.
type QTemplate ¶
type QTemplate string
QTemplate is used to represent queries that involve string substitution as well as SQL positional argument substitution.
type ReqInfoRow ¶
type ReqInfoRow struct { Time time.Time `json:"time"` APIName string `json:"api_name"` AccessKey string `json:"access_key"` Bucket string `json:"bucket"` Object string `json:"object"` TimeToResponseNs uint64 `json:"time_to_response_ns"` RemoteHost string `json:"remote_host"` RequestID string `json:"request_id"` UserAgent string `json:"user_agent"` ResponseStatus string `json:"response_status"` ResponseStatusCode int `json:"response_status_code"` RequestContentLength *uint64 `json:"request_content_length"` ResponseContentLength *uint64 `json:"response_content_length"` }
ReqInfoRow holds a structured log record