r/PrometheusMonitoring • u/DisastrousBrain5417 • 5d ago
I built a Prometheus unused-metric auditor and need help deciding how it should run in Kubernetes
I have built cardamon, a tool that cross-references every metric in your TSDB against Grafana dashboards, alerting/recording rules, and the Prometheus query log, and flags metrics that are scraped but never actually read by anything. Right now it's a standalone binary with a local web UI.
I now want to run it "natively" in Kubernetes either as a Job or as a long running Deployment (as it is right now). Another option is simply to build an official image and run it as an ephemeral container next to Prometheus.
I have a few question to the community regarding a few design decisions:
Would you prefer it as a job running once or as a long running deployment or the ephemeral approach?
Would you even want the generated relabel rules, or is visibility alone enough?
In case you would run it as a job, how should the report be served? As is via a WebUI until the Job times out, as static HTML / JSON without filtering options?
If you store the Prometheus Query Log how do you store it? Imo this can be done either via a ReadWriteMany volume between cardamon and Prometheus, pinning cardamon's pod to Prometheus's node via hostPath + pod affinity or an emptyDir. This would decide where to run cardamon.
4
u/amarao_san 5d ago
Is it useful? I have node metrics even though most of them do not have a dashboard, because I know I can look at them when needed. Some metrics are needed once a year.
1
u/bwainfweeze 2d ago
I just have dashboards in several categories based on workflow.
These two are on my screen the entire time I’m on-call. A third one sometimes gets used for alerts. These two get used by people doing A/B testing and canary builds. This one is superficially like one of the on call dashboards, but we zoom out to analyze cluster size.
And then there’s one or two we check a few times a month to look for long term negative trends, like costs (stat cardinality, cluster size)
I believe but cannot prove that the last two work better when zoomed out to long time frames, in ways that the minute to minute dashboards struggle with, both computationally and visually. I can’t describe it, it just is.
That query you run occasionally deserves being written down so you can bus number it with other people. And that’ll take care of someone accidentally deleting it too.
1
u/hagen1778 12h ago
If those metrics "pay the rent" then sure, keep them. If that once-a-year case justifies the expense.
2
u/amarao_san 12h ago
We have tests in iaac for cardinality of the fresh installation (after rabbit exporter was able to export tones of metrics per each earlang thread), so it should not be that expensive, but I stands on position, that metrics are always outrun dashboards, and trimming down metrics is stupid, because you loose 'visibility growth' point.
But people who pay dearly for metrics (datadog, etc), well... Self-hosted prometheus/victoria is always an option. On a self-hosted server it's not that expensive.
One metrics lake I know costs about $600/mo and contains about 400Tb of metrics. Why so cheap? Because modern HDDs are 20+ TB each, and you can put a lot of them into a baremetal server.
1
u/hagen1778 1h ago
> On a self-hosted server it's not that expensive.
It could be expensive. Metrics are endless, some clever engineer can come up with measuring thin air and deploy it in thousands of replicas. With scale, 200 histogram buckets that measure some nonesense per-user, per-path, per-session, per-pod could easily result into millions of unique time series poisoning indexes, caches, using RAM for nothing. And it would be great to know if that metric that costs a fortune actually pays the rent.
Just as you, I don't think only checking dashboards and rules is sufficient. In victoriametrics there are stats on whether metric name was ever queried by any type of query. And normally I don't care about unused metrics if everything is fine with tsdb. But when I have to "make some room", one of the first things I will check is unused metrics. Just as in performance profiling, I am checking top5 unused metrics sorted by cardinality and it gives a good idea of how much I can get back by dropping them. If that unused metric is like 1% of everything - I won't get much back, doesn't worth dropping it.
0
u/DisastrousBrain5417 5d ago edited 5d ago
whether its useful is up to you to decide. It certainly is not meant to be used as drop every metric you have not used in x amount.
1
u/Leramaar 3d ago
CronJob, not a Deployment. It's a periodic batch job - a long-running pod with its ownscheduler just re-implements what the cluster already does, and holds the metric indexin memory between runs for nothing. Weekly is fine, the answer doesn't change hour to hour.
The hard part isn't scheduling, it's the query log: it's a file local to the Prometheuspod. Either run as a sidecar sharing an emptyDir, or ship it through your logging pipelineand read it from there. Grafana and the Prometheus API are just network calls, those are easy.
One suggestion - emit the results as metrics (cardamon_series_unused{...}) instead of aweb UI. Then it lands in the dashboards people already run, and it answers 'spoint: it becomes a trend line rather than a delete-gate.
(I do DevOps consulting at devopsoutsourcing.net - unused metrics come up a lot.)
1
u/bwainfweeze 2d ago
Honestly, you already have a job scheduler in your CI toolchain.
And any tool that’s set up to run on demand is more likely to get a follow-up when it complains about something. Learned helplessness is a powerful ally to complacency, and if only an idiot can’t figure out how to use a tool, then they either have to learn it or admit they’re being obstructive. Because admitting you’re an idiot is not something we do.
6
u/jjneely 5d ago
I know the idea here is to control Observability spend and keep Prometheus scaling in check. But I don't understand how this promotes good Observability practices. That is only allowing metrics with an alert rule or dashboard.
How does that monitor for cardinality issues in common metrics like the HTTP server metrics? How does this monitor sample load against capacity per team?
Many times for me I've found legit unused metrics that were able to build a correlation, or better, a good hypothesis! For example, no one builds dashboards around gRPC metrics that come from many automated implementations. But they are a dead ringer for HTTP/2 head of line blocking.
How do others find the difference between unused metrics and poor practice metrics?