Grafana Singlestat: select with timerange - grafana

I am trying to use the SingleStat Plugin of Grafana to add an online/offline indicator to one of my dashboards.
So what I have so far is this with an influxdb datasource:
What I am missing is the option to define a timerange for this query. Lets say I want the count() of the last 30min. If the count is 0 I know that the server is offline. If the count is > 0 he is online. (For example my server adds a new entry every 20min. So if I don´t have an entry in the last 30min I know he must be offline)
So is it possible to get define a query with a timerange? When yes how ?
UPDATE
This is what I have so far now. But I get an error now which says a.form is undefined. Alos if I have a entry in the last 35min it doesnst switch to online.

The singlestat panel uses, by default, the timerange of the dashboard it is placed on.
For your case, make use of the 'override relative time' on the Time range tab and set it to "30m".
When using the count as you described, turn coloring on and set the threshold to 1. This will change the coloring when no entry is present (count is 0) in the last 30 minutes.

Related

Azure Devops Dashboards - How to chart the trend of query results over time based on work item history?

I want to be able to generate a stacked bar chart based on the results of a query, for example the number of open bugs and open features. I would like to see the resulting number of open bugs vs features from that query over a time period, for example the last 30 days. Specifically the number of bugs vs features that were open on that particular day, regardless of their current status. Is there a way to do this using an existing out of the box widget? I believe it should be possible to figure out this information using the history. Alternatively, is it possible to simply store the totals from the query somewhere in devops and then chart it? Or would I need to write a script to export the query results via the api and then use something like the power bi widget to chart it?
Sure, you can set up a chart of the query about the bugs and features opened in the last 30 days.
To meet this demand, you can do like as the steps below:
Set up a query with the following filter clauses. Save this query to the Shared Queries folder.
Work Item Type In Bug,Feature
State = [Any]
Created Date >= #StartOfDay('-30d')
On the Charts tab of the new query, create a new chart for the query like as below.
After saving the chart, add this chart to a specified dashboard in the project.
After above steps, navigate to the specified dashboard in the project, you can see the chart on the dashboard.
[UPDATE]
According to your latest reply, you want to get the Bug and Feature that were open state in the last 30 days. For these work items, we can think they satisfy one of the following conditions:
The work items were closed in the last 30 days, no matter what date they were created.
The work items are still open state currently. They do not have the closed date yet.
So, set up the query like as below should be able to match these work items.
Work Item Type In Bug,Feature
And State = [Any]
And Closed Date >= #StartOfDay('-30d')
Or Closed Date =
Group the last two clauses.
Then create the chart for the query.
Maybe the stacked chart would go some way to answering your problem.
https://learn.microsoft.com/en-us/azure/devops/report/dashboards/charts?toc=%2Fazure%2Fdevops%2Fboards%2Ftoc.json&bc=%2Fazure%2Fdevops%2Fboards%2Fbreadcrumb%2Ftoc.json&view=azure-devops#add-a-trend-chart
That produces charts with date as the x axis which, I think, is what you're looking for.

How to use the selected period of time in a query?

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.

What's $interval mean in Grafana?

After installed Heapster in my kubernetes cluster, I can access Grafana but the graph are empty.
I can build a new graph with special value, e.g. "cpu/limits"; but if the pre-defined graph used $interval, the graph can not display; for example,
SELECT mean(value) FROM "cpu/limit_gauge" WHERE "container_name" = 'machine' AND $timeFilter GROUP BY time($interval), "hostname"
https://grafana.com/docs/grafana/latest/variables/variable-types/add-interval-variable/
$interval is a built in automatic variable in grafana , and is automatically set based on time range
the graph are empty? maybe your query is wrong
For future readers -
I want to add that sometimes the "group-by" "fill" option, which is NULL by default, can cause no values to be displayed depending on the resolution.
If you have a query you think should work, but still see no data, try changing the fill value to another setting that you think works (ie: none) and see if data shows up.
Grafana tries to use that configuration to fill in for missing data, and occasionally, depending on your interval and data collection rate, you might end up with oddness.

Making a Histogram in Tableau

I work for a software company, and I am working with a database that tracks certain events that occur in one of our games. Every time one of the tracked events occurs, a text entry in the “Event Type” field specifies what kind of event it is – “User Login,” “Enemy Killed,” “Player Death,” etc. Another field, “Session ID,” assigns a unique ID number to each individual game session. So if a user logs in to the game, kills eight enemies, and then logs out again, each of those Enemy Killed events will have the same Session ID.
I’m trying to make a histogram showing the number of sessions that have x number of Enemy Killed events. How do I go about this? I’m a raw beginner at Tableau, so if you can dumb down your answer to the explain-like-I’m-five level that would be great.
Tableau 9.0 has been launched, and your problem can be solved entirely inside Tableau.
What you need is to understand the Level of Detail calculations. It will look like this:
{ FIXED [Session ID] : COUNT( IF [Event Type] = 'Enemy Killed'
THEN 1
END )
}
This will calculated how many kills each session had. You can create BINS with this field, and count how many sessions there are (COUNTD([Session ID]))
Well, my answer will echo with many of my last answers. Your database is not ready to do that analysis.
Basically what your database should look like is:
SessionId EnemiesKilled
1234 13
So you could create a histogram on EnemiesKilled.
To do the histograms, you can create BINs (right click on field, Create Bins), but I find it very limited, as it only creates BINS of the same width. What I usually do is a bunch of IF and ELSEIF to manually create the BINs, to better suit my purposes.
To convert your db to the format I explained, it's better if you can manipulate it outside Tableau and connect to it directly. If it's SQL, a GROUPBY Session ID, and COUNT of EnemyKilled Events should work (not exactly like this but that's the idea).
To do it on Tableau, you can drag SessionId (to either Marks or Rows, for this purpose of creating a table I usually put everything on Marks and choose Bar chart, so Tableau won't waste time plotting anything) and a calculated field like:
SUM(
IF EventType = "Enemy Killed"
THEN 1
ELSE 0
END
)
Then export the data to a csv or mdb and then connect to it

Default range for date range filter in tableau

I want to set the default range on a date filter to show me the last 10 days - so basically looking at the lastDate (max date) in the data and default filtering only on the last 10 days (maxDate - 10)
How it looks now:
I still would want to the see the entire range bar on the dashboard and give the user the ability to modify the selected range if he wants to. The maxDate changes after every data refresh so it has to be some sort of a condition that is applied to the filter.
How I want it to look (by default after every refresh of data - new dates coming in):
Any suggestions on how this can be done? I know I can use the relative date and show the data for last 10 days but that would modify the filter and create a drop down which I don't want.
Any suggestions are welcome!
One simple approach that does most of what you want is the following:
Create an integer valued parameter with a range from 1 to some max
you choose, say 100. Call it say num_days.
Show the parameter control on your dashboard as a slider, and give
it a nice title like "Number of days to display"
Create a boolean calculated field called Within_Day_Range defined as:
datediff('minute', [My_Date_Field], now()) < [num_days] * 24 * 60
Put Within_Day_Range on the filter shelf and select the value true.
This lets the user easily select how many days in the past to include, and works to the granularity of minutes (i.e. the last two days really means the last 48 hours, not starting at midnight yesterday). Adjust the calculated field if you want different behavior.
The main drawback of this approach as described so far is that it doesn't display the earliest date possible in the database because that is filtered out. Quick filters do an initial query to get the bounds, which has a performance cost -- so using the approach described here can avoid that query and thus load faster.
If you really need that information on your dashboard, you could create a different worksheet to get just the min([My_Date_Field]) and display that near your parameter control.