How to display a table of results in Grafana - grafana

I have a query (using CloudWatch as a data source) that retrieves a dataset that includes a count of certain event types - fields x, y, z | stats count() by x
the result returned by the query (e.g. if I run the query in log insights):
x | count()
-------------
Foo | 16
Bar | 3
(So the aggregation of stats is run in CW Logs). I want to represent this in Grafana in the same way it is shown above, but when I use the query with a table panel, the results are populated into a drop-down selector, and the table only shows 1 row - e.g. Foo 16 and I need to select which row I want to display in the table.
What is the best way to show all results? I'm not sure whether I should be leaving the stats function off the data query and doing the aggregation / count on Grafana side, or if I am using the wrong panel type / visualation and the query is right (looking on which approach would be best here if both are possible).
thanks in advance.

I encountered this same issue with Grafana 7.0.0.
When parsing an arrayed query response using the Grafana "Table" visualization, the drop-down result selector is a feature of the v7+ versions. The Grafana Explore functions apparently use the older table visualization, which is bundled in V7 versions as "table-old". The table-old visualization should return all query results as rows in the table, without a selector.

It is also possible to click on "Inspect" and then click on the JSON tab.
remove the below field from the JSON:
"statsGroups": [
...
]
NOTE 1: it is sometimes annoying that when editing the panel it is added back automatically
UPDATE
A more clean solution (but sometimes limiting) is to use the "Merge" transformation

Related

How to filter prometheus series based on the results of another query in grafana dashboard?

I am using Grafana 9.3.1 for monitoring of our system. Among other things, I am trying to monitor the remaining FUP of a phone number for each unit we operate.
Basically, we intend to use two data sources.
Database mapping of the unit ID to its phone number (e.g. "unit_id=123, phone_number="00 123456789")
Prometheus time series remaining_fup{phone_number="00 123456789"}. However, remaining_fup is a 3rd party data and does not include unit_id.
In my unit-detail dashboard I have unit_id variable which indicates which unit FUP should be displayed (among other things depending on unit_id)
My original approach was this:
Create a mixed datasource dashboard
Add database datasource as data A. SELECT phone_number FROM units WHERE unit_id='$unit_id'
Add prometheus datasource remaining_fup and filter it based on A.phone_number: remaining_fup{phone_number="${A.phone_number}"}
Unfortunatelly such use of A isn't supported. I used to hope for applying some transformation like Merge or Join by field and then Filter but with no success. After a lot of googling and trying I feel hopeless.
Could you help please? Is such filter even possible? Thanks!
TL;DR: In grafana dashboard I want to query one datasource in order to obtain a value which I subsequently want to use in another datasource query.
1.) Create variable - name phone_number, type: Query and query your database datasource SELECT phone_number FROM units WHERE unit_id='$unit_id'. You can hide this variable if you don't want it to be visible for the dashboard users.
2.) Variable phone_number may have multiple values, so use advance variable formatting to create valid regex query syntax for your prometheus datasource, e.g.
remaining_fup{phone_number=~"${phone_number:pipe}"}
Of course this queries are just examples and they may need some (syntax) tweaking for the use case. Main idea: don't use 2 queries, but one variable and one query (where you use that variable).

Is there any way to enable/disable log queries in Grafana based on a multi-variable?

I have a Grafana dashboard with a Logs panel. The panel has 3 separate queries: A, B & C. Each query filters the log data in a different way and displays the results in a different way. Having all 3 queries in the same panel rather than in separate panels is helpful because the results get displayed chronologically in relation to each other. By default I have A & B enabled, with C disabled.
I would like to be able to toggle each one on/off by selecting options from a variable drop-down instead of having to "Edit" or "Explore" the log panel, but can't quite work out how to do that.
So far, I have created a custom multi-select variable called LogTypes which can have any combination of the values Verbose, Messages & Errors. I initially (naively) tried changing the start of query A from:
{app="$app"}
to:
{app="$app", "Messages"=~"$LogTypes"}
to essentially try to only "enable" query "A" when Messages was selected as a Log Type, but it seems that LogQL expects "Messages" to be an identifier rather than a string. Is there another way to compare a constant string to a variable string in order to turn the query on/off like this?
Alternatively, is there some other functionality that I should potentially be looking at to achieve the same result?

Prometheus QL get the first values from the query result

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.

How to filter dashboard based on quick filter values selected in Tableau ?

I'm having Dashboard-1 with the data source from SQL Server Table-A having columns
Col1,Col2,Col3
Now, i'm creating a new dashboard-2 with data source as Table-B having columns Col1,Col4,Col5.
But Col1 which is common in both these tables doesn't have common data.
Eg. Col1 from Table-A is having records till 100 and Table-B is having records from 101.Also, the data is not static, its keeps on increasing in Table-B , Table-A is no longer populating but we need the data from it.
Problem1-- How to merge two column as single column for filter in Tableau
Problem2-- in the dashboard i need to show single filter as a union of Col1 from both tables, if user select value <100 then Dashboard-1 will open otherwise Dashboard-2.
Can someone provide me a correct approach.
1) Instead of merging after you have brought the data in, try merging the data using SQL UNION.
2) If that's not possible, do the same after importing both the datasets into Tableau. For an example, try from this official link
3) Try different Joins to see which one works for merging your table columns:
4) If all the above fails, try setting up an Action Filter explained in this link. Essentially you have to use Tiled Containers instead of Floating Containers and set up a action filter using a custom Parameter. This custom Parameter will help display Dashboard 1 when user selects <100 in the filter(for example) and Dashboard 2 when user selects >100(again example)

Pentaho CDE - how to build a chart from an SQL query JDBC

I'm trying to understand the logic of Pentaho CDE
My goal is to have a bar chart from a PostgreSQL materialized view (3 columns: geo_name, cat_name, cat_value) (I don't need to go through OLAP cubes for the moment)
So at first I define on the Layout panel one row containing one column (name: col1)
I connect to my datasource via Datasources panel like this :
Query : select * from my_schema.my_materialized_view;
Then in the Components panel, I create a 'CCC bar chart' by filling in my datasource and the HTML object correctly but I don't understand where I can define the X, Y and value columns (as in Pentaho Report Designer)?
The Listeners property does not offer me anything.
In preview I get an 'Error processing component', how do I know if my data source is connected?
Thank you !
EDIT SOLUTION
Finally it was a driver problem, we must check that the driver JDBC PostgreSQL is present here: .../tomcat/webapps/pentaho/WEB-INF/lib (in my case the driver postgresql- 9.3-1102-jdbc4.jar)
And then on Pentaho CDE, in the sql over sqljdbc data source I put 'postgresql-9.3-1102-jdbc4.jar' in the Driver property and it works!
Then you have to play with the query according to the type of chart and actually don't SELECT * FROM table
CCC charts by defaults takes first column on x axis and second column on y AXIS. Now this may be varies if you select crosstab property. If you want to change the axes as you want then you can select do it in post execution event of the ccc chart by setting properties.
Now for the data source connection, you can debug it through inspect the dashboard page and in Network you will see the cda query. also if it errors out then you can check it in console tab as well.
Another option is to check server/tomcat/logs directory you can verify pentaho.log and catlina.log for more information about the server behavior.