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

[feature] - change the filename of logfiles generated for tasks in Nomad #6259

Open
henrikjohansen opened this issue Sep 4, 2019 · 1 comment

Comments

@henrikjohansen
Copy link

henrikjohansen commented Sep 4, 2019

Finding a decent solution for centralized, multi-tenant logging with Nomad is ... difficult ... at the moment, especially when the desire is to keep nomad logs working alongside a centralized log shipping solution.

Our current approach is to inject a Filebeat based sidecar per task that adds several additional fields that are absolutely necessary in multi-tenant setups :

filebeat.inputs:
- paths:
    - /alloc/logs/*.stdout.0
    - /alloc/logs/*.stderr.0
  encoding: utf-8
  fields:
    nomad_job: ${NOMAD_JOB_NAME}
    nomad_group: ${NOMAD_GROUP_NAME}
    nomad_datacenter: ${NOMAD_DC}
    nomad_region: ${NOMAD_REGION}
    ...

... but with several hundred sidecars running this is not really feasible any longer :(

But if the names of the actual log files generated by Nomad could be changed to include more than just the task name the above problem could be solved by running a single log shipper per host.

Inspired by the metrics format that Nomad uses an example could be :

<Namespace>.<Job>.<TaskGroup>.<Task>.stdout.0

Based on the path and filename we could then route the correct logs to the correct teams and enable much easier correlation between the logs and metrics that Nomad offers.

@henrikjohansen
Copy link
Author

henrikjohansen commented Sep 4, 2019

Perhaps it would even be feasible to include this as a configurable option in the log stanza and use the standard variables for Interpolation?

logs {
        max_files       = 10
        max_file_size   = 10
        filename_prefix = "${NOMAD_NAMESPACE.NOMAD_JOB_NAME.NOMAD_GROUP_NAME.NOMAD_TASK_NAME"}
}

The namespace would be available now that #6192 has been merged.

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

No branches or pull requests

2 participants