Skip to content

Instantly share code, notes, and snippets.

@robn
Created September 5, 2018 05:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robn/9a3798ae011529a09f12ba439e097aa9 to your computer and use it in GitHub Desktop.
Save robn/9a3798ae011529a09f12ba439e097aa9 to your computer and use it in GitHub Desktop.
prom_file_exporter.pl
#!/usr/bin/env plackup
# grab all the .prom files from PROM_FILE_EXPORTER_METRICS_DIR PATH hand them to
# anyone that asks
use warnings;
use strict;
use Path::Tiny;
my @paths = map { path($_) } (split ':', ($ENV{PROM_FILE_EXPORTER_METRICS_PATH} // ''));
die "PROM_FILE_EXPORTER_METRICS_PATH not set\n" unless @paths;
sub app {
sub {
my $w = shift->([200, []]);
for my $path (@paths) {
next unless $path->exists;
$w->write($_->slurp) for $path->children(qr/\.prom$/);
}
$w->close;
};
}
\&app;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment