Conversation
prometheus.go
Outdated
| wg.Add(1) | ||
| defer wg.Done() | ||
|
|
||
| namespaceMap, err := fetchKVNamespaces(account.ID) |
There was a problem hiding this comment.
🍹 From experience, this list is going to get longer and longer the more native hosting stores we have. I think it might be fine for now, but for example, we do the auto paging for custom hostnames and it takes ~5 minutes to get through 90k custom hostnames.
There was a problem hiding this comment.
hmm you're right. do you think it's needed to fetch KV namespaces on every scrape? i think it might be a bit overkill. maybe we can cache them on boot and then refresh the cache on a separate interval (different from the scrape interval)
There was a problem hiding this comment.
- Only add
namespace_nameif the id matches a hardcoded list - need mapping table. - Only add
namespace_idif the id matches a hardcoded list - simple slice. - Add both
namespace_nameandnamespace_idif id matches a hardcoded list – need mapping table.
All other namespaces that are not on the hardcoded list don't have the label because it's high-cardinality.
There was a problem hiding this comment.
added changes to implement 2) in e3fb3b0
a quick caveat: prometheus constraint is that the same set of labels have to be set on every series, we can't omit the namespace_id entirely. so i've defaulted it to other so they all get bucketed there.
Pull Request Template
Description
Adds Cloudflare KV storage metrics to the Prometheus exporter. Two new metrics are exposed:
cloudflare_kv_requests_count— number of KV operations by namespace and action type (read/write/delete/list)cloudflare_kv_latency— KV operation latency quantiles (P50/P75/P99/P999) in millisecondsNamespace IDs are resolved to human-readable names via the Cloudflare REST API (
/storage/kv/namespaces), falling back to the raw ID if the name cannot be resolved.Type of Change
Testing
Ran the app locally and verified that
cloudflare_kv_latencyandcloudflare_kv_requests_countare visible by visiting/metricsVerified the graphql query gets executed by the app
make pr-testsand all tests passCode Quality
Before Submitting
Please ensure you have completed the following before submitting your PR:
# Run comprehensive tests make pr-testsIf the above command fails, please fix the issues before submitting your PR.
Additional Notes
Add any other context about the pull request here.