AWS Elasticsearch Aggregation - elasticsearch

# Transaction Id Amount Status
1 AA001 100 pending
2 AA001 100 success
3 AA002 200 pending
On above data AA001 - having both pending & success AA002 have only pending
So expected to get as below
# Transaction Id Amount Status
2 AA001 100 success
3 AA002 200 pending
How to apply Aggregation?
Condition:
- if a transaction have both pending and success status record return only success record
- if a transaction have only pending return pending record

In theory you can sort the way you want , and a rank to each row. Pick the rank = 1 , so you pick only one row for a unique combination of transaction id and amount.

Related

Jmeter delay between two loop count in Loop Controller

I am trying to achieve below use case for load testing via jmeter
1. Search Product
2. Add to cart
3. Do payment
1 user with uid = 1 will perform above mentioned 3 steps every 5min for 1 hour.
total request per user per hour. = 12(5 * 12 = 60) * 3(rpm) = 36(request per hour)
total users(threads) = 1000.
total request per hour = 1000 * 36 = 36000
lets consider 3 request as a single set
I am looking for below things
after every 5min 1 set should be executed
delay between two sets should be of 5 min
can anyone please help me in achieving above scenario?
I have tried with below jmeter tools
thread group (thread = 1000, ramp up = 100 sec, loop count = 1)
loop controller( above 3 request with loop count = 12)
constant timer = 300000 millisecond
thread group (thread = 1000, ramp up = 100 sec, loop count = 1)
loop controller( above 3 request with loop count = 12)
constant throughput timer = 5 rpm
thread group (thread = 1000, ramp up = 100 sec, loop count = infinite, duration = 3600 sec)
above 3 request inside thread group
constant throughput timer = 5 rpm
Also I have tried with random order controller
I am unable to simulate above scenario. What I am getting is first request is getting executed 1000 times, then delay, then second request is getting executed 1000 times, then delay then 3rd request is getting executed 1000 times.
Constant Timer adds a delay before each Sampler in its scope
If you want to introduce a delay between 2 iterations add Flow Control Action sampler and define the desired delay there
Additionally if you want all the users to finish the action - add a Synchronizing Timer and set the number of users to group by to be equal to the number of threads in the Thread Group.
More information on JMeter Timers concept: A Comprehensive Guide to Using JMeter Timers

Calculate Daily/Monthly Energy consumption in SQL Server

I have a SQL Server table Energy_CC with two columns: time [int] (Epoch time) and E_CC14 [float]. Every 30 minutes, the total amount of my energy (kWh) is appended to the data table - something like this:
time
E_CC14
1670990400
5469.00223
1670992200
5469.02791
1670994000
5469.056295
1670995800
5469.082706
1670997600
5469.10558
1670999400
5469.128534
I tried this SQL statement:
SELECT
MONTH(DATEADD(SS, i.time, '1970-01-01')),
i.E_CC14 AS mwh,
iprev.E_CC14 AS prevmwh,
(i.E_CC14 - iprev.E_CC14) AS diff
FROM
Energy_CC i
LEFT OUTER JOIN
Energy_CC iprev ON MONTH(iprev.time) = MONTH(i.time) - MONTH(DATEADD(month, -1, i.time))
AND DAY(iprev.time) = 1
WHERE
DAY(i.time) = 1
GROUP BY
MONTH(i.time), i.E_CC14, iprev.E_CC14;
I expect the result for monthly like this :
time
E_CC14
DECEMBER-22
10223
Any help would be greatly appreciated.

Understanding Spring Boot actuator `http.server.requests` metrics MAX attribute

can someone explain what does the MAX statistic refers to in the below response. I don't see it documented anywhere.
localhost:8081/actuator/metrics/http.server.requests?tag=uri:/myControllerMethod
Response:
{
"name":"http.server.requests",
"description":null,
"baseUnit":"milliseconds",
"measurements":[
{
"statistic":"COUNT",
"value":13
},
{
"statistic":"TOTAL_TIME",
"value":57.430899
},
{
"statistic":"MAX",
"value":0
}
],
"availableTags":[
{
"tag":"exception",
"values":[
"None"
]
},
{
"tag":"method",
"values":[
"GET"
]
},
{
"tag":"outcome",
"values":[
"SUCCESS"
]
},
{
"tag":"status",
"values":[
"200"
]
},
{
"tag":"commonTag",
"values":[
"somePrefix"
]
}
]
}
You can see the individual metrics by using ?tag=url:{endpoint_tag} as defined in the response of the root /actuator/metrics/http.server.requests call. The details of the measurements values are;
COUNT: Rate per second for calls.
TOTAL_TIME: The sum of the times recorded. Reported in the monitoring system's base unit of time
MAX: The maximum amount recorded. When this represents a time, it is reported in the monitoring system's base unit of time.
As given here, also here.
The discrepancies you are seeing is due to the presence of a timer. Meaning after some time currently defined MAX value for any tagged metric can be reset back to 0. Can you add some new calls to /myControllerMethod then immediately do a call to /actuator/metrics/http.server.requests to see a non-zero MAX value for given tag?
This is due to the idea behind getting MAX metric for each smaller period. When you are seeing these metrics, you will be able to get an array of MAX values rather than a single value for a long period of time.
You can get to see this in action within Micrometer source code. There is a rotate() method focused on resetting the MAX value to create above described behaviour.
You can see this is called for every poll() call, which is triggered every some period for metric gathering.
What does MAX represent
MAX represents the maximum time taken to execute endpoint.
Analysis for /user/asset/getAllAssets
COUNT TOTAL_TIME MAX
5 115 17
6 122 17 (Execution Time = 122 - 115 = 17)
7 131 17 (Execution Time = 131 - 122 = 17)
8 187 56 (Execution Time = 187 - 131 = 56)
9 204 56 From Now MAX will be 56 (Execution Time = 204 - 187 = 17)
Will MAX be 0 if we have less number of request (or 1 request) to the particular endpoint?
No number of request for particular endPoint does not affect the MAX (see Image from Spring Boot Admin)
When MAX will be 0
There is Timer which set the value 0. When the endpoint is not being called or executed for sometime Timer sets MAX to 0. Here approximate timer value is 2 minutes (120 seconds)
DistributionStatisticConfig has .expiry(Duration.ofMinutes(2)).
which sets some measurements to 0 if there is no request has been made in between expiry time or rotate time.
How I have determined the timer value?
For that, I have taken 6 samples (executed the same endpoint for 6 times). For that, I have determined the time difference between the time of calling the endpoint - time for when MAX set back to zero
More Details
UPDATE
Document has been updated.
NOTE:
Max for basic DistributionSummary implementations such as CumulativeDistributionSummary, StepDistributionSummary is a time
window max (TimeWindowMax).
It means that its value is the maximum value during a time window.
If the time window ends, it'll be reset to 0 and a new time window starts again.
Time window size will be the step size of the meter registry unless expiry in DistributionStatisticConfig is set to other value
explicitly.

Qlik Sense. Time Filter

Same issue I posted Friday but I will be more specific this time. I have this data:
UserId Action Id Date
1 1 1/1/2018
1 2 1/1/2018
1 2 2/1/2018
2 3 3/1/2018
2 4 4/1/2018
And I want a filter that will yield the following:
Count Instances from FirstDate to 2/1/2018
UserId ActionCount
1 3
2 0
In the data load editor you want to group by the User in order to get that first date:
GroupedUserData:
Load
UserId
min(Date) as FirstDate
resident [The name of your original table];
And then you want to use set analysis chart-side:
sum({<FirstDate = {'<=2/1/2018'}>} ActionCount)

Get latest record with certain criteria in linq

I have following result set. How to get latest History records which meets criteria : Status = 'A' in linq ? Grouping is done on Entity Id and Records will be sorted descending on History Id
History ID Entity ID Status
2969 6957 I
2968 6957 A
2967 6957 A
2303 6957 I
1000 6958 A
55 6959 A
50 6959 I
45 6960 I
40 6960 A
Results should give me
History ID Entity ID Status
1000 6958 A
55 6959 A
first group by entity and get the "latest" records for each group. Finally check for a status of A:
histories.GroupBy(h => h.EntityId)
.Select(g => g.OrderByDescending(h => h.HistoryID)
.First())
.Where(h => h.Status == "A");

Resources