Creating a custom visualization with if/switch statement

Hey Forum,

I am working on creating a dashboard based on connections that are made to a particular node. One of the things that I have visualized is the top 5 destination port numbers as an aggregate of all of the connections to this node. I would like to build some kind of custom module that can take these port numbers and show their names (for common ports). For example instead of seeing 80, 443, 23, 22, and 445, I'd like to see HTTP, HTTPS, Telnet, SSH, and SMB. My idea would be to create some kind of a switch or if statement that could check for these values and output the common names, but I have no idea how to do this (or if it is possible) in Kibana. Would something like this be possible with a vega visualization? If someone could help me out, I would really appreciate it!

Thank You,

You could probably use a scripted field, something like this:

if (doc['port_number'].value == 80) return 'HTTP';
if (doc['port_number'].value == 443) return 'HTTPS';

etc. etc. which you could then use in any of your visualizations.

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