Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add function to analyse used labels, and not just used metrics. #232

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tomwilkie
Copy link
Contributor

This is a WIP PR which analyses the usage of labels, and not just metric names. The idea is eventually we'll be able to identify labels we can drop / aggregate way.

Lots of this exists already (great work @gouthamve) but AFAICT only analyses metric names? I plan on just working through this pipeline and updating everything to consider labels too.

 1.Extract Queries     2.Line-delimited  3.Extract Labels
                         PromQL queries
┌────────────────────┐
│  Prometheus Logs   ├─────────┐
└────────────────────┘         │
                               │
┌────────────────────┐         │         ┌───────────────┐
│  Prometheus Rules  ├─────────┼────────►│ Query Analyse │
└────────────────────┘         │         └───────┬───────┘
                               │                 │
┌────────────────────┐         │                 │
│ Grafana Dashboards ├─────────┘                 │
└────────────────────┘                           │
                                                 │
                                                 │
                                                 │
 4.Extract Series Labels                         │   5. Find unused labels
                                                 ▼
┌────────────────────┐                   ┌───────────────┐
│    Active Series   ├──────────────────►│   Label Diff  │
└────────────────────┘                   └───────┬───────┘
                                                 │
                                                 │
                                                 │
                                                 │
                                                 │
 6.Extract Series Counts                         │   7. Rank unused labels
                                                 ▼      to find best
┌────────────────────┐                   ┌───────────────┐
│    Active Series   ├──────────────────►│  Rank Unused  │
└────────────────────┘                   └───────┬───────┘
                                                 │
                                                 │
                                                 ▼
                                         ┌───────────────┐
                                         │  Aggregation  │
                                         │     Rules     │
                                         └───────────────┘

Signed-off-by: Tom Wilkie [email protected]

}

for _, label := range ae.Grouping {
setInsert(label, &usedLabels.LabelsUsed)
Copy link
Contributor

@replay replay Jan 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just use a temporary map for the used labels?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No particular reason, I guess I was expecting this list to be short and this to be cheaper than all the allocs associated with maps.

@CLAassistant
Copy link

CLAassistant commented Jun 15, 2022

CLA assistant check
All committers have signed the CLA.

friedrichg pushed a commit to cortexproject/cortex-tools that referenced this pull request Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants