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

[FeatureRequest] Variables - Add custom value for the "None" value #10651

Closed
kumaravel29 opened this issue Jan 29, 2018 · 4 comments
Closed

[FeatureRequest] Variables - Add custom value for the "None" value #10651

kumaravel29 opened this issue Jan 29, 2018 · 4 comments

Comments

@kumaravel29
Copy link

kumaravel29 commented Jan 29, 2018

The template variable returns a blank string in case of no possible output for a query, the Grafana makes a query to Elasticsearch is follows:
“query”:"ApplicationId:() AND Scope:()"
This leads to following exception in the elasticsaerch logs and on grafana console
{
_ “type”: “query_parsing_exception”,_
_ “reason”: “Failed to parse query [ApplicationId:() AND Scope:()]”,_
_ “index”: “appversiondetails”,_
_ “line”: 1,_
_ “col”: 213_
_ },_

The js file actually returns blank string in case of None or no output. Is it possible to handle this scenario or atleast provide a configuration where we can set some default value.
Currently to suppress such exceptions, I modify the js file.

Detail of the Issue
I was going through the Grafana Files for this issue and found the below code snippets in the boot.js file which plays an important role in the queries done to the elasticsearch:

return{text:“None”,value:"",isNone:!0}

AND

this.luceneFormat=function(n){return"string"==typeof n?t(n):"("+e.map(n,function(e){return’"’+t(e)+’"’}).join(" OR “)+”)"}

Possible Action
For rectifying this issue we can modify the JS file and define the queries that are fired to the ElasticSearch database.

return{text:“None”,value:“none”,isNone:!0}

AND

this.luceneFormat = function© {
if (“string” == typeof c) return a©;
var d = b.map(c, function(b) {
return ‘"’ + a(b) + ‘"’
});
if(d.length != 0) return “(” + d.join(" OR ") + “)”;
else return “none”;

Information:

Please help. I do not want to have a workaround for this issue because after upgrading Grafana I face the same issue and then need to do the fix again because of change in the boot.js.

@torkelo torkelo changed the title Elasticsearch parse_exception when Grafana template variable return blank string Template variable: Custom value for none value Jan 29, 2018
@ahurtaud
Copy link

ahurtaud commented Apr 2, 2019

Hello,
We have the same need but for a prometheus datasource.
I like the edit on the issue name. We could re-use the same code/UI as defining the "Custom All Value" for a "Custom None Value".

@spjspjspj
Copy link

Yeah, I agree it would be nice to be able to specify a few custom values that variable values could always include. Then it'd be easy to achieve this by just adding a custom value using special character that never appear in variable values.

@hugohaggmark hugohaggmark changed the title Template variable: Custom value for none value [FeatureRequest] Variables - Add custom value for the "None" value Nov 11, 2020
@hugohaggmark hugohaggmark added this to Needs triage in Platform Backlog via automation Nov 11, 2020
@hugohaggmark hugohaggmark moved this from Needs triage to Feature requests in Platform Backlog Nov 11, 2020
Copy link
Contributor

This issue has been automatically marked as stale because it has not had activity in the last year. It will be closed in 30 days if no further activity occurs. Please feel free to leave a comment if you believe the issue is still relevant. Thank you for your contributions!

@github-actions github-actions bot added the stale Issue with no recent activity label Jan 19, 2024
Copy link
Contributor

This issue has been automatically closed because it has not had any further activity in the last 30 days. Thank you for your contributions!

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants