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

Fix: Use dashboard time range in prometheus variable editor #78950

Merged
merged 1 commit into from
Dec 1, 2023

Conversation

itsmylife
Copy link
Contributor

What is this feature?

While using a non-default time range on a Prometheus dashboard, variable editor queries always end up being queries with the default time range. This was happening because 'languageProviderhad never received the time range. This PR makes surelanguageProvider` receives the right time range always.

Why do we need this feature?

A better variable support in Prometheus

Who is this feature for?

Prometheus users

Which issue(s) does this PR fix?:

Fixes #78947

Special notes for your reviewer:

How to test

  • Create a Prometheus dashboard
  • Set the time range as a non-default value like the last 2 days
  • Go to settings and add a new variable
  • Select label values type and select the metric
  • In the network tab observe that the label query payload
    • end - start is 6h which is the default time range
  • Switch to this branch and try again
  • Observe that the queries have the right time range

Please check that:

  • It works as expected from a user's perspective.
  • If this is a pre-GA feature, it is behind a feature toggle.
  • The docs are updated, and if this is a notable improvement, it's added to our What's New doc.

Copy link
Contributor

@bohandley bohandley left a comment

Choose a reason for hiding this comment

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

LGTM! 🚀

@itsmylife itsmylife merged commit 46044ef into main Dec 1, 2023
30 checks passed
@itsmylife itsmylife deleted the ismail/prom-variable-editor-time-range branch December 1, 2023 14:30
grafana-delivery-bot bot pushed a commit that referenced this pull request Dec 1, 2023
Use dashboard time range in variable editor

(cherry picked from commit 46044ef)
@aangelisc aangelisc modified the milestones: 10.3.x, 10.2.3 Dec 21, 2023
Copy link
Contributor

The backport to v10.2.x failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new branch
git switch --create backport-78950-to-v10.2.x origin/v10.2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x 46044efdf8592f88e59a6cc277a98370a446e9b7

When the conflicts are resolved, stage and commit the changes:

git add . && git cherry-pick --continue

If you have the GitHub CLI installed:

# Push the branch to GitHub:
git push --set-upstream origin backport-78950-to-v10.2.x
# Create the PR body template
PR_BODY=$(gh pr view 78950 --json body --template 'Backport 46044efdf8592f88e59a6cc277a98370a446e9b7 from #78950{{ "\n\n---\n\n" }}{{ index . "body" }}')
# Create the PR on GitHub
echo "${PR_BODY}" | gh pr create --title "[v10.2.x] Fix: Use dashboard time range in prometheus variable editor" --body-file - --label "type/bug" --label "datasource/Prometheus" --label "area/frontend" --label "add to changelog" --label "no-changelog" --label "backport" --base v10.2.x --milestone 10.2.x --web

Or, if you don't have the GitHub CLI installed (we recommend you install it!):

# Push the branch to GitHub:
git push --set-upstream origin backport-78950-to-v10.2.x

# Create a pull request where the `base` branch is `v10.2.x` and the `compare`/`head` branch is `backport-78950-to-v10.2.x`.

# Remove the local backport branch
git switch main
git branch -D backport-78950-to-v10.2.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
add to changelog area/frontend backport v10.2.x backport-failed Failed to generate backport PR. Please resolve conflicts and create one manually. datasource/Prometheus no-changelog Skip including change in changelog/release notes type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Prometheus variable editor doesn't get the dashboard time range and fallbacks to the default range
4 participants