you want to do data aggregation, which Graylog does not support yet.
See here:
for more details.
If you want to have the functionality, you will have to code a plugin for that yourself. I’m sorry, but I’m not that far into Graylog Plugins regarding search yet to give any qualified advise ^^