promtail
: promtail's main interface. All interactions should be with this class.
promtail::config
: Creates files and folders associated with promtail's configpromtail::install
: Installs promtailpromtail::service
: Creates a service defintion for promtail
promtail::strip_yaml_header
: A function to strip the --- from the beginning of a stringpromtail::to_yaml
: A function to convert a hash into yaml for the promtail config
promtail's main interface. All interactions should be with this class. The promtail module is intended to install and configure Grafana's promtail tool for shipping logs to Loki.
include promtail
class { 'promtail':
clients_config_hash => $clients_config_hash,
positions_config_hash => $positions_config_hash,
scrape_configs_hash => $_real_scrape_configs_hash,
password_file_content => $sensitive_password_file_content,
password_file_path => $password_file_path,
service_ensure => $service_ensure,
server_config_hash => $server_config_hash,
target_config_hash => $target_config_hash,
bin_dir => $bin_dir,
checksum => $checksum,
version => $version,
}
---
promtail::password_file_path: '/etc/promtail/.gc_pw'
promtail::password_file_content: ENC[PKCS7,MIIBasdfasdfasdfasdfasdfasdf==]
promtail::server_config_hash:
server:
http_listen_port: 9274
grpc_listen_port: 0
promtail::clients_config_hash:
clients:
- url: 'https://logs-us-west1.grafana.net/api/prom/push'
basic_auth:
username: '1234'
password_file: '/etc/promtail/.gc_pw'
promtail::positions_config_hash:
positions:
filename: /tmp/positions.yaml
promtail::scrape_configs_hash:
scrape_configs:
- job_name: journal
journal:
max_age: 12h
labels:
job: systemd-journal
host: "%{facts.networking.fqdn}"
relabel_configs:
- source_labels:
- '__journal__systemd_unit'
target_label: 'unit'
- source_labels:
- 'unit'
regex: "session-(.*)"
action: replace
replacement: 'pam-session'
target_label: 'unit'
class profile::logging::promtail {
$_real_scrape_configs_hash = lookup('promtail_scrape_configs_hash', {merge => 'deep'})
class { 'promtail':
scrape_configs_hash => $_real_scrape_configs_hash,
}
}
The following parameters are available in the promtail
class:
service_enable
service_ensure
clients_config_hash
positions_config_hash
scrape_configs_hash
bin_dir
checksum
version
server_config_hash
target_config_hash
password_file_path
password_file_content
source_url
Data type: Boolean
The value passed to the service resource's enable parameter for promtail's service
Data type: Enum['running', 'stopped']
The value passed to the service resource's ensure parameter for promtail's service
Data type: Hash
Describes how Promtail connects to multiple instances of Loki, sending logs to each. See https://github.com/grafana/loki/blob/master/docs/clients/promtail/configuration.md for all parameters.
Data type: Hash
Describes how to save read file offsets to disk. See https://github.com/grafana/loki/blob/master/docs/clients/promtail/configuration.md for all parameters.
Data type: Hash
Each scrape_config block configures how Promtail can scrape logs from a series of targets using a specified discovery method. See https://github.com/grafana/loki/blob/master/docs/clients/promtail/configuration.md for all parameters.
Data type: Stdlib::Absolutepath
The directory in which to create a symlink to the promtail binary
Data type: String[1]
The checksum of the promtail binary. Note: each platform has its own checksum. Values can be found with each release on GitHub
Data type: String[1]
The version as listed on the GitHub release page See https://github.com/grafana/loki/releases for a list
Data type: Optional[Hash]
Configures Promtail's behavior as an HTTP server. Defaults will be used if this block is omitted. See https://github.com/grafana/loki/blob/master/docs/clients/promtail/configuration.md for all parameters.
Default value: undef
Data type: Optional[Hash]
Configures how tailed targets will be watched. Defaults will be used if this block is omitted. See https://github.com/grafana/loki/blob/master/docs/clients/promtail/configuration.md for all parameters.
Default value: undef
Data type: Optional[Stdlib::Absolutepath]
The fully qualified path to the file containing the password used for basic auth
Default value: undef
Data type: Optional[Sensitive[String[1]]]
The value to be placed in the password file. This value is cast to Sensitive via
lookup_options defined in data/common.yaml
Default value: undef
Data type: Stdlib::HTTPUrl
The URL from which promtail packages can be downloaded
Default value: 'https://github.com/grafana/loki/releases/download'
Type: Ruby 4.x API
A function to strip the --- from the beginning of a string
concat::fragment { 'server_config_hash':
target => $config_file,
content => $promtail::server_config_hash.promtail::to_yaml.promtail::strip_yaml_header,
order => '10',
}
A function to strip the --- from the beginning of a string
Returns: String
Returns the string with the leading header stripped off
concat::fragment { 'server_config_hash':
target => $config_file,
content => $promtail::server_config_hash.promtail::to_yaml.promtail::strip_yaml_header,
order => '10',
}
Data type: String
A string that may start with the ---'s used to denote a YAML file
Type: Ruby 4.x API
A function to convert a hash into yaml for the promtail config
promtail::to_yaml($promtail::config_hash)
A function to convert a hash into yaml for the promtail config
Returns: String
Returns the YAML version of the hash as a string
promtail::to_yaml($promtail::config_hash)
Data type: Hash
A Puppet hash to be converted into YAML