Skip to content

feat: persist patterns as aggregated metrics #17737

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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

trevorwhitney
Copy link
Collaborator

@trevorwhitney trevorwhitney commented May 19, 2025

What this PR does / why we need it:

This PR is the first step to enable persistence of patterns in Logs Drilldown beyond 3h. It persists the patterns back to Loki in the __aggregrated_metric__ stream, similar to aggregated metrics. This seems like the best solution for now, with the eventual goal of putting this type of information in dataobjs.

Screenshot of comparing these patterns to the existing.
Screenshot 2025-05-22 at 12 34 40

This PR also changes how patterns are stored in order to capture level in addition to the stream selector. This allowed the patterns to be persisted with level, and is needed for an upcoming change to the UI to group and filter patterns by level.

Checklist

  • Reviewed the CONTRIBUTING.md guide (required)
  • Documentation added
  • Tests updated
  • Title matches the required conventional commits format, see here
    • Note that Promtail is considered to be feature complete, and future development for logs collection will be in Grafana Alloy. As such, feat PRs are unlikely to be accepted unless a case can be made for the feature actually being a bug fix to existing behavior.
  • Changes that require user attention or interaction to upgrade are documented in docs/sources/setup/upgrade/_index.md
  • If the change is deprecating or removing a configuration option, update the deprecated-config.yaml and deleted-config.yaml files respectively in the tools/deprecated-config-checker directory. Example PR

@trevorwhitney trevorwhitney requested a review from a team as a code owner May 19, 2025 15:23
@trevorwhitney trevorwhitney marked this pull request as draft May 21, 2025 17:19
@trevorwhitney trevorwhitney force-pushed the persist-patterns-as-aggs branch from 0327353 to 60eb96d Compare May 22, 2025 18:06
Copy link
Contributor

github-actions bot commented May 22, 2025

@trevorwhitney trevorwhitney marked this pull request as ready for review May 22, 2025 18:37
@slim-bean
Copy link
Collaborator

It feels kind of wrong to me that we are reusing aggregated_metric naming and the aggregated_metric label for this as it's not an aggregated metric.

I think we should use a different label for this? And maybe there is a different name we could use for code that is shared which isn't specific to aggregated metrics and usable for both

# CLI flag: -pattern-ingester.metric-aggregation.downsample-period
[downsample_period: <duration> | default = 10s]
# Configures the aggregation and storage behavior of the pattern ingester.
aggregation:
Copy link
Collaborator

Choose a reason for hiding this comment

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

i wonder if rather than making this generic, we should have separate configs for metric_aggregation and pattern persistence.

I think we are overloading concepts here in a way that is a bit confusing and potentially harder to optimize in the future as we replace our storage (a different label identifier for these types would be important for handling them differently if we choose to in the future)

@@ -144,37 +144,37 @@ func Test_Push(t *testing.T) {

p.WriteEntry(
wayBack,
AggregatedMetricEntry(model.TimeFromUnix(wayBack.Unix()), 1, 1, "test_service", lbls1),
AggregatedMetricEntry(model.TimeFromUnix(wayBack.Unix()), 1, 1, lbls1),
Copy link
Collaborator

Choose a reason for hiding this comment

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

If this is re-usable between aggregated metrics and patterns, maybe a better name would be "MetricEntry"?

}

newLbls := labels.Labels{
labels.Label{Name: constants.AggregatedMetricLabel, Value: service},
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this should use a new label name, aggregated metrics and pattern persistence are quite different things and it feels wrong to me to store patterns in a stream called "aggregated metrics" also feels like it would be less performant at query time because you can't differentiate them when you query.

@trevorwhitney
Copy link
Collaborator Author

@slim-bean and I talked about his feedback. my motivation for putting these in the same stream as aggregated metrics was to co-locate as much of the aggregated data together as I could to hedge against having lots of really small chunks. given the move to dataobjs that is currently under way, however, @slim-bean pointed out this shouldn't be a problem for long, and the logical/naming separation is worth the trade off, so I'm moving forward with that refactor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants