metrico / qryn

Polyglot Observability Stack. Lightweight & Drop-in compatible with Loki, Prometheus, Tempo, Pyroscope, Opentelemetry, Datadog & more! WASM powered ⭐️ Star to Support
https://qryn.dev
GNU Affero General Public License v3.0
1.05k stars 63 forks source link

undefined parser #501

Closed shimaore closed 2 months ago

shimaore commented 2 months ago

Seeing the following error (in 3.2.17 and 3.2.19); I don't know for sure which query is concerned but most probably loki since I'm seeing 500 errors for it on the client side (vector).

undefined parser
Error: undefined parser
    at Parser.fn (/app/parsers.js:263:15)
    at ContentTypeParser.run (/app/node_modules/fastify/lib/contentTypeParser.js:177:27)
    at handleRequest (/app/node_modules/fastify/lib/handleRequest.js:41:33)
    at next (/app/node_modules/fastify/lib/hooks.js:339:7)
    at Object.<anonymous> (/app/qryn_node.js:112:7)
    at next (/app/node_modules/fastify/lib/hooks.js:345:30)
    at preParsingHookRunner (/app/node_modules/fastify/lib/hooks.js:368:3)
    at runPreParsing (/app/node_modules/fastify/lib/route.js:587:5)
    at next (/app/node_modules/fastify/lib/hooks.js:237:9)
    at /app/node_modules/@fastify/cors/index.js:201:12

There was a ticket opened a couple months ago on a similar issue #441 .

lmangani commented 2 months ago

@shimaore thanks for the report but we need to know how to reproduce this in order to replicate and fix. Could you try and find the message(s) producing this error?

shimaore commented 2 months ago

I raised the LOG_LEVEL to debug and the log contains:

{"level":30,"time":1714587428350,"pid":14,"hostname":"…","name":"qryn","reqId":"req-5p","req":{"method":"POST","url":"/v1/metrics","hostname":"…","remoteAddress":"127.0.0.1","remotePort":40886},"msg":"incoming request"}
{"level":50,"time":1714587428350,"pid":14,"hostname":"…","name":"qryn","reqId":"req-5p","err":"undefined parser\nError: undefined parser\n    at Parser.fn (/app/parsers.js:263:15)\n    at ContentTypeParser.run (/app/node_modules/fastify/lib/contentTypeParser.js:177:27)\n    at handleRequest (/app/node_modules/fastify/lib/handleRequest.js:41:33)\n    at next (/app/node_modules/fastify/lib/hooks.js:339:7)\n    at Object.<anonymous> (/app/qryn_node.js:112:7)\n    at next (/app/node_modules/fastify/lib/hooks.js:345:30)\n    at preParsingHookRunner (/app/node_modules/fastify/lib/hooks.js:368:3)\n    at runPreParsing (/app/node_modules/fastify/lib/route.js:587:5)\n    at next (/app/node_modules/fastify/lib/hooks.js:237:9)\n    at /app/node_modules/@fastify/cors/index.js:201:12","msg":"undefined parser"}
{"level":30,"time":1714587428350,"pid":14,"hostname":"…","name":"qryn","reqId":"req-5p","res":{"statusCode":500},"responseTime":0.6597940027713776,"msg":"request completed"}

I'll see if I can get more logs with a custom build.

shimaore commented 2 months ago

Actually given the path this looks like it could be a misconfigured endpoint.

Suggestion: provide a better message than undefined parser for new users?

diff --git a/parsers.js b/parsers.js
index 036aa30..6cd4da0 100644
--- a/parsers.js
+++ b/parsers.js
@@ -260,7 +260,7 @@ const parsers = {
       const parser = find(parsers._parsers, [contentType, req.routeOptions.method, req.routeOptions.url]) ||
         find(parsers._parsers, ['*', req.routeOptions.method, req.routeOptions.url])
       if (!parser) {
-        throw new Error('undefined parser')
+        throw new Error(`undefined parser for ${contentType} ${req.routeOptions.method} ${req.routeOptions.url}`)
       }
       return await parser(req, payload)
     },
shimaore commented 2 months ago

Definitely a misconfigured endpoint, I was trying to use @opentelemetry/exporter-metrics-otlp-proto but OTLP Metrics are not listed in the Qryn Ingestion API list yet.

Sorry about the noise.

Dletta commented 2 months ago

@shimaore Your suggestion is not a bad idea. Feel free to add a PR for the extended error message. Could be helpful for others.