How to expose metrics from sdk and HostMetrics to the same port? #5155
-
|
If possible I'm looking combine both metrics from the sdk and HostMetrics to be exposed at 9464/metrics With this implementation I get: Is this possible? Thanks for the help in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Hi, you're adding the exporter to two different Specifically Doing this instead should work: const prometheus = new PrometheusExporter();
const sdk = new NodeSDK({
metricReader: prometheus,
instrumentations: [
getNodeAutoInstrumentations(),
new RuntimeNodeInstrumentation(),
],
});
sdk.start();
import {metrics} from '@opentelemetry/api';
// important only get `MeterProvider` after `sdk.start()` otherwise it will be no-op.
const hostMetrics = new HostMetrics({ meterProvider: metrics.getMeterProvider() });
hostMetrics.start(); |
Beta Was this translation helpful? Give feedback.
Hi, you're adding the exporter to two different
MeterProviders, which is not supported.Specifically
NodeSDKinstantiates another instance ofMeterProviderand tries to add thePrometheusExporterto the new one but it was already bound on theMeterProvideryou created in L2-L4.Doing this instead should work: