cloudflare-exporter icon indicating copy to clipboard operation
cloudflare-exporter copied to clipboard

Add path metric

Open yurifrlcw opened this issue 2 years ago • 1 comments

New Cloudflare metric and configuration option

This pull request adds a new metric, cloudflare_zone_requests_origin_status_path_host, to the exporter. The new metric takes the path from Cloudflare's GraphQL endpoint httpRequestsAdaptiveGroups.

To enable this new metric, a new configuration option cfgClientRequestPathFilters has been added, which allows the user to pass a filter to specify which requests should be included in the metric. For example, to filter requests based on their HTTP host and path, the following command line argument can be used:

-cf_path_filters='{ "AND": [ { "clientRequestHTTPHost_in": [ "foo.io" ] }, {"clientRequestPath_in": [ "/bar", "/bar/foo" ] } ] }'

The filter should match the filter of httpRequestsAdaptiveGroups and the default datetime will be added

This filter will only include requests that have an HTTP host of foo.io and a path of either /bar or /bar/foo.

This new feature provides users of cloudflare-exporter with greater flexibility in monitoring and analyzing requests from specific origins.

Notes

  • This should address #33
  • I choose this approach to not flood prometheus with metrics, I noticed that even if I get the top x metrics, this number tend to grown as they rotate, found much safer to just pass the query and give the option to use filters like clientRequestPath_in

yurifrlcw avatar Mar 14 '23 20:03 yurifrlcw

Hey, nice one. Curious what's left here to get it merged ?

Cali93 avatar Jun 05 '24 07:06 Cali93