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: # Accept warn/error logs coming from the client accept_client_log: true -# Highly experimental support of Open Telemetry +# Support of Open Telemetry metrics and tracing +# For more information: https://docs.joinpeertube.org/maintain-observability open_telemetry: metrics: enabled: false # Create a prometheus exporter server on this port so prometheus server can scrape PeerTube metrics prometheus_exporter: + hostname: '127.0.0.1' port: 9091 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: # Accept warn/error logs coming from the client accept_client_log: true -# Highly experimental support of Open Telemetry +# Support of Open Telemetry metrics and tracing +# For more information: https://docs.joinpeertube.org/maintain-observability open_telemetry: metrics: enabled: false # Create a prometheus exporter server on this port so prometheus server can scrape PeerTube metrics prometheus_exporter: + hostname: '127.0.0.1' port: 9091 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 () { 'email.body.signature', 'email.subject.prefix', 'storage.avatars', 'storage.videos', 'storage.logs', 'storage.previews', 'storage.thumbnails', 'storage.torrents', 'storage.cache', 'storage.redundancy', 'storage.tmp', 'storage.streaming_playlists', 'storage.plugins', 'storage.well_known', - 'log.level', + 'log.level', 'log.rotation.enabled', 'log.rotation.max_file_size', 'log.rotation.max_files', 'log.anonymize_ip', + 'log.log_ping_requests', 'log.log_tracker_unknown_infohash', 'log.prettify_sql', 'log.accept_client_log', + 'open_telemetry.metrics.enabled', 'open_telemetry.metrics.prometheus_exporter.hostname', + 'open_telemetry.metrics.prometheus_exporter.port', 'open_telemetry.tracing.enabled', 'open_telemetry.tracing.jaeger_exporter.endpoint', 'user.video_quota', 'user.video_quota_daily', 'video_channels.max_per_user', '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 = { ENABLED: config.get('open_telemetry.metrics.enabled'), PROMETHEUS_EXPORTER: { + HOSTNAME: config.get('open_telemetry.metrics.prometheus_exporter.hostname'), PORT: config.get('open_telemetry.metrics.prometheus_exporter.port') } }, 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 @@ import { Application, Request, Response } from 'express' -import { Meter, metrics } from '@opentelemetry/api-metrics' +import { Meter, metrics } from '@opentelemetry/api' import { PrometheusExporter } from '@opentelemetry/exporter-prometheus' import { MeterProvider } from '@opentelemetry/sdk-metrics' import { logger } from '@server/helpers/logger' @@ -52,7 +52,10 @@ class OpenTelemetryMetrics { ] }) - provider.addMetricReader(new PrometheusExporter({ port: CONFIG.OPEN_TELEMETRY.METRICS.PROMETHEUS_EXPORTER.PORT })) + provider.addMetricReader(new PrometheusExporter({ + host: CONFIG.OPEN_TELEMETRY.METRICS.PROMETHEUS_EXPORTER.HOSTNAME, + port: CONFIG.OPEN_TELEMETRY.METRICS.PROMETHEUS_EXPORTER.PORT + })) metrics.setGlobalMeterProvider(provider)