How do I query InfluxDB to show me current time and date? - time

I couldn't find much documentation on this. How do I query InfluxDB to show me current database system time and date?

SHOW DIAGNOSTICS will do it, if you're an admin.
If you're not an admin, you can cheat:
precision rfc3339
INSERT foo,dummy_tag="time_test" testval=0i
SELECT last(*) FROM foo
Which is a bit awkward. This might deserve a feature request on their github page: https://github.com/influxdata/influxdb/issues

Another possibility is to look at the HTTP-header of any response from the influx server. It contains a "Date" field. However, the HTTP-date field only has seconds precision.

Related

Grafana elasticsearch time from now

I've configured Grafana to use Elasticsearch as a data source and prepared a few panels.
My document in ES index contains only a few fields. It describes some system actions, respectively there are such fields as userId, action date, and others.
Now I faced with the issue that I can't calculate the amount of time left when the action happened. I mean if the action happened 2 days ago, I need to have the number 2 in my table. Pretty simple I supposed.
I couldn't find any metric or transformation that can allow me to do it.
Any suggestion, help, please.
Resolved my issue with scripted field.
In table visualization, I just picked any numeric field, selected Min metric, and added script like next:
Instant Currentdate = Instant.ofEpochMilli(new Date().getTime());
Instant Startdate = Instant.ofEpochMilli(doc['activity'].value.getMillis());
ChronoUnit.DAYS.between(Startdate, Currentdate);
As a result, it shows me the number I needed.
I don't find this solution the best, so in case anybody know some better way to resolve this issue, please add a comment.

How to find the date and time the order was cancelled in Magento 1.9.x

Bit of a complex question for you..
I am exporting orders from Magento 1.9.4.0 using an extention from XTENTO.
It uses XSL to build 'profiles' to all me to cycle through orders programatically and export them in a format of my choice.
I have everything working aside from pulling the correct date the order was cancelled. I can see that in Magento this date appears to be in the table 'sales_flat_order_status_history'.
Looking at the table i can see the following:
sales_flat_order_status_history table
And the XSL I have been using is below..
XSL query
It IS finding a date; but it is finding the LAST update to the order and pulling the created_at value.
Does anyone know how I could find the FIRST timestamp where the order was in a cancelled state using the XSL notation?
The documentation for the XSL engine is available here, if helpful: https://support.xtento.com/wiki/Magento_Extensions:Magento_Order_Export_Module#2.29_Export_Fields
Many thanks
This seems to be hardcoded on your module files.
You could be able to change the query it is making to the database. I can't give complete guidance since I do not have the module files to look at.
Try opening the module folder in some code editor and search for something like:
Mage::getModel('sales/order_status_history')
You will then find where the code may reside and then change the query to filter for what you want.

Grafana graph total count shown as list?

I have a Grafana dashboard, where I am currently getting my query shown as a "Gauge"-graph showing the total hits.
As you can see on the screenshot, it shows total number of hits - but I would like to have them on a list, with the details of each hit (NOT the Kibana way).
I've looked at some of the other graph models that Grafana provide and the "Table"-model is the one I find best, but it only shows the columns "time" and "count", which isn't that useful.
Is there some way to manipulate the columns shown on the table, so it isnt "time" and "count" but more custom values?
Or do others have better ways to do it?
I have already looked at the tutorial/guidelines provided by Grafana here but I find them quite low on details.
I've also tried to pull out the "Raw document" to find the JSON-columns, that I want shown, but then it crashes and I get the same error message as the one reported in Grafans github here saying
"Grafana has likely been updated. Please try reloading the page."
hmm... Quite frustrating to be honest.
// In short: I want to add some metrics from the query that is shown in the JSON, which I can place in the table, as I want.
UPDATE 22nd Oct. 2019
Regarding the error message from Grafana
"Grafana has likely been updated. Please try reloading the page."
Updating it to the newest version 6.4.3 fixed this problem, even though it should have been fixed in 6.4.2.
This enables me to see raw JSON formatted data, so that is done. Now I need to find out how to fetch and work with some of these data inside the JSON, so that I can see them on the table.
Found out that I just had to use the metric "Unique Count" or "Count" from where I choose a indexed metric which will then give me a count value.
Please double check that you are not getting an average value, but a total. If it fx shows 0.4 and you only have integers, then you are probably getting an average value.
Also if you want to play around with the different metrics, so they show in the panel, a solution would be to choose the metric "Raw Document". Then inside visualization you can choose to add the metrics you want shown under "Column". Press the '+' mark and add the different metrics.
If you want to give it a better name, you can configure it under "Column Styles".
And finally - always stay up to date with the newest grafana version, so you don't end up getting frustated over a error which is only there because you haven't updated.

How to convert output timezone per query in sequel ruby?

I wanted to be able to set timezone in each query depending on my user's preferred timezone without adding timezone conversion in each raw sql generated by my application.
I was able to query/retrieve the records in 'Asia/Manila' TZ using this config
Sequel.extension :named_timezones
Sequel.application_timezone = 'Asia/Manila'
Is it possible to set application_timezone per query so that I will pass the current application user's timezone in each request.
You probably want to use Sequel's thread_local_timezones extension: http://sequel.jeremyevans.net/rdoc-plugins/files/lib/sequel/extensions/thread_local_timezones_rb.html
This is per thread, not per query, but should hopefully still work for your needs.
Store everything in UTC and then convert in the UI/presentation layer.

Listing messages with more precision than yyyy/mm/dd

I'm trying to get all the messages sent to a user after a certain point in time, by using the Gmail API. I've successfully retrieved messages after a certain date by using the query q=after:2015/01/19 in the API Explorer.
I would like to be more specific than this and specify an hour and a minute of the day. Is this possible? I ask since the Advanced Search-specification only contains the most useful operators.
You can use a search query to list messages after a certain date with second accuracy.
Use the search term after:SOME_TIME_IN_SECONDS_SINCE_EPOCH. Gmail supports the after keyword using a timestamp instead of the yyyy/mm/dd format.

Resources