Grafana dashboard panel with custom time range - grafana

I have a Grafana dashboard with a time range for "today so far"
"time": {
"from": "now/d",
"to": "now"
}
But I have a service that runs only between 4am and 5am every day for which I would like to plot some metrics in a panel on this dashboard. I'm trying to set the time range for that panel to 4am-5am of the current day so that it doesn't show a full 24 hour x-axis for data that only exists between 4am and 5am. If I were able to specify the time range for the panel using From: and To:, it would have looked something like this:
"time": {
"from": "now/d+4h",
"to": "now/d-19h"
}
But of course, you can't specify a time range like that for individual panels. You have to make use of the Relative Time and Time Shift values in Query Options for the panel but, for the life of me, I can't figure out how to represent the time range I want in relative time using those two values. It would seem that Grafana's documentation in this regard is sorely lacking; They only show a few very basic and specific examples, none of which helps me with this query.
Would anyone be able to set me straight here please?
For what it's worth, my data source for this Grafana dashboard is Prometheus but I don't think that is germane to this question.

Related

Get the hours of a timestamp and display in grafana

For my Grafana panel i would like to extract and display the hours of a date from a given timestamp series
For example the timestamp 1628274040 which is 2021-08-06 18:20:40 (CET) i would like to only have "18:20:40" and display this comparable in my panel (display as graph).
How to do that? The underlying data is influxDB and the query is influxQL. I searched the grafana dashboard for converting function but dont find any.
I do not understand how you imagine to present this data in Grafan graph panel.
But I know that there is possibility to make it as a table with Datatable Panel Plugin by setting "Column Style" of "Time" as "HH:mm:ss".
It will allow you to present your data as a table with format exactly as you described.
Realisation example - image
This will return current date, like "24/05/22":
${__to:date:DD/MM/WW}
This will return Timestamp from today date, like "1653447599999":
${__to}

How to modify from and to values in grafana

I am having troubles understanding how the following works
from=now-1h&to=1568789063000
but when I do
from=1568789063000-1h&to=1568789063000 it doesn't work.
I have tried doing it directly in the URL, doesn't work.
from=1568789063000-1h&to=1568789063000 and from=1568789063000-2h&to=1568789063000 shows me the same time range on the graph whereas
from=now-1h&to=1568789063000 and from=now-2h&to=1568789063000 shows me different time range in the graph.
Additionally, I also tried manipulating this by using the option Data link in the visualization where I tried using
from=${__value_time}-1h&to=${__value_time} and I don't plan to use __url_time_range becasue I want custom time range around one point.
Can please anyone explain what I am doing wrong or what am I missing?
The Unix timestamps you're using (1568789063000) all translate to the same time. So doing from=1568789063000&to=1568789063000 doesn't return a valid period of time as
1568789063000 - 1568789063000 = 0
now-1h and now-2h will show different time ranges because you're telling Grafana to start the graph either at one or two hours before the time that you're making the render request, even if the to time is always the same
As for the issue using the absolute timestamp with a relative "offset" (1568789063000-1h), this isn't allowed. Instead you should subtract 3600000 from the starting (from) timestamp which equals 1568785463000. So, if you do from=1568785463000&to=1568789063000, it should work instead of from=1568789063000-1h&to=1568789063000.
Similarly for -2h, you should subtract 7200000: from=1568781863000&to=1568789063000.

Tableau, strange behavior for reference line

I'm attempting to show the results of an experiment. I'm using a calculated field and a parameter to create the following view, splitting the view by pre and post dates.
The trouble is the "Average" reference line...
None of the reference lines are placed at the actual Average for that time period (or any time period, from what I can tell). I know this because when I highlight the full date range the reference line adjusts:
Here's how I've set up the Average:
here's the calculation for post-reset (pre-reset is the same). [ reset-date ] is a hard coded parameter (the date the intervention began).
date( if [Friday Date] >= [reset-date]
then [Friday Date]
end)
Any idea what's going on here?
I was helped on the Tableau forum itself:
https://community.tableau.com/message/673000#673000
Instead of creating two date axis, I added one dimension to show pre and post.
See post at the link above for a full description, images, and a reference file.

Storing dates as nodes in Neo4j

I'm new to Neo4j so maybe I'm just completely wrong on this, but I'll give it a try!
Our data is mostly composed by reservations, users and facilities stored as nodes.
I need both to count the total reservations that occurred in a specific time frame and the overall income (stored as reservation.income) in this timeframe.
I was thinking to overcome the problem by creating the date as a node, in this way I can assign a relationship [:PURCHASED_ON] to all the reservations that occurred on a specific date.
As far as I've understood, creating the date as a node could give me a few pros:
I could split the date from dd/mm/yyyy and store them as integer properties, in this way I could use mathematical operators such as > and <
I could create a label for the node representing each month as a word
It should be easier to sum() the income on a day or a month
Basicly, I was thinking about doing something like this
CREATE (d:Day {name:01/11/2016 day: TOINT(01), month: TOINT(11), year: TOINT(2016)}
I have seen that a possible solution could be to create a node for every year, every month (1-12) and every day (1-31), but I think that would just complicate terribly the architecture of my Graph since every reservation has an "insert_date" (the day it's created) and then the official "reservation_date" (the day it's due).
Am I onto something here or is it just a waste of time? Thanks!
You may want to look at the GraphAware TimeTree library, as date handling is a complex thing, and this seems to be the logical conclusion of the direction you're going. The TimeTree also has support for finding events attached to your time tree between date ranges, at which point you can perform further operations (counting, summing of income, etc).
There are many date/time functions in the APOC plugin that you should take a look at.
As an example, you can use apoc.date.fields (incorrectly called by the obsolete name apoc.date.fieldsFormatted in the APOC doc) to get the year, month, day to put in your node:
WITH '01/11/2016' AS d
WITH apoc.date.fields(d, 'MM/dd/yyyy') AS f
CREATE (d:Day {name: d, day: f.days, month: f.month, year: f.years});
NOTE: The properties in the returned map have names that are oddly plural. I have submitted an issue requesting that the names be made singluar.

Kibana 4 not the good date in visualize menu

I have a problem with visualization of my data on Kibana 4. In discover menu I have the real date that I have insert, but in visualize menu it's not the same date.
This is my data :
{"index":{"_id":"1"}}
{"data1":912914,"date":"2015-01-01","title":"my-title","data2":2939186,"data3":226447}
{"index":{"_id":"2"}}
{"data1":910145,"date":"2015-01-02","title":"my-title","data2":2936572,"data3":225800}
{"index":{"_id":"3"}}
{"data1":917742,"date":"2015-01-03","title":"my-title","data2":2942237,"data3":226889}
{"index":{"_id":"4"}}
{"data1":911823,"date":"2015-01-04","title":"my-title","data2":2925900,"data3":230025}
And the result in discover menu :
This result is good with the good date, but now in visualize menu :
So, as you can see, on the second image the date is the date from the day before and note the real date as I want.
Someone can help me to resolve this problem?
Thanks in advance
Elasticsearch stores all dates in GMT.
When kibana displays dates, it displays them in your browsers local time (which appears to be offset from GMT by 1 hour).
If you put the times into ES with the correct time zone it may display them properly, but you have not specified how you are getting the data into ES. If it is with logstash, you could try adding a timezone parameter to your date filter.