I have a long query which is about 70 lines in Postgres and I created view of it in PGadmin to use it whenever need.
Now, I want to create dashboard of that view in Grafana, I think it is not good idea to past all queries in Grafana SQLEditor and also because I need to include Grafana variables into query (to filter result of query) can not just select from Postgres view
is there any solution?
Related
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).
I have enabled Query Performance Insights, however, the Query Text fields are left empty, as you can see from the screenshot below.
I have enabled the Query Store as described in the documentation, everything else has been left to its default values.
pg_qs.query_capture_mode is set to TOP
pgms_wait_sampling.query_capture_mode is set to ALL
If I query the query_store.qs_view or pgms_wait_sampling_view data is returned.
SELECT * FROM query_store.qs_view;
SELECT * FROM query_store.pgms_wait_sampling_view;
Also the column qs_view.query_sql_text contains SQL statements, as well as the query_texts_view. Any idea why its not showing up in the UI?
In the portal page of your Azure Database for PostgreSQL server, select Query performance Insight under the Intelligent Performance section of the menu bar. Query Text is no longer supported is shown. However, the query text can still be viewed by connecting to azure_sys and querying 'query_store.query_texts_view'.
https://learn.microsoft.com/en-us/azure/postgresql/concepts-query-performance-insight
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 am using Apache drill in embedded mode and when I am able to connect to mongo and query in drill successfully.
However when I create a schema in saiku schema designer using driver as "org.apache.drill.jdbc.Driver" and URL as "jdbc:drill:drillbit=hostname:31010" the connection is successful and all collections are also fetched and shown as tables in saiku, but in place of column names "*" is coming and actual column names are not coming.
Dont know what I am missing on.
I figured out the solution and posting in case anyone could benefit. I had created a view in drill with select * from table. When I created view as select col1,col2... from table the issue got resolved.
I'm trying to setup some custom monitoring for postgres and one of the metrics I want to see is the index usage from pg_stat_user_indexes. I have multiple databases, each of them have indexes and I want a single metrics role that has access to all of them.
The problem is that when I select * from pg_stat_user_indexes using the metrics role I see no results. But if I select with the individual database role I see the stats just fine.
The metrics role is a superuser with Bypass RLS. I tried looking at pg_stat_all_indexes but I can see only pg_* stuff.
https://www.postgresql.org/docs/current/static/monitoring-stats.html#pg-stat-all-indexes-view
The pg_stat_all_indexes view will contain one row for each index in
the current database, showing statistics about accesses to that
specific index. The pg_stat_user_indexes and pg_stat_sys_indexes views
contain the same information, but filtered to only show user and
system indexes respectively.
emphasis mine
Seems like you need to be connected to the specific database you want to monitor (not to postgres db) in order to see those stats.
Bizarre.. would have at least expected to see them all in pg_stat_all_indexes - it should have been named pg_stat_all_indexes_for_current_database_plus_pg_catalog - I know.. but pg_stat_all_indexes is not all indexes at all..