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

Loki: Add feature flag to enable dataplane-compliant metric frames #66017

Merged
merged 2 commits into from
Apr 13, 2023

Conversation

gabor
Copy link
Contributor

@gabor gabor commented Apr 5, 2023

this PR adds a feature-flag that makes Loki's responses to metric queries compliant with the dataplane-spec's time series multi and numeric multi formats.

(similar PR happened to Prometheus in #62694)

this means the following changes:

  • the Frame.Name field is not used anymore
  • for "vector" data (numbers for a single timestamp), the Frame.Meta.Type field changes from timeseries-multi to numeric-multi.

we do not expect many backward-compatibility issues with this change, but for now it is opt-in thing controlled by the feature-flag.

we are running the snapshot-tests twice, both for the flag being enabled and also for the flag being disabled

when reading the diff, the real changes are in the tsdb/loki part, the rest is adding a feature-flag, and adding more snapshot-tests (because now we need to cover both flag-enabled and flag-disabled cases).

if anyone has any idea how to do this in an easier way, i'm listening 👍 .

how to test:

  1. enable the feature-flag lokiMetricDataplane
  2. go to explore, run a metric LogQL query, make sure the graph you see looks ok
  3. repeat the same in a dashboard
  4. now disable the feature-flag lokiMetricDataplane
  5. repeat the tests from [2] and [3]

@grafanabot grafanabot added datasource/Loki type/docs Flags the technical writing team for documentation support; auto adds to org-wide docs project area/frontend area/backend labels Apr 5, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Apr 5, 2023

Backend code coverage report for PR #66017

Plugin Main PR Difference
loki 58.4% 58.4% 0%

@github-actions
Copy link
Contributor

github-actions bot commented Apr 5, 2023

Frontend code coverage report for PR #66017
No changes

@github-advanced-security
Copy link

You have successfully added a new CodeQL configuration .github/workflows/pr-codeql-analysis-javascript.yml:analyze. As part of the setup process, we have scanned this repository and found no existing alerts. In the future, you will see all code scanning alerts on the repository Security tab.

@gabor gabor force-pushed the gabor/loki-metric-dataplane branch from 6808620 to bef1a1b Compare April 11, 2023 11:00
@gabor gabor changed the title loki: add feature flag to enable dataplane-compatible metric frames Loki: add feature flag to enable dataplane-compatible metric frames Apr 11, 2023
@gabor gabor added add to changelog no-backport Skip backport of PR labels Apr 11, 2023
@gabor gabor changed the title Loki: add feature flag to enable dataplane-compatible metric frames Loki: add feature flag to enable dataplane-compliant metric frames Apr 11, 2023
@gabor gabor requested review from a team, svennergr and matyax April 11, 2023 11:09
@gabor gabor marked this pull request as ready for review April 11, 2023 11:09
@gabor gabor requested review from a team and chri2547 as code owners April 11, 2023 11:09
@gabor gabor requested review from joshhunt, ashharrison90, academo, zserge, mildwonkey and yangkb09 and removed request for a team April 11, 2023 11:09
@gabor gabor added this to the 10.0.0 milestone Apr 11, 2023
@gabor gabor force-pushed the gabor/loki-metric-dataplane branch from bef1a1b to 0ff547c Compare April 11, 2023 12:39
// 🌟 This was machine generated. Do not edit. 🌟
{
"status": 200
}
Copy link
Contributor

Choose a reason for hiding this comment

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

If "empty" means "no data" in Grafana terms here, it can be returned as a single frame with no fields. This way metadata can still be passed. In particular, the executed query string (if using macros, can help to see what happened to result in no data if unexpected). https://github.com/grafana/grafana-plugin-sdk-go/blob/main/data/contract_docs/contract.md#no-data-and-empty

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for the tip. i'll check what to modify to achieve this 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh, i see prom adds an empty-frame if converter/prom.go returns zero frames:

// Add frame to attach metadata
if len(r.Frames) == 0 && !q.ExemplarQuery {
r.Frames = append(r.Frames, data.NewFrame(""))
}

i'll do the same for Loki too (in a separate PR, not to complicate things here)

@gabor gabor force-pushed the gabor/loki-metric-dataplane branch from 0ff547c to 23dead6 Compare April 13, 2023 07:16
@gabor gabor force-pushed the gabor/loki-metric-dataplane branch from 23dead6 to c19256b Compare April 13, 2023 07:17
@gabor gabor changed the title Loki: add feature flag to enable dataplane-compliant metric frames Loki: Add feature flag to enable dataplane-compliant metric frames Apr 13, 2023
@gabor gabor merged commit 531caec into main Apr 13, 2023
@gabor gabor deleted the gabor/loki-metric-dataplane branch April 13, 2023 13:07
@zerok zerok modified the milestones: 10.0.0, 10.0.0-preview May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
add to changelog area/backend area/frontend datasource/Loki no-backport Skip backport of PR type/docs Flags the technical writing team for documentation support; auto adds to org-wide docs project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants