node_exporter: create module for textfile scraping - #881
Conversation
| Optional[Enum['none', 'http', 'https', 'ftp']] $proxy_type = undef, | ||
| Stdlib::Absolutepath $web_config_file = '/etc/node_exporter_web-config.yml', | ||
| Prometheus::Web_config $web_config_content = {}, | ||
| Optional[String] $textfile_directory = undef, |
There was a problem hiding this comment.
Maybe Stdlib::Absolutepath is a better choice?
| @@ -0,0 +1,11 @@ | |||
| <% | | |||
| Optional[Hash] $metrics = {}, | |||
|
Can you please tell me a bit about the benefit this brings? Where do the metrics put in the class param actually come from ? If its from hiera this seems like an unnecessary extra step. Why do you need one file per key? I've been using textfile collectors for quite some time, usually each collector gathers its own data and dumps it into its own file. What is the benefit of passing that through puppet? Not a big fan of shell-scripts with templating. IMHO any kind of executable should be static an consume a templated confgi/data file. |
| @@ -0,0 +1,20 @@ | |||
| <% | | |||
| Optional[Hash] $metrics = {}, | |||
| class prometheus::node_exporter_textfile ( | ||
| String $update_script_location = '/usr/local/bin/update_metrics.sh', | ||
| String $cleanup_script_location = '/usr/local/bin/cleanup_metrics.sh', | ||
| Hash $metrics = {}, |
There was a problem hiding this comment.
Maybe better Hash[String[1],String[1]] ?
There was a problem hiding this comment.
The hash looks like
metrics = {
"metric_name": {
"command": "cat whatever"
"static": false
}
}
So I'd assume a type such as Hash[String[1], Hash[String[1], Variant[String[1], Boolean]]] would be better?
There was a problem hiding this comment.
Right... so a custom type might be in order ;)
| user => $user, | ||
| } | ||
|
|
||
| if $prometheus::server::init_style == 'systemd' { |
There was a problem hiding this comment.
Textfile test
|
Just fixed many of the concerns from earlier, mainly making it configuration-based and making the script static. |
Pull Request (PR) description
This PR creates a module that manages a script responsible for generating
.promfiles, which can be used with the node_exporter textfile collector. Currently, it supports systemd, but it can easily be modified to use a cron job for machines running other init systems. This PR also updates the node_exporter module to allow configuration of the textfile collectors directory without usingcollectors_enable.This Pull Request (PR) fixes the following issues
n/a