Skip to content

Commit b6132ec

Browse files
authored
Merge pull request #68 from hirosystems/fix/metrics-prefix
fix(prometheus): adds prefix to each metric and fixes default prom port
2 parents 6c5505d + d24b362 commit b6132ec

File tree

3 files changed

+185
-116
lines changed

3 files changed

+185
-116
lines changed

src/api/routes/prom-metrics.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ export const SignerPromMetricsRoutes: FastifyPluginAsync<
1616

1717
const signerRegistry = new Registry();
1818

19+
const metricsPrefix = 'signer_api_';
20+
1921
new Gauge({
20-
name: 'time_since_last_pending_block_proposal_ms',
22+
name: metricsPrefix + 'time_since_last_pending_block_proposal_ms',
2123
help: 'Time in milliseconds since the oldest pending block proposal',
2224
registers: [signerRegistry],
2325
async collect() {
@@ -30,7 +32,7 @@ export const SignerPromMetricsRoutes: FastifyPluginAsync<
3032
});
3133

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

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

6466
new Gauge({
65-
name: 'signer_state_count',
67+
name: metricsPrefix + 'signer_state_count',
6668
help: 'Count of signer states over different block periods',
6769
labelNames: ['signer', 'period', 'state'] as const,
6870
registers: [signerRegistry],

src/env.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const schema = Type.Object({
2626
/** Hostname that will be reported to the chainhook node so it can call us back with events */
2727
EXTERNAL_HOSTNAME: Type.String({ default: '127.0.0.1' }),
2828
/** Port in which to serve prometheus metrics */
29-
PROMETHEUS_PORT: Type.Number({ default: 9154 }),
29+
PROMETHEUS_PORT: Type.Number({ default: 9153 }),
3030
/** Port in which to serve the profiler */
3131
PROFILER_PORT: Type.Number({ default: 9119 }),
3232

0 commit comments

Comments
 (0)