Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pipeline function list_get negative index addressing #19561

Open
ryan-carroll-graylog opened this issue Jun 5, 2024 · 0 comments
Open

Pipeline function list_get negative index addressing #19561

ryan-carroll-graylog opened this issue Jun 5, 2024 · 0 comments

Comments

@ryan-carroll-graylog
Copy link
Contributor

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants