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

Allow for logfile naming like in Nomad #15709

Closed
Esity opened this issue Dec 7, 2022 · 7 comments · Fixed by #18617
Closed

Allow for logfile naming like in Nomad #15709

Esity opened this issue Dec 7, 2022 · 7 comments · Fixed by #18617
Labels
theme/logging Relating to logs and error messages

Comments

@Esity
Copy link

Esity commented Dec 7, 2022

Feature Description

Currently consul logs files like this consul-{timestamp}.log
This is a pain to figure out the most recent log file. Sure we collect files and ship them out but sometimes it's useful to look inside /var/log

Nomad Example

ls -alh /var/log/nomad/
-rw-r-----.  1 root  root   51K Dec  6 01:50 nomad-1670313323123267918.log
-rw-r-----.  1 root  root   12K Dec  7 01:50 nomad-1670399732186160816.log
-rw-r-----.  1 root  root   16K Dec  7 09:55 nomad.log

But consul looks like this

ls -alh /var/log/consul/
drwxr-xr-x.  2 consul consul 4.0K Dec  7 08:34 .
drwxr-xr-x. 24 root   root   8.0K Dec  7 08:34 ..
-rw-r-----.  1 consul consul  39K Dec  1 11:35 consul-1669914326514455232.log
-rw-r-----.  1 consul consul 230K Dec  2 11:35 consul-1669916117380991503.log

Nomad Config Code
https://github.com/hashicorp/nomad/blob/1c9b4e398dd2b954dc0414b7c1568f04a3143355/command/agent/config.go#L66
https://github.com/hashicorp/nomad/blob/1c9b4e398dd2b954dc0414b7c1568f04a3143355/command/agent/config.go#L1326-L1328

Consul Config Code

LogFile *string `mapstructure:"log_file" json:"log_file,omitempty"`

Use Case(s)

The use here is to make this easier to tail the most recent log file

@Esity
Copy link
Author

Esity commented Dec 7, 2022

CC @wjpatton

@jkirschner-hashicorp
Copy link
Contributor

Linking to a related issue: #10976

@jkirschner-hashicorp jkirschner-hashicorp added the theme/logging Relating to logs and error messages label Dec 21, 2022
@Globidev
Copy link

It seems to me that without that feature, one cannot properly integrate datadog log collection.

The link on their docs shows that the datadog agent configuration requires specifying a file path: https://docs.datadoghq.com/integrations/consul/?tab=host#log-collection

With the current naming scheme, I fail to see how we can always point to an up to date source of logs

@david-yu
Copy link
Contributor

@Esity Just to clarify, nomad.log contains the most recent log entries prior to rotation? Are all the log files mutually exclusive or does the latest share entries with a timestamped log file?

@Esity
Copy link
Author

Esity commented Jul 23, 2023

Recent/new logs would go to consul.log
Once they are rotated based on the log settings in the hcl, then they go to consul-timestamp.log

Let me know if that makes sense

@david-yu
Copy link
Contributor

@Esity There is a PR now up that will implement this could you review if this works for you? #18617

@gaelik
Copy link

gaelik commented Aug 31, 2023

@Esity There is a PR now up that will implement this could you review if this works for you? #18617

It is exactly what Matt and I were looking for, thank you for making our life easier!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme/logging Relating to logs and error messages
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants