Graylog2 / Graylog2/graylog2-server

Pipeline function `list_get` negative index addressing

Open
#19,561 0 comments 0 reactions 0 assignees View on GitHub
feature triaged
Dominant language
Java
Stars
8.1k
Forks
1.1k
Avg merge
1d 20h
Merged PRs (30d)
217

Description

### What?
I want to get the last element of the list, or the second-last element. In other languages like python I can use -1, -2 and so on to get elements from the end of the list. This would be very useful.

### Why?
Support issue request: https://github.com/Graylog2/support/issues/56

scenario:
I have a dns-query log with domains like helpcenter.graylog.com. I want to extract the second level domain (graylog) and the top level domain (com), and save them into another field.
What I did to archive this:
1) split the field with the split function,
2) calculate the length of the list, as it could be shorter or longer. Save it in the variable "len"
3) list_get(list,len - 2) for the second last item, list_get(list,len - 1) for the fields
4) concat them to save
Step 2+3 would be much easier, if I just could address them with -1 and -2. It's mainly a point of convenienc

(created from Zendesk ticket #557)
gz#557

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.