New to the Elastic Stack and trying to get familiar with it. I'm not sure if this should be done on the ingest pipeline or visualization (I haven't had luck on either) but attempting to solve this with a scripted field in kibana for the time being.
I have a field "bytes" that is stored as a number. What I'm trying to do is count every occurrence of the field bytes that satisfies a requirement and return 1. This way I can sum all occurrences of of this condition in a data table. For example, I want to store occurrences field bytes greater 10000 and sum that in a data table. My scripted field for "high transfer" looks like:
if (doc['bytes'].size() == 0) return ''; if (doc["bytes"].value > 10000) { return 1; }
However this isn't producing the results in discover. Can anyone give me some advice on how to achieve this?
Also, would this be better to do as a script processor in the ingest pipeline to create a field "High Transfer" which is a count of all fields bytes greater than 10000 to be used in a sum aggregation?
I think I'm getting somewhere but could use some feedback if anyone has it. I'm trying to create an ingest pipeline with a bucket selector aggregation to get the values I need. I'm trying to create a field in my index, "High Transfer" from an ingest pipeline:
Thanks for the reply. Essentially what I'm looking for is a table like this:
Page
Hits
High Transfer
test.html
65
7
page.html
23
9
link.html
64
10
I could easily sum the hits to a an html page. But what I'm also looking for is the ability to sum the total number of occurrences of "high transfer" in a table. In the example, test.html had 65 hits and 7 with a byte transfer gte 10000
It's not possible to do this as a separate column in the table (something we are working on), but you can create a separate row for it by using a "Split rows" aggregation using "Filters" - then splitting like this:
Filter | Page | Hits
* | test.html | 65
High transfer | test.html | 7
* | page.html | 23
High transfer | page.html | 9
I suppose that makes sense that you can't create a separate column in a table but at the ingest/pipeline level you should at least be able to create an entirely new field in an index, right?
Theoretically if I have a field integer "bytes" being stored in my index, I should be able to "process that field" with some form of logic and say "if I see field 'bytes' in a document with a value greater than 10000, add a value of 1 to new field "High Transfer."
This is definitely a new beast for me, certainly without a having clause I've been struggling a bit but there has got to be a way to count the occurrences of a field in a document that matches some logic and store it in a new field.
Yes, that would be possible by using a scripted field, then adding a sum aggregation of this scripted field to the table. That should do the same thing adding a new column.
Would you mind giving me some insight on how to do this? possibly an example script? Would this scripted field be applied at the index pattern or ingest pipeline?
I attempted this with a scripted field in my original post, without luck. I thought doing this as a processing pipeline would be cleaner and was looking at how to facilitate this as part of a processing pipeline script to create the new field.
I thought doing this as a processing pipeline would be cleaner and was looking at how to facilitate this as part of a processing pipeline script to create the new field.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.