Running below query in prometheus produces results, How can I (is it possible to) create a templating variable in Grafana using similar query with label_values ?
group by (label_application_service_name) (kube_namespace_labels)
Something like
label_values(groupby (label_application_service_name) (kube_namespace_labels), ServiceName)
Thanks in Advance.
Related
In grafana documentation there is information about global variables, but when i try using them in my query (I am using mysql database), they don't get translated. Why is that?
An example:
For query
SELECT
'$__dashboard'
Gives in generated query:
SELECT
'$__dashboard'
But when I do select on variable defined by myself in the editor it works just fine.
I have a simple Custom variable called route with e.g. this value:
/foo/bar,/foo/baz,/foo/baz/foo
I'm trying to map these values to some more understandable values, e.g. Custom route_names:
bar,baz,foo
Searching on google resulted in people doing nested variables, but whatever I try in Grafana 5.3.4, I can't get it to work. If I do a Query variable and use -- Grafana -- as source, I don't know what to put in the query field. route.* didn't do anything, $route neither.
What is the correct way of selecting a value from one variable and map it to the other? I.e. What is the query language being used when selecting -- Grafana -- as datasource?
As a side note, I have two datasources at the moment, my actual data source where I get my graph data from and -- Grafana --.
There are correct answers on the first floor. solve "key/value pairs" by SELECT 'txt1' AS __text, 'value1' AS __value UNION SELECT 'txt2' AS __text, 'value2' AS __value
This is not possible with Custom template variables (unless smth changed in recent Grafana versions). It can be done with variables coming from mysql, postgres and clickhouse datasource queries. See examples in https://community.grafana.com/t/key-value-style-for-custom-template-variable-configuration-and-usage/3109 thread. Can't tell about this feature support in other datasource types.
I have created a transformation in Pentaho Kettle where I am pulling some data from Mongo Collection, via Mongo Input, but the problem I am facing is I have created two named parameters in the same transformation and they are not being replaced in Mongo Query Expression Tab. Below is my mongo query expression:
{$and:[{'key1':{'$in':['${para1}']}},{'key2':{'$in':['${para2}']}}]}
Below are the two options I have tried from command line:
./pan.sh -file='/dir../pull_data.ktr' -param:para1=hello -param:para2=world -Level=Basic > /dir../etl.log
./pan.sh -file='/dir../pull_data.ktr' -param:"para1=hello" -param:"para2=world" -Level=Basic > /dir../etl.log
I am using Mac OSX and Pentaho Kettle (CE 5.2). Is it possible to use named parameters in the same transformation?
Use ./pan.sh -file='/dir../pull_data.ktr' -listparam to make sure you declared your parameters in the transformation settings.
Variable substitution inside of the JSON query should work AFAICS in the source code.
I'm writing a Dropwizard app that needs to connect to the database, and using SQL objects to query the DB, per the Dropwizard docs.
The issue I'm running into is when my query is using a type specifier (::) being confused for a binding variable. Something like
SELECT
(a,
b,
c)::user_type
FROM ...
WHERE id = :id
The parser is reading ::user_type as a parameter placeholder. When I've escaped them with \, it says the query is not returning any rows, but if I run the query through psql, it does, so I'm guessing it's not so simple. Any help would be appreciated.
Thanks! :D
The easiest solution is to just use the SQL-standard CAST syntax not the PostgreSQL extension :: syntax.
CAST (c AS user_type)
I am using Rogue/Lift Mongo record to query MongoDb. I am trying to create different query according to the sort field name. I have therefore a string name of the field that I want to use to sort the results.
I have tried to use Record.fieldByName in OrderAsc:
...query.orderAsc (elem => elem.fieldByName(columnName).open_!)
but I obtain "no type parameter for orderAsc".
How can I make it working? Honestly all the type programming in Rogue is quite difficult to follow.
Thanks
The problem is that you cannot dynamically generate a query with Rogue easily. As solution I used Lift Mongo Db that allows the usage of strings (without compile checking) for these kind of operations that requires dynamic sorting.