Skip to content

Conversation

@evaan
Copy link

@evaan evaan commented Mar 10, 2025

Pull Request (PR) description

This PR creates a module that manages a script responsible for generating .prom files, 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 using collectors_enable.

This Pull Request (PR) fixes the following issues

n/a

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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe Stdlib::Absolutepath is a better choice?

@@ -0,0 +1,11 @@
<% |
Optional[Hash] $metrics = {},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the optional here?

@TheMeier
Copy link
Contributor

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 = {},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why optional here?

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 = {},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe better Hash[String[1],String[1]] ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right... so a custom type might be in order ;)

user => $user,
}

if $prometheus::server::init_style == 'systemd' {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@evaan
Copy link
Author

evaan commented Mar 12, 2025

Just fixed many of the concerns from earlier, mainly making it configuration-based and making the script static.
Being able to add custom textfile metrics through puppet allows for easier monitoring such as being able to constantly monitor OOM kills within a cgroup.
Being able to pass through Puppet allows for custom metrics to be collected outside of collectors you may be running.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants