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

legacy endpoint 400s metric queries #1541

Merged
merged 1 commit into from
Jan 17, 2020

Conversation

owen-d
Copy link
Member

@owen-d owen-d commented Jan 17, 2020

This fix short-circuits metric queries to the legacy /api/prom/query endpoint. Previously it would return 5xx status codes and now it 400s upon seeing metric queries. As a small optimization it doesn't actually run the query anymore either.

Examples

Allows regular log queries

$ curl -i http://localhost:3100/api/prom/query --data-urlencode 'query={job="jobba-the-hut"}'
HTTP/1.1 200 OK
Date: Fri, 17 Jan 2020 17:11:49 GMT
Content-Length: 15
Content-Type: text/plain; charset=utf-8

{"streams":[]}

Fails metric queries

$ curl -i http://localhost:3100/api/prom/query --data-urlencode 'query=sum(rate({job="jobba-the-hut"}[10m])) by (level)'
HTTP/1.1 400 Bad Request
Content-Type: text/plain; charset=utf-8
X-Content-Type-Options: nosniff
Date: Fri, 17 Jan 2020 17:09:32 GMT
Content-Length: 50

legacy endpoints only support streams result type

Copy link
Contributor

@cyriltovena cyriltovena left a comment

Choose a reason for hiding this comment

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

LGTM

@cstyan
Copy link
Contributor

cstyan commented Jan 17, 2020

👍

@cyriltovena cyriltovena merged commit 366e06f into grafana:master Jan 17, 2020
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.

/api/prom/query route incorrectly 500s when passed a metric query
3 participants