wondering if someone can help me with this.
I want to have a select query that returns a boolean based on two different fields. For example
SELECT (sum("value_1")=count("value_2")) as test FROM "measurement"
would like this to return true or false, but can't seem to get it to work. I would like to use this as a singlestat in grafana. Any ideas?
Thanks
Related
i'm running show pool_nodes and it's work. What if i want to return just the 4th column(status), using only query. It is possible ? Thanks
If you are using pgpool-admin extension, then you can use SQL queries.
SELECT status FROM pcp_node_info()
Here is the documentation reference:
https://www.pgpool.net/docs/latest/en/html/pgpool-adm.html
I'm utilizing Grafana with InfluxDB as the database.
Say I have the following query
SELECT MIN("field_1"), MAX("field_1") FROM "measurement" WHERE $timeFilter
but I would like the user the ability to view the MEAN in the same panel instead
SELECT MEAN("field_1") FROM "measurement" WHERE $timeFilter
Is there a way to accomplish this? Ideally the solution would be agnostic to field_1 as I'd like to use it across multiple panels with different fields.
Create Grafana dashboard variable e.g. function with values, which match InfluxDB functions: MIN,MAX,MEAN,COUNT,LAST,... and then use that variable in the Grafana InfluxDB query:
SELECT ${function:raw}("field_1") FROM "measurement" WHERE $timeFilter
so Grafana generates correct InfluxDB query syntax.
Even field can be dashboard variable, which can be automatically discovered with InfluxDB query SHOW FIELD KEYS.
I write the query below to get the up time for the microvices.
base_jvm_uptime_seconds{kubernetes_name="namepspce1"}
However, it returns multiple values, so the grafana returns "Only queries that return single series/table is supported". I am wondering how can I the first velus from the query result?
I tried base_jvm_uptime_seconds{kubernetes_name="namepspce1"}[0], but it doesn't work..
Thanks!
I suggest you first inspect the label values of these multiple time series by running the query in Prometheus Graph console.
The you'll need to decide which one you want to display. Random first usually isn't the best idea.
But you can always do topk(1,query) if it helps. Just turn the Instant mode on in the Grafana Query editor.
I feel like I'm trying to do something incredibly simple, but I just can't find any cogent explanation anywhere on the internet after an hour of searching.
I'm using InfluxDB/Grafana and I have a DB with several tables. My tables have a tag key named "host" so that I can tell which server the data is coming from.
I want to create a dropdown on my dashboard so that I can select which host's data is displaying on the panels. Is there any way to do this?
Create dashboard variable from the query
SHOW TAG VALUES WITH KEY = "host"
and use it in the panel query. It is documented in the Grafana doc:
https://grafana.com/docs/grafana/latest/features/datasources/influxdb/#templating
i am working on aem 6.3 and would like to get page name
SELECT * FROM [cq:Page] WHERE ISDESCENDANTNODE("/content/Product/Silhouettes/Accessories/Bands/Headband")
If I need to retrieve name of the nodes using sql-2 , how do I achieve it?
You can specify column constraints like title, node name, etc this way -
SELECT nodeSet.name, nodeset.title
FROM [cq:Page] AS nodeSet
WHERE ISDESCENDANTNODE("/content/Product/Silhouettes/Accessories/Bands/Headband")
Note: the query tool in AEM(Tools -> Query) will not list the query results according to the columns you've mentioned, it will only list the node paths.
You can look at using /etc/importers/bulkeditor.html or AEM fiddle tool to visualize the query results based on column constraints.
If you want to achieve this programmatically, you can use the same query as you've mentioned in your question and use javax.jcr.query.* and javax.jcr.Node.* API's to retrieve just about any property from the query result. This article here should help you achieve this programatically.
Use the ResourceResolver API to execute and obtain the query results:
final Iterator<Resource> pagesIterator = resolver.findResources('<your_query_here>', javax.jcr.query.Query.JCR_SQL2);
while (pagesIterator.hasNext()) {
final Resource pageResource = pagesIterator.next();
LOG.info(pageResource.getName());
}
However, please note that if you are using any version higher then CQ 5.6, you should use instead the Page API.
In this case, the listChildren(Filter<Page> filter, boolean deep) method will do the job.
The PageFilter parameter may be used if you want to filter through pages of some kind. So if no extra criteria for your page finding algorithm, your may pass null or a new empty object.
The boolean parameter: if false it returns only direct child pages, and if true would list all the descendant pages of the given page.
Therefore, the equivalent solution of the SQL Query which would provide you the same end results would be:
Iterator<Page> rootPageIterator = rootPage.listChildren(null, true);