Skip to content

Commit

Permalink
Merge pull request #126 from hathitrust/prometheus-exporter
Browse files Browse the repository at this point in the history
Prometheus exporter for metrics
  • Loading branch information
aelkiss authored May 30, 2024
2 parents 4ada912 + e2dffb9 commit b0d512b
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
libmailtools-perl \
libmouse-perl \
libnet-prometheus-perl \
libplack-perl \
libreadonly-perl \
libreadonly-xs-perl \
libroman-perl \
Expand Down
30 changes: 30 additions & 0 deletions bin/metrics_exporter.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
use strict;
use warnings;

use HTFeed::JobMetrics;
use Plack::Response;

# Metrics exporter for prometheus statistics gathered via ingest.
# Usage: plackup -p 9090 ./bin/metrics_exporter.pl

my $metrics = HTFeed::JobMetrics->get_instance();

my $app = sub {
my $env = shift;

my $rendered = $metrics->pretty();

my $response = Plack::Response->new();
$response->content_type('text/plain');

if ($rendered) {
$response->status(200);
$response->body($rendered);
} else {
$response->status(500);
$response->body("# metrics rendering failed");
}

return $response->finalize;

};
17 changes: 17 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ services:
- HTFEED_CONFIG=/usr/local/feed/etc/config_ingest_docker.yml
- FEED_HOME=/usr/local/feed
- VERSION=feed-development
- HTFEED_JOBMETRICS_DATA_DIR=/usr/local/feed/jobmetrics
depends_on:
mariadb: *healthy

Expand All @@ -86,12 +87,27 @@ services:
- ./volumes_to_test:/tmp/stage/toingest/test
environment:
- HTFEED_CONFIG=/usr/local/feed/etc/config_prevalidate.yml
- HTFEED_JOBMETRICS_DATA_DIR=/usr/local/feed/jobmetrics
- FEED_HOME=/usr/local/feed
- VERSION=feed-development
command: bash -c "/bin/ls /tmp/stage/toingest/test/*.zip | xargs -n 1 basename | sed s/.zip// | perl -w /usr/local/feed/bin/validate_volume.pl -p simple -n test --no-clean"
depends_on:
mariadb: *healthy

prometheus-exporter:
build: .
volumes:
- .:/usr/local/feed
ports:
- "9090:9090"
environment:
- HTFEED_CONFIG=/usr/local/feed/etc/config_prevalidate.yml
- HTFEED_JOBMETRICS_DATA_DIR=/usr/local/feed/jobmetrics
- FEED_HOME=/usr/local/feed
- VERSION=feed-development
command: plackup -p 9090 ./bin/metrics_exporter.pl


mariadb:
image: ghcr.io/hathitrust/db-image:latest
volumes:
Expand Down Expand Up @@ -125,6 +141,7 @@ services:
<<: *healthcheck-defaults
test: [ "CMD", "wget", "--quiet", "--tries=1", "-O", "/dev/null", "pushgateway:9091/-/healthy" ]


rabbitmq:
image: rabbitmq
healthcheck:
Expand Down

0 comments on commit b0d512b

Please sign in to comment.