I have Grafana 3.0 with InfluxDB and Graphite datasources.
I have a field with size in GigaByte and I need to know the sum of this field in the last 1h.
I tried summarize() and hitcount() on graphite, but is not the correct result.
How can I achieve this??
Solved.
It was hitcount, but I have some problem with graphite data and the result is not tthe correct. Now I resolved.
For InfluxDB the query would be SELECT count(GigaByte) FROM yourmeasurement where time > now() - 1h
Related
I'm trying to combine two columns with date and time data in the ETL tool and load them into snowflake. When I load the data as datetime, there are 10 and 11 hour differences. At the same time, I share with you the current hours of Snowflake and my local.
select current_timestamp >> '2022-11-15 23:46:47.318 -0800'
My current hour is now >> '2022-11-16 10:46:47.318'
The photo below will help to understand the problem more closely. STAGE_DATE Merged version of VBRK_FKDAT and VBRK_ERZET. I want to see this date. I combine VBRK_FKDAT and VBRK_ERZET from Data Services and after I get 10 hours I send snowflake. This stands for INVOICEDATE. When I take the difference of INVOICEDATE and STAGE_DATE I get HOURDIFF. Randomly there are 10 and 11 hours difference. I'm trying to understand the problem.
Thank you for your interest.
What you've explained is most probably related to the current setting for the TIMEZONE:
Default: America/Los_Angeles
The timestamps are stored internally in UTC but are displayed for the user based on the TIMESTAMP parameter value for session/user/account.
For more information have a look here.
I have an asp.net application deployed in azure. This generates plenty of logs, some of which are exceptions. I do have a query in Log Analytics Workspace that picks up exceptions from logs.
I would like to know what is the best and/or cheapest way to detect anomalies in the exception count over a time period.
For example, if the average number of exceptions for every hour is N (based on information collected over the past 1 month or so), and if average goes > N+20 at any time (checked every 1 hour or so), then I need to be notified.
N would be dynamically changing based on trend.
I would like to know what is the best and/or cheapest way to detect anomalies in the exception count over a time period.
Yes, we can achieve this by following steps:
Store the average value in a Stored Query Result in Azure.
Using stored query result
.set stored_query_result
These are some limitations to keep the result. Refer MSDOC for detailed information.
Note: The stored query result will be available only 24 hours.
Workaround Follows
Set the Stored query result
# here i am using Stored query result to store the average value of trace message count for 5 hours
.set stored_query_result average <|
traces
| summarize events = count() by bin(timestamp, 5h)
| summarize avg(events)
2. Once Query Result Set you can use the Stored Query Result value in another KQL Query (The stored value was available till 24 hours)
# Retrieve the stored Query Result
stored_query_result(<StoredQueryResultName>) |
Query follows as per your need
Schedule the alert.
I just started figuring out DynamoDB.
I have a simple table has date attribute(ex. 20160101) as HASH and created_at attribute(ex. 20160101185332) as RANGE.
I'd like to get latest N items from the table.
First, SCAN command does not have ScanIndexForward option. I think it's not possible with SCAN.
Next, QUERY command. It seems to be work if I repeat QUERY command several times to get enough number of items(cuz, I don't know how many items have same key value). - for example, I can query using today first and repeat for the day before if the result does not give enough items.
How can I do the job more efficiently? Or, can I query without KEY value?
as you described your table, you cant do it more efficiently, and you cant query dynamodb without KEY(hash) value
look at the answer here:
dynamodb get earliest inserted distinct values from a table
I need to update the actual date of a ton of rows, but preserve the time already in there. A script started incorrectly populating the rows incorrectly due to a programming error. I could probably do this via an external script, but I figure there has to be a sqlite command to do this easily.
The column is described as this in the schema:
logDate DATE NOT NULL,
A sample row looks like this:
data8|dat7|200|2011--08 00:15|12
It SHOULD look like this:
data8|dat7|200|2011-01-08 00:15|12
It's done this for the past 10 days. I can do individual updates for the past 10 days, or one big one, but I really am not sure where to start. I haven't found much via googling. If I do, I'll answer my own question.
Thanks in advance.
So I just did this:
UPDATE views SET logDate = REPLACE(logDate,'--','-01-')
WHERE logDate LIKE '2011%';
Worked fine.
I've got a query where I'm trying to get the hours in duration (eg 6.5 hours) between two different times.
In my database, time and date are held in different fields so I can efficiently query on just a startDate, or endDate as I never query specifically on time.
My query looks like this
SELECT COUNT(*), IFNULL(SUM(TIMEDIFF(endTime,startTime)),0) FROM events WHERE user=18
Sometimes an event will go overnight, so the difference between times needs to take into account the differences between the dates as well.
I've been trying
SELECT COUNT(*), IFNULL(SUM(TIMEDIFF(CONCAT(endDate,' ',endTime),CONCAT(startDate,' ',startTime))),0) FROM events WHERE user=18
Unfortunately I only get errors when I do this, and I can't seem to combine the two fields into a single timestamp.
Pretty sure your problem is that your concatenated values are being sent to TIMEDIFF() as strings rather than DATETIMEs. Try calling the DATETIME function on them:
SELECT COUNT(*), IFNULL(SUM(TIMEDIFF(DATETIME(CONCAT(endDate,' ',endTime)),DATETIME(CONCAT(startDate,' ',startTime)))),0) FROM events WHERE user=18
I don't have a MySQL DB in front of my to test that, but I think that or some similar form of it is what you are looking for. There's an example of it in the MySQL docs involving MICROSECOND:
http://dev.mysql.com/doc/refman/5.0/en/datetime.html
Edit: Hmm... looks like TIMEDIFF is supposed to work with strings. Worth trying anyway.
TIMEDIFF(endDate,startDate) + TIMEDIFF(endTime,startTime)