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

chore: add example for audit logging to file in docker #1496

Merged
merged 8 commits into from
Apr 18, 2023
Merged

Conversation

yquansah
Copy link
Contributor

Add example for running a Flipt in a docker container with audit logging enabled.

Completes FLI-306

@yquansah yquansah requested a review from a team as a code owner April 13, 2023 17:48
image: flipt/flipt:latest
command: ["./flipt", "--force-migrate"]
ports:
- "8080:8080"
Copy link
Collaborator

Choose a reason for hiding this comment

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

what if we mounted a local file for the audit log as a volume, then the user could also tail that file in another terminal to see it being written to? we could include that in the instructions?

like:

volumes:
      - "/tmp/flipt/audit.log:/var/opt/flipt/audit.log"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@markphelps I like the idea. I think that would work best 👍

Copy link
Collaborator

Choose a reason for hiding this comment

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

My bad, this should prob be /var/log/flipt/audit.log instead of /var/opt. I copied and pasted from a previous example 😞 sorry

## Running the Example

1. Run `docker-compose up` from this directory
1. Open the Flipt UI (default: [http://localhost:8080](http://localhost:8080))
Copy link
Collaborator

Choose a reason for hiding this comment

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

We could add:

1. Create some sample data: Flags/Segments/etc.
1. In a new terminal, run `tail -f /tmp/flipt/audit.log` to see events written to the log

See my comment below about mounting the file to a volume in the container

Copy link
Collaborator

Choose a reason for hiding this comment

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

could we make it audit.log or similar so it ends in the .log ext?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@markphelps Done. made that change.

Copy link
Collaborator

@markphelps markphelps left a comment

Choose a reason for hiding this comment

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

one minor request

## Running the Example

1. Run `docker-compose up` from this directory
1. Open the Flipt UI (default: [http://localhost:8080](http://localhost:8080))
Copy link
Collaborator

Choose a reason for hiding this comment

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

could we make it audit.log or similar so it ends in the .log ext?

Copy link
Collaborator

@markphelps markphelps left a comment

Choose a reason for hiding this comment

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

one suggestion on changing the path because I copy / pasted incorrectly from a previous example.. but other than that .. ship it!!

image: flipt/flipt:latest
command: ["./flipt", "--force-migrate"]
ports:
- "8080:8080"
Copy link
Collaborator

Choose a reason for hiding this comment

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

My bad, this should prob be /var/log/flipt/audit.log instead of /var/opt. I copied and pasted from a previous example 😞 sorry

environment:
- FLIPT_LOG_LEVEL=debug
- FLIPT_AUDIT_SINKS_LOG_ENABLED=true
- FLIPT_AUDIT_SINKS_LOG_FILE=/var/opt/flipt/audit.log
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
- FLIPT_AUDIT_SINKS_LOG_FILE=/var/opt/flipt/audit.log
- FLIPT_AUDIT_SINKS_LOG_FILE=/var/log/flipt/audit.log

sorry again

Copy link
Member

@GeorgeMac GeorgeMac Apr 14, 2023

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@markphelps @GeorgeMac Yeah I used the location /var/log/audit.log to avoid modifying the Dockerfile. If I should actually create that flipt directory under /var/log, then I am down to do that too.

@yquansah yquansah requested a review from GeorgeMac April 14, 2023 14:22
@yquansah yquansah enabled auto-merge (squash) April 14, 2023 16:43
@yquansah yquansah disabled auto-merge April 14, 2023 16:46

```bash
FLIPT_AUDIT_SINKS_LOG_ENABLED=true
FLIPT_AUDIT_SINKS_LOG_FILE=/var/opt/flipt/audit.log
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
FLIPT_AUDIT_SINKS_LOG_FILE=/var/opt/flipt/audit.log
FLIPT_AUDIT_SINKS_LOG_FILE=/var/log/flipt/audit.log

mkdir -p /tmp/flipt && touch /tmp/flipt/audit.log
```

and `tail` the logs as you are making API request to the Flipt server when the container is running.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
and `tail` the logs as you are making API request to the Flipt server when the container is running.
and `tail` the logs as you are making API requests to the Flipt server when the container is running.

FLIPT_AUDIT_SINKS_LOG_FILE=/var/opt/flipt/audit.log
```

The auditable events currently are CRUD (except for read) operations on `flags`, `variants`, `segments`, `constraints`, `rules`, `distributions`, and `namespaces`. If you do any of these operations through the API, it should emit an audit event log to the specified location.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
The auditable events currently are CRUD (except for read) operations on `flags`, `variants`, `segments`, `constraints`, `rules`, `distributions`, and `namespaces`. If you do any of these operations through the API, it should emit an audit event log to the specified location.
The auditable events currently are CRUD (except for read) operations on `flags`, `variants`, `segments`, `constraints`, `rules`, `distributions`, and `namespaces`. If you perform any of these operations through the API, it should emit an audit event log to the specified location.


The auditable events currently are CRUD (except for read) operations on `flags`, `variants`, `segments`, `constraints`, `rules`, `distributions`, and `namespaces`. If you do any of these operations through the API, it should emit an audit event log to the specified location.

Since docker containers are ephemeral and data within the container is lost when the container exits. In this example we mount a local file on the host to the audit event log location in the container as a volume. You would have to create the file [first](https://github.com/moby/moby/issues/21612#issuecomment-202984678) before starting the container:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
Since docker containers are ephemeral and data within the container is lost when the container exits. In this example we mount a local file on the host to the audit event log location in the container as a volume. You would have to create the file [first](https://github.com/moby/moby/issues/21612#issuecomment-202984678) before starting the container:
Since docker containers are ephemeral and data within the container is lost when the container exits, we mount a local file on the host to the audit event log location in the container as a volume. You would have to create the file [first](https://github.com/moby/moby/issues/21612#issuecomment-202984678) before starting the container:

@yquansah yquansah merged commit 0f34a83 into main Apr 18, 2023
@yquansah yquansah deleted the yq-add-example branch April 18, 2023 08:59
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.

3 participants