Scripted field to find percent of documents to be used in a metric

I made a scripted field in Kibana using the below which syntactically is fine but doesn't function properly.
I want to take the amount of documents with "Execution", divide that hit count by 10, then multiply that number by 100 to get a percent.

if (doc.containsKey('Execution') ) {
    return Integer.parseInt(doc['tactic.keyword'].sum / 10 * 100)

When using scripted fields from kibana, the scripts only have access to document level data.

However, you might find this helpful -

Excellent, thanks Matthew

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.