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

Add logrotate config #6142

Merged
merged 1 commit into from
Sep 27, 2023
Merged

Add logrotate config #6142

merged 1 commit into from
Sep 27, 2023

Conversation

ldvc
Copy link
Contributor

@ldvc ldvc commented Sep 27, 2023

What this PR does

In case users decide to store Mimir's logs out of journald (e.g. /var/log/mimir.log), we want to be sure that Mimir's logs won't fill up the disk.

Which issue(s) this PR fixes or relates to

N/A

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

@CLAassistant
Copy link

CLAassistant commented Sep 27, 2023

CLA assistant check
All committers have signed the CLA.

CHANGELOG.md Outdated Show resolved Hide resolved
In case users decide to store Mimir's logs out of journald (e.g. `/var/log/mimir.log`) we want to be sure that Mimir's logs won't fill up the disk.

Tested on Debian 11, Centos 7 and AlmaLinux 8.

```
[root@centos7 ~]# logrotate --debug --verbose /etc/logrotate.d/mimir
reading config file /etc/logrotate.d/mimir
Allocating hash table for state file, size 15360 B

Handling 1 logs

rotating pattern: /var/log/mimir/mimir.log  after 1 days (7 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/mimir/mimir.log
```

```
[root@alma8 ~]# logrotate --debug --verbose /etc/logrotate.d/mimir
WARNING: logrotate in debug mode does nothing except printing debug messages!  Consider using verbose mode (-v) instead if this is not what you want.

reading config file /etc/logrotate.d/mimir
Reading state from file: /var/lib/logrotate/logrotate.status
Allocating hash table for state file, size 64 entries

Handling 1 logs

rotating pattern: /var/log/mimir/mimir.log  after 1 days (7 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/mimir/mimir.log
Creating new state
```

```
root@debian11:~# logrotate --debug --verbose /etc/logrotate.d/mimir
WARNING: logrotate in debug mode does nothing except printing debug messages!  Consider using verbose mode (-v) instead if this is not what you want.

reading config file /etc/logrotate.d/mimir
Reading state from file: /var/lib/logrotate/status
Allocating hash table for state file, size 64 entries
Creating new state
Creating new state
Creating new state
Creating new state
Creating new state
[...]

Handling 1 logs

rotating pattern: /var/log/mimir/mimir.log  after 1 days (7 rotations)
empty log files are not rotated, old logs are removed
considering log /var/log/mimir/mimir.log
Creating new state
```

Signed-off-by: Ludovic Terrier <5823358+ldvc@users.noreply.github.com>
@56quarters
Copy link
Contributor

I'm 👍 if the packaging folks are good with this but I'm a little confused. Mimir doesn't even support writing to log files (only stderr). These log files would be something else running Mimir and writing the log files (like Supervisord or something)?

@ldvc
Copy link
Contributor Author

ldvc commented Sep 27, 2023

I'm 👍 if the packaging folks are good with this but I'm a little confused. Mimir doesn't even support writing to log files (only stderr). These log files would be something else running Mimir and writing the log files (like Supervisord or something)?

By adding these two parameters in the systemd unit file, logs can be appended to a file:

StandardOutput=append:/var/log/mimir/mimir.log
StandardError=inherit

We would not like to make these parameters enabled by default as:

  • this is something usually enabled by the sysadmin,
  • we would not like to break customized logging on existing Mimir's installations.

As a side note, there is also a Puppet module in order to ease Mimir management.

@56quarters 56quarters merged commit fc68c93 into grafana:main Sep 27, 2023
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants