I created a SQL query that counts the number of servers running test jobs on a specific Jenkins server at a specified time. I'm trying to chart it on Grafana but for some reason, it's displaying the value as NaN.
The data source is a MySQL server. I'm running Grafana version 8.1.5. I went on the server (phpMyAdmin) to check the results of the query and I can see numbers.
When we look at the grafana chart/panel, the bars on the chart look like it matches the values, but the chart shows NaN instead of the value.
What setting do I need to change so that it can print the numeric value on the chart instead of displaying NaN?
EDIT: Looks like I didn't include enough info to my question.
Here's the query that's used, although, I don't know how feasible it is to include the tables with data to demo the issue:
SELECT COUNT(DISTINCT(tb_name)) as val, jenkins FROM (
SELECT
hw.collected_date AS mytime,
hw.jenkins AS jenkins,
hw.name AS tb_name
FROM hw_report as hw LEFT OUTER JOIN jenkins_owner jo
ON hw.jenkins = jo.jenkins
WHERE jo.org IN ('Enterprise Readiness')) as y
WHERE mytime = '2021-12-03 00:00:00'
GROUP BY jenkins
HAVING count(distinct(tb_name)) > '0'
Here are screenshots of my panel. The "Show values" setting is set to "Always", which II assume should show the values.
One thing I noticed is when I hover over the bar, it shows
COUNT(DISTINCT(name_cnt))
instead of a numeric value. Not sure if this is indicative of anything. I checked other charts in the dashboard that someone created and their bars either have a numeric value or it's just a column name (like name_cnt)
Sorry I'm a noob and didn't know what to configure, look up, or mention in my question. I accidentally came across the answer.
So it seems like I need to select something under the "Transform" tab for the panel. Calculation needs to be "Total" instead of "Count" and I need to hide the fields specified in my SQL query and show the "Total"
Related
I use grafana to plot timeseries data. In a timeseries plot i want to add a constant line which comes from a monitoring level. The value of that level is dynamic (from a postgres database) the timeseries come from a ifluxdb Datasource.
The monitoring level have no timestamp. The result should look like this:
I have searched quite a while how to do this, but not found a good explanation.
You can now add thresholds (bottom of the edit screen).
Each threshold can be represented as a solid line and/or region with individual color
Another way to do it in a dirty way is to create panel with a mixed data source.
Create your variable in grafana - it can be a query, constant or custom. Just remember to keep it a single floating point.
Add your original query and add the prometheus data source to query your variable.
${net_ordered_storage}
You will have to play a little bit with the number of data points displayed (query options>max data points) and minimum step of data point in prometheus query to make grafana connect dots.
Green horizontal line from variable
To draw a line like that you have to "fake" a timeseries. (thresholds don't work since they can not be dynamic as far as I know)
First thing to keep in mind is that grafana needs timestamp to plot it, for this reason the global variables ${__to} and ${__from} come in handy.
Then, to draw a line, grafana needs at least two points. ([t0, t1][y0, y1])
So this is the sql (postgre) query that lead to the desired result:
SELECT
${__from} AS time,
level_1,
FROM my_table where display_name = '${my_grafana_var:raw}'
union all
SELECT
${__to} AS time,
level_1,
FROM my_table where display_name = '${my_grafana_var:raw}';
It is possible to add dynamic thresholds using the Config from query option.
Add a new query below your standard metric query. This will likely be called B.
Here you query the static reference value.
Eg SELECT expected_number_of_widgets FROM baseline
Open Transformation tab
Find Configuration from Query results
Choose Config query = B
At the dropdown for expected_number_of_widgets, choose Use as: Threshold1.
In the right panel, under Thresholds, make sure Show Tresholds is enabled and remove the default threshold of 80.
For more details, see https://grafana.com/docs/grafana/latest/panels-visualizations/query-transform-data/transform-data/#config-from-query-results
I will start of by saying that I'm new to Grafana.
I have a database table that is being updated externally that has say 15 columns of information on a given set of servers. I'm just trying to display the server name and current status and change the color of the row based on that status (Norm, Alert, Down) ... ideally those would be links to a detail page.
I tried the included table display which looks like it should handle it but the coloring options don't seem to work based on plain dumb text in a column or it would be perfect because it says it will color by row and includes the ability to make each row a link essentially.
grafana screen shot
I have tried with and without quotes in the Threshold values. It says in the hover help you can use comma separated values but does not seem to work for me. (I am thinking it's my config or usage btw)
Every other plugin I can find that says it wants to do this errors out when I tell it I have a table of data and not some live feed.
I need to create a dashboard to be used in a control room, where a bunch of operators will need to monitor the number of tasks assigned to other employees (among other aspects).
Source data will be coming from a RDBMs (PostgreSQL, in this case). We have people with assigned and numbered tasks that also have a status, and the DB data is like this (purely fictional: but it resembles the real one)
Having to create and mantain a dashboard i was thinking to use tools like Grafana, Kibana or similars, to plot something like this
The problem is that Grafana, for example, doesn't let me use alphabetical values for the x-axis. It only allow numeric values, while i've names to plot (Mark, Luke, Brian).
Is there a best practice than i can follow? Am i trying to use the wrong tools?
Actually solution is easier then you think although it also took me some time to figure it out. I will place here an example for some unspecified shop data grouped over countries - you just need to change it for your task. Example was tested on Grafana 5.0.3
PostgreSQL query for metrics
SELECT
$__time( partition_date ),
country as metric,
sum(value) as value
FROM
aggregations.my_data_for_dashboard
WHERE
shop = 'myshopname' AND
$__timeFilter(partition_date )
group by 1, 2
Grafana will show usual metrics:
In "Axes" tab look at "X-Axis" section, item "Mode" - switch "Time" to "Series" and Grafana will show bar chart for countries.
I'm using Grafana with Prometheus and I'd like to build a query that depends on the selected period of time selected in the upper right corner of the screen.
Is there any variable (or something like that) to use in the query field?
In other words, If I select 24hs I'd like to use that data in the query.
There are two ways that I know:
You can use the $__interval variable like this:
increase(http_requests_total[$__interval])
There is a drawback that the $__interval variable's value is adjusted by resolution of the graph, but this may also be helpful in some situations.
This approach should fit your case better:
Go to Dashboard's Templating settings, create new variable with the type of Interval. Enable "Auto Option", adjust "Step count" to be equal 1. Then ensure that the "auto" is selected in corresponding drop-down list at the top of the dashboard.
Let's assume you name it timeRange, then the query will look like this:
increase(http_requests_total[$timeRange])
This variable will not be adjusted by graph resolution and if you select "Last 10 hours" its value will be 10h.
If you are looking at using prometheus as data source, $__range supports your dashboard time is great.
increase(gin_total_requests[$__range])
Why create your variable when you can use inbuilt Global variable.
I have added links to documentations to back up my answer
Grafana 5.3+
count_over_time({job="gerrit-sshd"}[$__interval])
It works for me and what's more, you should set Max data point as 1 ,in query option.
Then the $__interval is the same Time-Range from the Panel on Grafana top right corner.
I have a parameter and a calculated field
Parameter - "Hierarchy" (which is a string - '1', '2', '3')
Calculated Field - "Division" (which is based on the Hierarchy chosen)
Case 1 display '' (nothing)
Case 2 and 3 show Dimension A
My question - when I select a value 'X' from Division, when the parameter is set to 2 or 3. The value 'X' remains, when I switch to 1. I would like this to default to the 'All' values.
I don't have data for 'X' at level 1 hierarchy. So, my graphs shows nothing, which isn't good.
Does anyone know how to script this to default to 'All' when I revert selection to '1' (and I don't mean the string 'All', I mean the ALL values selection used in filtering.
Thanks,
gemmo
Assuming you are using quick filters, try setting your quick filter to display "Only Relevant Values" instead of "All Values in Database". I think that's the default setting, so that's likely not the complete solution to your problem -- but its something you can check quickly before diving deeper.
Another thing to check - what data source are you using? Some data sources have limitations, in particular, the MS Jet engine used for MS Access, Excel and text files apparently doesn't handle sets in filters (among other limitations). Tableau announced at their 2013 customer conference that they planned to replace the Microsoft Jet Engine in Tableau 8.2 (again -- I'm not sure that's your issue here)
I don't think tableau have this level of programmability. In short - can't be done at the moment. Research didnt bear any fruit
I was able to do this but it took an extra calculated field to make it work. Inside your parameter add the Value "All" and Display as "All".
Then create a calculated field with a case statement that returns 'All' for every value in your field's set. Something like this for you:
CASE Parameter
WHEN 1 THEN 'All'
WHEN 2 THEN 'All'
WHEN 3 THEN 'All'
END
I named it _All. Then add to or create a T|F calculated field to add to your filter pane. Add this to the field.
[_All] = [Parameter]
You should see then be able to select "All" in your parameter control and have it show all values.