I'm not seeing meter information come through, per...
# signoz-cloud
z
I'm not seeing meter information come through, perhaps I'm looking in the wrong place("dashboard panel metrics"). setup in the thread.
import { MeterProvider } from "@opentelemetry/sdk-metrics"; import { OTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-http"; import { PeriodicExportingMetricReader } from "@opentelemetry/sdk-metrics"; import { Resource } from "@opentelemetry/resources"; import { SemanticResourceAttributes } from "@opentelemetry/semantic-conventions"; import { Request, Response, NextFunction } from "express"; const collectorOptions = { url: "https://ingest.us.signoz.cloud:443/v1/metrics", headers: { "signoz-access-token": process.env.SIGNOZ_INGESTION_KEY, }, }; const exporter = new OTLPMetricExporter(collectorOptions); const metricReader = new PeriodicExportingMetricReader({ exporter: exporter, exportIntervalMillis: 60000, // 60 seconds }); const resource = new Resource({ [SemanticResourceAttributes.SERVICE_NAME]: "event-processor", }); // Register the exporter const meterProvider = new MeterProvider({ resource: resource, }); meterProvider.addMetricReader(metricReader); const meter = meterProvider.getMeter("event-processor-meter"); const requestCount = meter.createCounter("requests_count", { description: "Count all incoming requests", }); export const countAllRequests = () => { return (_req_: Request, _res_: Response, next: NextFunction) => { const labels = { route: req.path }; requestCount.add(1, labels); next(); }; }; }; import express, { Request, Response, NextFunction } from "express"; import { v4 as uuidv4 } from "uuid"; import logger from "./logger"; // Interfaces interface CustomRequest extends Request { id?: string; } interface CustomResponse extends Response { id?: string; } // Constants const app = express(); const port = 3000; // Global variables let isReady = false; // Middleware app.use(express.json({ limit: "500kb" })); app.use(countAllRequests()); // Request ID middleware app.use((_req_: CustomRequest, _res_: CustomResponse, next: NextFunction) => { req.id = uuidv4(); res.setHeader('X-Request-ID', req.id); next(); });
s
This looks fine to me. Are you not seeing
requests_count
in the suggestions?
z
I'm not. perhaps I need to have this running at the same time? const sdk = new NodeSDK({ traceExporter: exporter, instrumentations: [getNodeAutoInstrumentations()], resource: new Resource({ [SemanticResourceAttributes.SERVICE_NAME]: "event-processor", // Replace with your service name }), }); sdk.start(); I do have an agent running through kubernetes that is sending logs but perhaps these are separate requirements.
for example, signoz-k8s-infra-otel-agent-hm28l 1/1 Running 0 3h19m signoz-k8s-infra-otel-deployment-7779f988cf-gsszr 1/1 Running 0 3h19m
s
z
same links
made slight adjustment so no confusion. service name is event-processor for both examples of code I shared.
s
Can you try using ConsoleExporter in dev and check it writes metrics to stdout?