Created
September 5, 2018 05:53
-
-
Save robn/9a3798ae011529a09f12ba439e097aa9 to your computer and use it in GitHub Desktop.
prom_file_exporter.pl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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