How to group http urls as the resource uri (UUID/ID) part is irrelevant for the graph as it is the same API being hit?


I want to create pie chart for API endpoints for like how many times which API endpoint has got hit!
Currently every request to /videos/UUID is being considered as different as grafana consider all the endpoints different what I want to do is to consider all /videos/UUID endpoints to consider a single endpoint like /videos/{id} so graph shows the collective count of /videos/{id} instead of showing count of each /videos/UUID requests.
for example:
Grafana considers below endpoints as different and show their count;
/videos/42j34h2-c463-4d88-9e02-28c141347098
/videos/63h5kns-c463-4d88-9e02-532kjh23kjn53
/videos/23ij4r22-c463-4d88-9e02-f4r43443fsfdss
What it should consider is as; /videos/{id}

welcome @observability10

what is your datasource? you would use regex but not sure how far you can push it to get what you need ^.*videos.*$

value mapping will only change the value on the surface underneath they will still all be different urls. what i mean is basically grafana will still count each of them individually.
see the attached ss below, i have already tried what you said above with value mapping.

I tried the transformation you provided as well, still no luck. The existing transformation is necessary to create the pie chart based of path and value#A count.

1 Like

what is your datasource

what do you mean by datasource? nvm newbie to grafana here! Promtail is basically setup to push the logs to loki server if that is what you are asking.

1 Like

Grafana champ bro! I admire your support, please either show me the way to do so, I hope the questions is clear to you, atleast tell me if that is even possible on grafana level.
I mean I know I can do workaround in my code where the logs are being generated or at promtail yaml file level perhaps but doing it there won’t be effective and efficient for the API server also as it looks like grafana should have some way to handle it.

Run with it :horse:

this seems to work on my side of town. modify per your needs

	count_over_time(
    {color="pink"} | regexp "(?P<video_url>\\/[\\w|$]+)"
    [5m])

which graph are you using? also may you please elaborate a little bit what is happening under the hood? like what is the regex doing?
My understanding is that it is counting over 5mins for color label equal to ‘pink’ in value with the regex pattern! right? Well if yes then how is it gonna solve the problem like having graph to show count of all endpoints requests? feels like it is only looking for paths with word video_url

I am using timeseries but that does not matter.
under the hood, I am just using regex to strip things down to the paths: tasks and videos

it is counting each path type.

{job="varlogs"} | regexp "(?P<url>\\/[\\w|$]+)"

read docu on regexp to understand what is happening here.