I have some non-time-based data that I'd like to summarize using chart with a small number of bins. For example,
<some search> | stats count as c by foo | sort -c | chart sum(c) by foo bins=10
"foo" is not numeric, so it automatically fails, but I don't want the bins to be determined by an intrinsic order on foo anyway: The bins should respect the order that comes from the sort command. Thus, in the chart, the first "bar" should represent the greatest decile of the "sort -c" command, the second, the second decile, and so on.
I can't figure out how to wrangle an order into the chart command or otherwise make it respect the sort and use that order as the basis for the separations into bins. Am I barking up the wrong tree here?
Try something like this
| stats count as c by foo
| sort - c
| eventstats count as foos
| eval binsize=ceil(foos/10)
| streamstats count as row
| eval foobin=1+floor((row-1)/binsize)
| chart sum(c) by foobin
Yes, I do realize that my question isn't very well-formed. Let me provide an example, using 2 bins, instead of 10 for brevity:
Suppose my data has 10 lines where foo="A", 9 lines where foo="B", 8 lines where foo="C", and 7 lines where foo="D". Then
| stats count as c by foo | sort -c
should output
foo c
A 10
B 9
C 8
D 7
What I want from the chart+bins command (for example) is something like this:
bins sum
bin1 19
bin2 15
...where bin1 is formed from A and B, since they have the top two c values and bin2 is C and D, as the least, and the sum value is sum(c).
Try something like this
| stats count as c by foo
| sort - c
| eventstats count as foos
| eval binsize=ceil(foos/10)
| streamstats count as row
| eval foobin=1+floor((row-1)/binsize)
| chart sum(c) by foobin
That appears to be what I need. Thanks much.
It isn't clear what your expected result would look like - having said that, does this help?
| stats count as c by foo
| sort - c
| transpose 0 header_field=foo column_name=count