Skip to content

Commit

Permalink
Merge pull request #68 from hirosystems/fix/metrics-prefix
Browse files Browse the repository at this point in the history
fix(prometheus): adds prefix to each metric and fixes default prom port
  • Loading branch information
CharlieC3 authored Jan 15, 2025
2 parents 6c5505d + d24b362 commit b6132ec
Show file tree
Hide file tree
Showing 3 changed files with 185 additions and 116 deletions.
10 changes: 6 additions & 4 deletions src/api/routes/prom-metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ export const SignerPromMetricsRoutes: FastifyPluginAsync<

const signerRegistry = new Registry();

const metricsPrefix = 'signer_api_';

new Gauge({
name: 'time_since_last_pending_block_proposal_ms',
name: metricsPrefix + 'time_since_last_pending_block_proposal_ms',
help: 'Time in milliseconds since the oldest pending block proposal',
registers: [signerRegistry],
async collect() {
Expand All @@ -30,7 +32,7 @@ export const SignerPromMetricsRoutes: FastifyPluginAsync<
});

new Gauge({
name: 'avg_block_push_time_ms',
name: metricsPrefix + 'avg_block_push_time_ms',
help: 'Average time (in milliseconds) taken for block proposals to be accepted and pushed over different block periods',
labelNames: ['period'] as const,
registers: [signerRegistry],
Expand All @@ -46,7 +48,7 @@ export const SignerPromMetricsRoutes: FastifyPluginAsync<
});

new Gauge({
name: 'proposal_acceptance_rate',
name: metricsPrefix + 'proposal_acceptance_rate',
help: 'The acceptance rate of block proposals for different block ranges (as a float between 0 and 1).',
labelNames: ['period'],
registers: [signerRegistry],
Expand All @@ -62,7 +64,7 @@ export const SignerPromMetricsRoutes: FastifyPluginAsync<
});

new Gauge({
name: 'signer_state_count',
name: metricsPrefix + 'signer_state_count',
help: 'Count of signer states over different block periods',
labelNames: ['signer', 'period', 'state'] as const,
registers: [signerRegistry],
Expand Down
2 changes: 1 addition & 1 deletion src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const schema = Type.Object({
/** Hostname that will be reported to the chainhook node so it can call us back with events */
EXTERNAL_HOSTNAME: Type.String({ default: '127.0.0.1' }),
/** Port in which to serve prometheus metrics */
PROMETHEUS_PORT: Type.Number({ default: 9154 }),
PROMETHEUS_PORT: Type.Number({ default: 9153 }),
/** Port in which to serve the profiler */
PROFILER_PORT: Type.Number({ default: 9119 }),

Expand Down
Loading

0 comments on commit b6132ec

Please sign in to comment.