Skip to content

Commit f352bba

Browse files
chore: add prometheus ports to remaining services for consistency (#6412)
Co-authored-by: Kamil Kisiela <[email protected]>
1 parent 2bd2082 commit f352bba

File tree

10 files changed

+17
-3
lines changed

10 files changed

+17
-3
lines changed

.changeset/three-random-words.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'hive': minor
3+
---
4+
5+
Added a new environment variable `PROMETHEUS_METRICS_PORT` to control the promethus port of the policy service. The default value is `10254` (no action needed).

packages/services/policy/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ policy checks.
1414
| `SENTRY` | No | Whether Sentry error reporting should be enabled. | `1` (enabled) or `0` (disabled) |
1515
| `PROMETHEUS_METRICS` | No | Whether Prometheus metrics should be enabled | `1` (enabled) or `0` (disabled) |
1616
| `PROMETHEUS_METRICS_LABEL_INSTANCE` | No | The instance label added for the prometheus metrics. | `usage-service` |
17+
| `PROMETHEUS_METRICS_PORT` | No | Port on which prometheus metrics are exposed | Defaults to `10254` |
1718
| `OPENTELEMETRY_COLLECTOR_ENDPOINT` | No | OpenTelemetry Collector endpoint. The expected traces transport is HTTP (port `4318`). | `http://localhost:4318/v1/traces` |

packages/services/policy/src/environment.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const SentryModel = zod.union([
3737
const PrometheusModel = zod.object({
3838
PROMETHEUS_METRICS: emptyString(zod.union([zod.literal('0'), zod.literal('1')]).optional()),
3939
PROMETHEUS_METRICS_LABEL_INSTANCE: emptyString(zod.string().optional()),
40+
PROMETHEUS_METRICS_PORT: emptyString(NumberFromString.optional()),
4041
});
4142

4243
const LogModel = zod.object({
@@ -119,6 +120,7 @@ export const env = {
119120
labels: {
120121
instance: prometheus.PROMETHEUS_METRICS_LABEL_INSTANCE ?? 'schema',
121122
},
123+
port: prometheus.PROMETHEUS_METRICS_PORT ?? 10_254,
122124
}
123125
: null,
124126
} as const;

packages/services/policy/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ async function main() {
8989
});
9090

9191
if (env.prometheus) {
92-
await startMetrics(env.prometheus.labels.instance);
92+
await startMetrics(env.prometheus.labels.instance, env.prometheus.port);
9393
}
9494
} catch (error) {
9595
server.log.fatal(error);

packages/services/rate-limit/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ you don't need this service.
2121
| `SENTRY_DSN` | No | The DSN for reporting errors to Sentry. | `https://[email protected]/12121212` |
2222
| `PROMETHEUS_METRICS` | No | Whether Prometheus metrics should be enabled | `1` (enabled) or `0` (disabled) |
2323
| `PROMETHEUS_METRICS_LABEL_INSTANCE` | No | The instance label added for the prometheus metrics. | `rate-limit` |
24+
| `PROMETHEUS_METRICS_PORT` | No | Port on which prometheus metrics are exposed | Defaults to `10254` |
2425
| `WEB_APP_URL` | No | The base url of the web app | `https://your-instance.com` |
2526
| `REQUEST_LOGGING` | No | Log http requests | `1` (enabled) or `0` (disabled) |
2627
| `LOG_LEVEL` | No | The verbosity of the service logs. One of `trace`, `debug`, `info`, `warn` ,`error`, `fatal` or `silent` | `info` (default) |

packages/services/rate-limit/src/environment.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const PostgresModel = zod.object({
5050
const PrometheusModel = zod.object({
5151
PROMETHEUS_METRICS: emptyString(zod.union([zod.literal('0'), zod.literal('1')]).optional()),
5252
PROMETHEUS_METRICS_LABEL_INSTANCE: zod.string().optional(),
53+
PROMETHEUS_METRICS_PORT: emptyString(NumberFromString.optional()),
5354
});
5455

5556
const LogModel = zod.object({
@@ -155,6 +156,7 @@ export const env = {
155156
labels: {
156157
instance: prometheus.PROMETHEUS_METRICS_LABEL_INSTANCE ?? 'rate-limit',
157158
},
159+
port: prometheus.PROMETHEUS_METRICS_PORT ?? 10_254,
158160
}
159161
: null,
160162
} as const;

packages/services/rate-limit/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ async function main() {
119119
});
120120

121121
if (env.prometheus) {
122-
await startMetrics(env.prometheus.labels.instance);
122+
await startMetrics(env.prometheus.labels.instance, env.prometheus.port);
123123
}
124124
await server.listen({
125125
port: env.http.port,

packages/services/usage-estimator/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ This service takes care of estimating the usage of an account.
2222
| `SENTRY_ENABLED` | No | Whether Sentry error reporting should be enabled. | `1` (enabled) or `0` (disabled) |
2323
| `PROMETHEUS_METRICS` | No | Whether Prometheus metrics should be enabled | `1` (enabled) or `0` (disabled) |
2424
| `PROMETHEUS_METRICS_LABEL_INSTANCE` | No | The instance label added for the prometheus metrics. | `rate-limit` |
25+
| `PROMETHEUS_METRICS_PORT` | No | Port on which prometheus metrics are exposed | Defaults to `10254` |
2526
| `REQUEST_LOGGING` | No | Log http requests | `1` (enabled) or `0` (disabled) |
2627
| `LOG_LEVEL` | No | The verbosity of the service logs. One of `trace`, `debug`, `info`, `warn` ,`error`, `fatal` or `silent` | `info` (default) |
2728
| `OPENTELEMETRY_COLLECTOR_ENDPOINT` | No | OpenTelemetry Collector endpoint. The expected traces transport is HTTP (port `4318`). | `http://localhost:4318/v1/traces` |

packages/services/usage-estimator/src/environment.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const SentryModel = zod.union([
3737
const PrometheusModel = zod.object({
3838
PROMETHEUS_METRICS: emptyString(zod.union([zod.literal('0'), zod.literal('1')]).optional()),
3939
PROMETHEUS_METRICS_LABEL_INSTANCE: emptyString(zod.string().optional()),
40+
PROMETHEUS_METRICS_PORT: emptyString(NumberFromString.optional()),
4041
});
4142

4243
const LogModel = zod.object({
@@ -137,6 +138,7 @@ export const env = {
137138
labels: {
138139
instance: prometheus.PROMETHEUS_METRICS_LABEL_INSTANCE ?? 'rate-limit',
139140
},
141+
port: prometheus.PROMETHEUS_METRICS_PORT ?? 10_254,
140142
}
141143
: null,
142144
} as const;

packages/services/usage-estimator/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ async function main() {
106106
});
107107

108108
if (env.prometheus) {
109-
await startMetrics(env.prometheus.labels.instance);
109+
await startMetrics(env.prometheus.labels.instance, env.prometheus.port);
110110
}
111111
await server.listen({
112112
port: env.http.port,

0 commit comments

Comments
 (0)