I am configuring my node this way
import { NodeSDK } from "@opentelemetry/sdk-node";
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-grpc";
import { Resource } from "@opentelemetry/resources";
import {
SEMRESATTRS_SERVICE_NAME,
SEMRESATTRS_SERVICE_VERSION,
SEMRESATTRS_SERVICE_NAMESPACE
} from "@opentelemetry/semantic-conventions";
import { getNodeAutoInstrumentations } from "@opentelemetry/auto-instrumentations-node";
import { trace } from "@opentelemetry/api";
import { PrometheusExporter } from "@opentelemetry/exporter-prometheus";
import { MeterProvider } from "@opentelemetry/sdk-metrics";
const OTLP_EXPORTER_URL = process.env.OTLP_EXPORTER_URL || "http://localhost:4317";
// OpenTelemtry
const sdk = new NodeSDK({
traceExporter: new OTLPTraceExporter({
url: OTLP_EXPORTER_URL
}),
metricReader: new PrometheusExporter(),
resource: new Resource({
[SEMRESATTRS_SERVICE_NAMESPACE]: "servopa-victoria-backend",
[SEMRESATTRS_SERVICE_NAME]: "servopa-victoria-backend",
[SEMRESATTRS_SERVICE_VERSION]: "1.0"
}),
instrumentations: [getNodeAutoInstrumentations()]
});
sdk.start();
and my Prometheus in Docker.
prometheus:
image: prom/prometheus:v2.47.2
user: root
ports:
- 9090:9090
extra_hosts:
- host.docker.internal:host-gateway
command:
- --config.file=/etc/prometheus/prometheus.yml
volumes:
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
- ./prometheus/prometheus-data:/prometheus
prometheus.yml
global:
scrape_interval: 15s
scrape_configs:
- job_name: cadvisor
static_configs:
- targets:
- cadvisor:8080
- job_name: nodejs_exporter
static_configs:
- targets:
- host.docker.internal:9464
In Prometheus, it is reporting the following error