Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement audit backend for TimescaleDB. #151

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open

Conversation

Gerrit91
Copy link
Contributor

No description provided.

go.mod Outdated Show resolved Hide resolved
@Gerrit91 Gerrit91 marked this pull request as ready for review January 24, 2025 12:22
@Gerrit91 Gerrit91 requested a review from a team as a code owner January 24, 2025 12:22
auditing/timescaledb.go Outdated Show resolved Hide resolved
auditing/timescaledb.go Outdated Show resolved Hide resolved
Comment on lines +256 to +295
if err := addFilter("body", filter.Body, phrase); err != nil {
return nil, err
}
if err := addFilter("component", filter.Component, equals); err != nil {
return nil, err
}
if err := addFilter("detail", filter.Detail, equals); err != nil {
return nil, err
}
if err := addFilter("error", filter.Error, equals); err != nil {
return nil, err
}
if err := addFilter("forwardedfor", filter.ForwardedFor, equals); err != nil {
return nil, err
}
if err := addFilter("path", filter.Path, equals); err != nil {
return nil, err
}
if err := addFilter("phase", filter.Phase, equals); err != nil {
return nil, err
}
if err := addFilter("remoteaddr", filter.RemoteAddr, equals); err != nil {
return nil, err
}
if err := addFilter("rqid", filter.RequestId, equals); err != nil {
return nil, err
}
if err := addFilter("statuscode", filter.StatusCode, equals); err != nil {
return nil, err
}
if err := addFilter("tenant", filter.Tenant, equals); err != nil {
return nil, err
}
if err := addFilter("type", filter.Type, equals); err != nil {
return nil, err
}
if err := addFilter("user", filter.User, equals); err != nil {
return nil, err
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this must all match to the Entry json annotations, easy to make mistakes here or miss some of them. There might be a smarter way, but unsure.

Comment on lines +301 to +303
values["from"] = filter.From.UTC()
where = append(where, "timestamp >= :from")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be much faster if the where clause against the timestamp is the very first one to reduce the results as early as possible.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also timestamp should be indexed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants