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

User-defined VRL modules #1020

Open
uralmetal opened this issue Sep 6, 2024 · 3 comments
Open

User-defined VRL modules #1020

uralmetal opened this issue Sep 6, 2024 · 3 comments
Labels
vrl: compiler Changes to the compiler

Comments

@uralmetal
Copy link
Contributor

This is an idea for improving reuse and code style VRL. I suggest to realize mechanism like python import or Jinja include. tthis is necessary to use user vrl code in different pipelines without using the Pipeline to Pipeline communication
For example:

user library

function set_http_status_code() {
    http_status_code = parse_int!(.http_status)
    del(.http_status)

    if http_status_code >= 200 && http_status_code <= 299 {
        .status = "success"
    } else {
        .status = "error"
    }
}

pipeline code

from library import set_http_status_code

del(.foo)

.timestamp = now()

set_http_status_code()

@uralmetal
Copy link
Contributor Author

@jszwedko
Copy link
Member

jszwedko commented Sep 6, 2024

Hi @uralmetal !

Thanks for opening this. I can see how it would be useful. I think there are few separate requests here:

  1. User-defined functions, which we have a request for: User defined VRL functions #47
  2. Modules (related: add (syntax-only) modules for functions #145)
  3. Including files in VRL configuration. The fluentd example you referenced is a feature of some YAML engines to include files. Unfortunately I don't think the serde-yaml, which we use, supports that feature.

It seems like you don't really want 3, but just 1 and 2. Since we have an issue for 1 already, I'll repurpose this issue to be about 2.

@jszwedko jszwedko added the vrl: compiler Changes to the compiler label Sep 6, 2024
@jszwedko jszwedko changed the title Reuse VRL code User-defined VRL modules Sep 6, 2024
@uralmetal
Copy link
Contributor Author

Yeah, i agree with you. Then i wait news about User-defined VRL functions and modules

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
vrl: compiler Changes to the compiler
Projects
None yet
Development

No branches or pull requests

2 participants