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

Can this plugin provide script function? #214

Open
alwaysliving opened this issue Jun 28, 2023 · 0 comments
Open

Can this plugin provide script function? #214

alwaysliving opened this issue Jun 28, 2023 · 0 comments
Labels
enhancement Increases software capabilities beyond original client specifications help wanted Extra attention is needed

Comments

@alwaysliving
Copy link

alwaysliving commented Jun 28, 2023

Is your feature request related to a problem? Please describe.
I would like to request for the plugin to provide a way to use scripts, similar to what is offered in the output-elasticsearch plugin. Documentation for output-elasticsearch can be found here: https://www.elastic.co/guide/en/logstash/current/plugins-outputs-elasticsearch.html#plugins-outputs-elasticsearch-script

Describe the solution you'd like
Currently, I have no problems using scripts with Elasticsearch. However, I have intentions of using OpenSearch instead and there are several places in my existing output-elasticsearch Logstash configuration where scripts are used. When I tried to use the same method with output-opensearch, an error message was returned and the program did not run.

Describe alternatives you've considered
None at the moment.

Additional context
I have included some sample code below.

        elasticsearch {
            hosts => ["my_host"]
            index => "my_index"
            document_id => "doc_id"
            action => "update"
            doc_as_upsert=>true
            manage_template => false

            script_lang => "painless"
            script_type => "inline"
            script => '
                if (ctx._source.total_duration == null) {
                    ctx._source.total_duration = params.event.get("total_duration");
                    ctx._source.last_logout = params.event.get("last_logout");
                }
                if (ctx._source.last_logout != params.event.get("last_logout")) {
                    ctx._source.total_duration_s = ctx._source.total_duration + params.event.get("total_duration");
                    ctx._source.last_logout = params.event.get("last_logout");
                }
            '
        }
@asifsmohammed asifsmohammed added enhancement Increases software capabilities beyond original client specifications help wanted Extra attention is needed and removed untriaged labels Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Increases software capabilities beyond original client specifications help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants