Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(prometheus): adds prefix to each metric and fixes default prom port #68

Merged
merged 3 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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