Skip to content

feat: Add fanout latency metric for loki pipelines#5656

Closed
kalleep wants to merge 6 commits into
mainfrom
kalleep/loki-pipeline-write-latency
Closed

feat: Add fanout latency metric for loki pipelines#5656
kalleep wants to merge 6 commits into
mainfrom
kalleep/loki-pipeline-write-latency

Conversation

@kalleep
Copy link
Copy Markdown
Contributor

@kalleep kalleep commented Feb 25, 2026

Pull Request Details

Issue(s) fixed by this Pull Request

Notes to the Reviewer

PR Checklist

  • Documentation added
  • Tests updated
  • Config converters updated

Copy link
Copy Markdown
Contributor

@thampiotr thampiotr left a comment

Choose a reason for hiding this comment

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

Tests are missing.

wl := prometheus.NewHistogram(prometheus.HistogramOpts{
Name: "loki_fanout_latency",
Help: "Write latency for sending to components",
Buckets: []float64{.005, .01, .025, .05, .1, .25, .5, 1, 2.5, 5, 10, 30, 60},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we need all these buckets? I think we can do with fewer and still have a good idea of 'something is wrong' or 'everything looks fine'.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Absolutely, I just used the same bucktes we have for prometheus and pyroscope pipelines

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I changed buckets in f62e04f.

These would be able to measure potential throughput at 5k/s to 1/s but I am happy to adjust these more if you think we should do it

processIn: loki.NewLogsReceiver(),
receiver: loki.NewLogsReceiver(loki.WithComponentID(o.ID)),
fanout: loki.NewFanout(args.ForwardTo),
fanout: loki.NewFanout(args.ForwardTo, o.Registerer),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this registerer scoped to the component?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@kalleep
Copy link
Copy Markdown
Contributor Author

kalleep commented Feb 25, 2026

Tests are missing.

Well it's a draft, also need to update docs for each component using fanout to include this metric

@kalleep kalleep changed the title feat: Add fanout latency metric for loki fanout feat: Add fanout latency metric for loki pipelines Feb 26, 2026
@kalleep kalleep force-pushed the kalleep/loki-pipeline-write-latency branch from 0ee3f56 to b97898f Compare February 26, 2026 09:24
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 26, 2026

💻 Deploy preview deleted (feat: Add fanout latency metric for loki pipelines).

@kalleep kalleep marked this pull request as ready for review February 26, 2026 10:32
@kalleep kalleep requested review from a team and clayton-cornell as code owners February 26, 2026 10:32
@kalleep
Copy link
Copy Markdown
Contributor Author

kalleep commented Feb 26, 2026

Btw right now I just fixed existing tests that check metrics to ignore these, do you think we should have test for the metric itself?

Comment thread docs/sources/reference/components/loki/loki.process.md Outdated
@clayton-cornell clayton-cornell added the type/docs Docs Squad label across all Grafana Labs repos label Feb 26, 2026
Co-authored-by: Clayton Cornell <131809008+clayton-cornell@users.noreply.github.com>
@clayton-cornell
Copy link
Copy Markdown
Contributor

Docs changes are OK for now. Are there more changes incoming for docs?

@kalleep
Copy link
Copy Markdown
Contributor Author

kalleep commented Mar 4, 2026

Closing in favor of #5702

@kalleep kalleep closed this Mar 4, 2026
kalleep added a commit that referenced this pull request Mar 10, 2026
### Pull Request Details
Alternative to #5656.

In this pr I added `loki_write_entry_propagation_latency`. This is a
histogram with the time it takes from from a source until it's written
over the wire.

Every source now uses `loki.NewEntry` or `loki.NewEntryWithCreated`, and
multiline will propagate created from first entry.

When the entry was either sent or dropped by loki write we record the
time it took for all of them. I also added a new version for entries in
WAL so that the created time is encoded.


### Issue(s) fixed by this Pull Request

<!--
Uncomment the following line and fill in an issue number if you want a
GitHub
  issue to be closed automatically when this PR gets merged.
-->

<!-- Fixes #issue_id -->

### Notes to the Reviewer

<!-- Add any relevant notes for the reviewers and testers of this PR.
-->

### PR Checklist

<!-- Remove items that do not apply. For completed items, change [ ] to
[x]. -->

- [x] Documentation added
- [x] Tests updated
- [ ] Config converters updated

---------
Co-authored-by: Piotr <17101802+thampiotr@users.noreply.github.com>
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Mar 19, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

frozen-due-to-age type/docs Docs Squad label across all Grafana Labs repos

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants