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.
Related
This is my first time using amazon quicksight and I am having trouble creating a calculated measure that brings in sales from the year before the one I am evaluating in each row.
Example:
I am looking for the simile to the function CALCULATE (SUM (SALES), PREVIOUSYEAR ()) of PowerBi
I am afraid this is not a complete solution but hopefully it will put you in the right direction.
I started with the following dataset:
In Quicksight, I prepared my data by calculating the Year and Month fields from the Date field of my dataset. I then defined the following calculated field:
lag(sum(SALES), [Month ASC], 1)
I was then able to get the following result:
As mentioned, this is a partial answer as it doesn't work for May 2019 (it should be null/empty instead of 19). It might be easier to work with dates field rather than Month/Year string fields the way I did. I hope this will be of some help.
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.
I am using Kibana to log actions performed by the users of my web interface.
I would like to create a visualisation that does the following:
For each of my users (I have a field for that in my Elastic entries)
Display the first and last entry datetime
Maybe should I make two visualisations, on for first, one for last, as I don't know if it possible to do it on one single Visual.
Thanks in advance
Okay, I found the answer, in the case of a Data Table visualization, I added two metrics:
The min and max of the datetime field I use as the timestamp.
Changing the timespan of your visualization will give you the first and last entry datetimes.
I have 3 columns in my mongodb named as days (long), startDate (java.util.Date), endDate (java.util.Date). What all I want to fetch the records between startDate and (endDate-days) OR (endDate-startDate) <= days.
Can you please let me know how could i achieve this using mongoTemplate spring.
I don't want to fetch all the records from table and then resolve this on java side since in future my table may have million of records.
Thanks
Jitender
There is no way to do this in the query on the DB side (the end minus start part). What I recommend if this is an important feature for your application is that you alter the schema to maintain in the document the delta between the two fields in the format you need it. Since you can update that field when you update endDate (or if you populate both dates at the same time you can just compute the field then).
If you receive this data in bulk from another source, or if you do multi-updates of the endDate then you will probably need another job to run and periodically compute the delta of the documents where it's not computed (then you can start with always setting delta to 99999 and update it in this job to accurate value once endDate is set).
While you can use $where clause, it will be a very slow full collection scan so I would not suggest its use - it's probably better to come up with a more performant alternative even if it requires altering the schema.
http://docs.mongodb.org/manual/reference/operator/where/
I have the following issue: I have a large grid, that is primarily sorted by date since the load. This particular table also has the ability to group, as shown in the following image:
(Sorry for posting an image like this, but thanks to the spam filter, i cant directly insert one here)
Issue is that when i group by date (do note that this behavior is not observed in other columns other than date) this happens:
But if i order the date in to the other way, such behavior is no longer observed
I should note also that this implementation is under ASP.MVC 3. I tried to format the date differently, but without avail.
Thanks for your time
If the problem is only the order of sorting (see comments to the question) I think one could solve the problem by the usage sorttype as function. See the old answer and this one for details.