Skip to content
This repository has been archived by the owner on Jan 8, 2023. It is now read-only.

extra masks usage question #43

Open
parabuzzle opened this issue Oct 30, 2020 · 3 comments
Open

extra masks usage question #43

parabuzzle opened this issue Oct 30, 2020 · 3 comments

Comments

@parabuzzle
Copy link

I'm using this middleware with a Next.js app and I've noticed that it grabs all the static files (which change with every release):

I've tried to use the extra masks option and tried multiple incantations of regex to no avail..

examples I've tried:

extraMasks:[/\/_next\/static\/.*/]
extraMasks:["\/_next\/static\/.*"]
extraMasks:["/_next/static/.*"]

How can mask all the "_next/static" routes?

Example data:

http_request_duration_seconds_bucket{le="0.1",route="/_next/static/css/afd7172b7cfc566ac23d.css",method="GET",status="2XX"} 2
http_request_duration_seconds_bucket{le="0.5",route="/_next/static/css/afd7172b7cfc566ac23d.css",method="GET",status="2XX"} 2
http_request_duration_seconds_bucket{le="1",route="/_next/static/css/afd7172b7cfc566ac23d.css",method="GET",status="2XX"} 2
http_request_duration_seconds_bucket{le="1.5",route="/_next/static/css/afd7172b7cfc566ac23d.css",method="GET",status="2XX"} 2
http_request_duration_seconds_bucket{le="+Inf",route="/_next/static/css/afd7172b7cfc566ac23d.css",method="GET",status="2XX"} 2
http_request_duration_seconds_sum{route="/_next/static/css/afd7172b7cfc566ac23d.css",method="GET",status="2XX"} 0.00456407
http_request_duration_seconds_count{route="/_next/static/css/afd7172b7cfc566ac23d.css",method="GET",status="2XX"} 2
http_request_duration_seconds_bucket{le="0.1",route="/_next/static/chunks/webpack-e067438c4cf4ef2ef178.js",method="GET",status="2XX"} 2
http_request_duration_seconds_bucket{le="0.5",route="/_next/static/chunks/webpack-e067438c4cf4ef2ef178.js",method="GET",status="2XX"} 2
http_request_duration_seconds_bucket{le="1",route="/_next/static/chunks/webpack-e067438c4cf4ef2ef178.js",method="GET",status="2XX"} 2
http_request_duration_seconds_bucket{le="1.5",route="/_next/static/chunks/webpack-e067438c4cf4ef2ef178.js",method="GET",status="2XX"} 2
http_request_duration_seconds_bucket{le="+Inf",route="/_next/static/chunks/webpack-e067438c4cf4ef2ef178.js",method="GET",status="2XX"} 2
http_request_duration_seconds_sum{route="/_next/static/chunks/webpack-e067438c4cf4ef2ef178.js",method="GET",status="2XX"} 0.013053611
http_request_duration_seconds_count{route="/_next/static/chunks/webpack-e067438c4cf4ef2ef178.js",method="GET",status="2XX"} 2
http_request_duration_seconds_bucket{le="0.1",route="/_next/static/chunks/main-d20ec7196aab0d46d13b.js",method="GET",status="2XX"} 2
http_request_duration_seconds_bucket{le="0.5",route="/_next/static/chunks/main-d20ec7196aab0d46d13b.js",method="GET",status="2XX"} 2
http_request_duration_seconds_bucket{le="1",route="/_next/static/chunks/main-d20ec7196aab0d46d13b.js",method="GET",status="2XX"} 2
http_request_duration_seconds_bucket{le="1.5",route="/_next/static/chunks/main-d20ec7196aab0d46d13b.js",method="GET",status="2XX"} 2
http_request_duration_seconds_bucket{le="+Inf",route="/_next/static/chunks/main-d20ec7196aab0d46d13b.js",method="GET",status="2XX"} 2
http_request_duration_seconds_sum{route="/_next/static/chunks/main-d20ec7196aab0d46d13b.js",method="GET",status="2XX"} 0.010383447
http_request_duration_seconds_count{route="/_next/static/chunks/main-d20ec7196aab0d46d13b.js",method="GET",status="2XX"} 2
http_request_duration_seconds_bucket{le="0.1",route="/_next/static/chunks/commons.aaa9335b713850236c60.js",method="GET",status="2XX"} 2
http_request_duration_seconds_bucket{le="0.5",route="/_next/static/chunks/commons.aaa9335b713850236c60.js",method="GET",status="2XX"} 2
http_request_duration_seconds_bucket{le="1",route="/_next/static/chunks/commons.aaa9335b713850236c60.js",method="GET",status="2XX"} 2
http_request_duration_seconds_bucket{le="1.5",route="/_next/static/chunks/commons.aaa9335b713850236c60.js",method="GET",status="2XX"} 2
http_request_duration_seconds_bucket{le="+Inf",route="/_next/static/chunks/commons.aaa9335b713850236c60.js",method="GET",status="2XX"} 2
http_request_duration_seconds_sum{route="/_next/static/chunks/commons.aaa9335b713850236c60.js",method="GET",status="2XX"} 0.011580664```
@joao-fontenele
Copy link
Owner

hello @parabuzzle

the extraMasks config replaces single parts of the route only. So you could replace each part of the path in isolation, not a group of the paths.

you could add extra masks for each kind of file, e.g. a regex for the main.js, a regex for the .css, and so on. This avoids having a different metric, once you deploy a new release of the static files.

And then you could aggregate the static files requests using a query from prometheus

@parabuzzle
Copy link
Author

Oh, that's a bit annoying. I know I can have prom ignore these things through relabel configs. It would be nice to do something similar in the plugin directly. Guess not :(

@vadymrybak
Copy link

How about this:

transformLabels(labels, req: Request) {
        labels.route = req.baseUrl.trim() === "" ? "/static" : req.baseUrl;
    }

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants