Nomad
Promtail
@hashicorp
Promtail is an agent which ships the contents of local logs to a private Loki instance or Grafana Cloud.
- Community
- Pack
Updated 2 years ago
- GitHub(opens in new tab)
Promtail
Promtail is an agent which ships the contents of local logs to a private Loki instance or Grafana Cloud. It is usually deployed to every machine that has applications needed to be monitored.
This pack deploys Promtail as a Nomad System Job using the grafana/promtail
Docker image and Consul Service named "promtail".
Dependencies
This pack requires Linux clients to run properly.
Configuration
This pack allows passing a pre-made Promtail configuration file by setting the config_file
variable to a filepath relative to the directory the nomad-pack
command is being called from. If the custom config file being used will require the promtail container to rune as a privileged container, you must set the privileged_container
variable to true
.
If no custom configuration file is provided, a default template will be used which is configured to scrape systemd-journal logs by default. You will need to set the client_urls
variable with a list of URL's in order for promtail to ship the logs. Using the default configuration sets the container to be run as privileged.
Container Privilege
This container runs the Promtail task as a Privileged container.
Variables
Name | Description | Type | Default | Required |
---|---|---|---|---|
job_name | The name to use as the job name which overrides using the pack name. | string | "" | no |
namespace | The namespace where the job should be placed. | string | "default" | no |
datacenters | A list of datacenters in the region which are eligible for task placement. | list(string) | [ "dc1"] | no |
region | The region where the job should be placed. | string | "global" | no |
version_tag | The docker image version. For options, see https://hub.docker.com/grafana/promtail | string | "latest" | no |
privileged | Controls whether the container will be run as a privileged container | bool | false | no |
config_file | Path to custom Promtail configuration file. | string | "" | no |
client_urls | A list of client url's for promtail to send it's data to. | list(string) | [] | no |
journal_max_age | Maximum age of journald entries to scrape. | string | "12h" | no |
constraints | Constraints to apply to the entire job. | list(object({ attribute = string operator = string value = string })) | [ { "attribute": "${attr.kernel.name}", "operator": "", "value": "linux" }] | no |
promtail_group_network | The Promtail network configuration options. | object({ mode = string ports = map(number) }) | { "mode": "bridge", "ports": { "http": 9090 }} | no |
promtail_group_services | Configuration options of the promtail services and checks. | list(object({ service_port_label = string service_name = string service_tags = list(string) check_enabled = bool check_path = string check_interval = string check_timeout = string upstreams = list(object({ name = string port = number })) })) | [ { "check_enabled": true, "check_interval": "3s", "check_path": "/ready", "check_timeout": "1s", "service_name": "promtail", "service_port_label": "http", "service_tags": [], "upstreams": [] }] | no |
resources | The resource to assign to the promtail service task. | object({ cpu = number memory = number }) | { "cpu": 200, "memory": 256} | no |
container_args | Arguments passed to the Promtail docker container | list(string) | [ "-config.file=/etc/promtail/promtail-config.yaml", "-log.level=info"] | no |
extra_mounts | Additional mounts to create in the Promtail container | list(object({ type = string source = string target = string readonly = bool bind_options = list(object({ name = string value = string })) })) | [] | no |
default_mounts | Mounts that are configured when using the default Promtail configuration | list(object({ type = string source = string target = string readonly = bool bind_options = list(object({ name = string value = string })) })) | [ { "bind_options": [ { "name": "propagation", "value": "rshared" } ], "readonly": true, "source": "/var/log/journal", "target": "/var/log/journal", "type": "bind" }, { "bind_options": [ { "name": "propagation", "value": "rshared" } ], "readonly": false, "source": "/etc/machine-id", "target": "/etc/machine-id", "type": "bind" }] | no |