aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-11-15 13:56:04 +0100
committerChocobozzz <me@florianbigard.com>2022-11-15 13:56:04 +0100
commit31a9ed960ff1013940d677cb56f83ecd90a93e26 (patch)
tree33eb418727a762793a62839fb8d039b96e5b9c9b
parent077600e03774203c57ba7e8b122bd18faa3e51e6 (diff)
downloadPeerTube-31a9ed960ff1013940d677cb56f83ecd90a93e26.tar.gz
PeerTube-31a9ed960ff1013940d677cb56f83ecd90a93e26.tar.zst
PeerTube-31a9ed960ff1013940d677cb56f83ecd90a93e26.zip
Add configuration for prometheus exporter hostname
-rw-r--r--config/default.yaml4
-rw-r--r--config/production.yaml.example4
-rw-r--r--server/initializers/checker-before-init.ts5
-rw-r--r--server/initializers/config.ts1
-rw-r--r--server/lib/opentelemetry/metrics.ts7
5 files changed, 16 insertions, 5 deletions
diff --git a/config/default.yaml b/config/default.yaml
index a916b1dc3..19e2fcf3a 100644
--- a/config/default.yaml
+++ b/config/default.yaml
@@ -209,13 +209,15 @@ log:
209 # Accept warn/error logs coming from the client 209 # Accept warn/error logs coming from the client
210 accept_client_log: true 210 accept_client_log: true
211 211
212# Highly experimental support of Open Telemetry 212# Support of Open Telemetry metrics and tracing
213# For more information: https://docs.joinpeertube.org/maintain-observability
213open_telemetry: 214open_telemetry:
214 metrics: 215 metrics:
215 enabled: false 216 enabled: false
216 217
217 # Create a prometheus exporter server on this port so prometheus server can scrape PeerTube metrics 218 # Create a prometheus exporter server on this port so prometheus server can scrape PeerTube metrics
218 prometheus_exporter: 219 prometheus_exporter:
220 hostname: '127.0.0.1'
219 port: 9091 221 port: 9091
220 222
221 tracing: 223 tracing:
diff --git a/config/production.yaml.example b/config/production.yaml.example
index 100bc7948..da067b3b5 100644
--- a/config/production.yaml.example
+++ b/config/production.yaml.example
@@ -207,13 +207,15 @@ log:
207 # Accept warn/error logs coming from the client 207 # Accept warn/error logs coming from the client
208 accept_client_log: true 208 accept_client_log: true
209 209
210# Highly experimental support of Open Telemetry 210# Support of Open Telemetry metrics and tracing
211# For more information: https://docs.joinpeertube.org/maintain-observability
211open_telemetry: 212open_telemetry:
212 metrics: 213 metrics:
213 enabled: false 214 enabled: false
214 215
215 # Create a prometheus exporter server on this port so prometheus server can scrape PeerTube metrics 216 # Create a prometheus exporter server on this port so prometheus server can scrape PeerTube metrics
216 prometheus_exporter: 217 prometheus_exporter:
218 hostname: '127.0.0.1'
217 port: 9091 219 port: 9091
218 220
219 tracing: 221 tracing:
diff --git a/server/initializers/checker-before-init.ts b/server/initializers/checker-before-init.ts
index 42be7ee6e..39713a266 100644
--- a/server/initializers/checker-before-init.ts
+++ b/server/initializers/checker-before-init.ts
@@ -18,7 +18,10 @@ function checkMissedConfig () {
18 'email.body.signature', 'email.subject.prefix', 18 'email.body.signature', 'email.subject.prefix',
19 'storage.avatars', 'storage.videos', 'storage.logs', 'storage.previews', 'storage.thumbnails', 'storage.torrents', 'storage.cache', 19 'storage.avatars', 'storage.videos', 'storage.logs', 'storage.previews', 'storage.thumbnails', 'storage.torrents', 'storage.cache',
20 'storage.redundancy', 'storage.tmp', 'storage.streaming_playlists', 'storage.plugins', 'storage.well_known', 20 'storage.redundancy', 'storage.tmp', 'storage.streaming_playlists', 'storage.plugins', 'storage.well_known',
21 'log.level', 21 'log.level', 'log.rotation.enabled', 'log.rotation.max_file_size', 'log.rotation.max_files', 'log.anonymize_ip',
22 'log.log_ping_requests', 'log.log_tracker_unknown_infohash', 'log.prettify_sql', 'log.accept_client_log',
23 'open_telemetry.metrics.enabled', 'open_telemetry.metrics.prometheus_exporter.hostname',
24 'open_telemetry.metrics.prometheus_exporter.port', 'open_telemetry.tracing.enabled', 'open_telemetry.tracing.jaeger_exporter.endpoint',
22 'user.video_quota', 'user.video_quota_daily', 25 'user.video_quota', 'user.video_quota_daily',
23 'video_channels.max_per_user', 26 'video_channels.max_per_user',
24 'csp.enabled', 'csp.report_only', 'csp.report_uri', 27 'csp.enabled', 'csp.report_only', 'csp.report_uri',
diff --git a/server/initializers/config.ts b/server/initializers/config.ts
index 3dd1f6971..c2f8b19fd 100644
--- a/server/initializers/config.ts
+++ b/server/initializers/config.ts
@@ -190,6 +190,7 @@ const CONFIG = {
190 ENABLED: config.get<boolean>('open_telemetry.metrics.enabled'), 190 ENABLED: config.get<boolean>('open_telemetry.metrics.enabled'),
191 191
192 PROMETHEUS_EXPORTER: { 192 PROMETHEUS_EXPORTER: {
193 HOSTNAME: config.get<string>('open_telemetry.metrics.prometheus_exporter.hostname'),
193 PORT: config.get<number>('open_telemetry.metrics.prometheus_exporter.port') 194 PORT: config.get<number>('open_telemetry.metrics.prometheus_exporter.port')
194 } 195 }
195 }, 196 },
diff --git a/server/lib/opentelemetry/metrics.ts b/server/lib/opentelemetry/metrics.ts
index fc1666604..226d514c0 100644
--- a/server/lib/opentelemetry/metrics.ts
+++ b/server/lib/opentelemetry/metrics.ts
@@ -1,5 +1,5 @@
1import { Application, Request, Response } from 'express' 1import { Application, Request, Response } from 'express'
2import { Meter, metrics } from '@opentelemetry/api-metrics' 2import { Meter, metrics } from '@opentelemetry/api'
3import { PrometheusExporter } from '@opentelemetry/exporter-prometheus' 3import { PrometheusExporter } from '@opentelemetry/exporter-prometheus'
4import { MeterProvider } from '@opentelemetry/sdk-metrics' 4import { MeterProvider } from '@opentelemetry/sdk-metrics'
5import { logger } from '@server/helpers/logger' 5import { logger } from '@server/helpers/logger'
@@ -52,7 +52,10 @@ class OpenTelemetryMetrics {
52 ] 52 ]
53 }) 53 })
54 54
55 provider.addMetricReader(new PrometheusExporter({ port: CONFIG.OPEN_TELEMETRY.METRICS.PROMETHEUS_EXPORTER.PORT })) 55 provider.addMetricReader(new PrometheusExporter({
56 host: CONFIG.OPEN_TELEMETRY.METRICS.PROMETHEUS_EXPORTER.HOSTNAME,
57 port: CONFIG.OPEN_TELEMETRY.METRICS.PROMETHEUS_EXPORTER.PORT
58 }))
56 59
57 metrics.setGlobalMeterProvider(provider) 60 metrics.setGlobalMeterProvider(provider)
58 61