I am trying to perform a ratio calculation on 2 fields (values) coming from different sources but of the same source type, Individually my searches work fine and return the correct values. But, when I combine them together, I get really weird results. Many Thanks for your help !
(sourcetype= "test" source=A host =192.168.1.1 fieldA=* ) OR source=B eval sourceA=round(fieldA/1000),2 eval sourceB=round(fieldB/1000),2 stats max(sourceA) as SA max(sourceB) as SB |eval percent_ratio=round(SA/SB,2) |stats max(percent_ratio)
Can you describe what result you're looking for?
As your search sits now, you're getting the maximums of both values, calculating the ratio of those two maximums, and then getting the maximum of that one ratio. I can't tell from that what you're actually trying to achieve, and in what way your search deviates from that goal.
Hello Martin , Thanks for your reply
I am trying to calculate percent ratio from two max(values) belong to two diff sources and I am looking for the correct syntax on how to do that
dataset from sourceA
data set from sourceB
it should produce the following results
sourceA(max value) sourceB(max value) percent_ratio
62 200 (200/62)*100
Hope it will clarified your question
To get the ratio between two maximums your search looks pretty much correct already, I'd just leave off the rounding until the very end.
source=A OR source=B | stats max(fieldA) as maxA max(fieldB) as maxB | eval percent_ratio = round(maxA/maxB*100, 2) | fields percent_ratio
another question if you don't mind , what about
sum & max it shouldn't make no difference , correct ?
source=A OR source=B
| stats sum(fieldA) as sumA max(fieldB) as maxB
| eval percentratio = round(sumA/maxB*100, 2)
| fields percentratio