Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Sample code and instructions for Java plugins will omit common configuration (eg. 'id', 'tags')

Open
#22 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Documentation
Clarity
Mostly clear
Activity status
Stale
Tech stack
java
Domain
documentation

Research direction

Start with the Java input-plugin instructions and example source, then inspect PluginHelper.commonFilterSettings in logstash-core and PluginUtil.java. Update the affected documentation and example code so the common configuration is represented for the relevant Java plugin types, and verify that the documented examples no longer omit settings such as id and tags.

Written by the indexing model from the issue text.

Description

Logstash 7.9 at least; although as a documentation and example-code issue, it's been around since the Java API was released.

The official instructions and example source code for creatingpure-Java input/filter/output/codec plugins for Logstash leaves out some code which means plugins created according to the instructions will cause a configuration failure such as this:

[ERROR][co.elastic.logstash.api.PluginHelper] Unknown setting 'id' specified for plugin 'mmdb'

This log appears to come from PluginUtil, despite the class indicated in the log.

The provided instructions and code will have you use the following (How to write a Java input plugin):

    @Override
    public Collection<PluginConfigSpec<?>> configSchema() {
        return Arrays.asList(EVENT_COUNT_CONFIG, PREFIX_CONFIG);
    }

This should instead be something like the following:

import co.elastic.logstash.api.PluginHelper;
...

    @Override
    public Collection<PluginConfigSpec<?>> configSchema() {
        
        // The Java example I was looking at doesn't tell
        // you that you need to include the common config
        // too, nor does it show how.
        // 
        // This form of commonFilterSettings, with an
        // argument, will merge the provided settings with
        // the common ones for filter.
        //
        // Note that the checking of arguments is not done
        // when we run the unit-tests; that's not our
        // code. You may therefore encounter this during
        // integration testing instead.

        return PluginHelper.commonFilterSettings(
            Arrays.asList(
                SOURCE_CONFIG,
                TARGET_CONFIG,
                DATABASE_FILENAME_CONFIG,
                CACHE_SIZE_CONFIG,
                FIELDS_CONFIG));
    }

See the source for commonFilterSetttings

Most of the Java plugins in logstash-core get this right, such as the generator, stdin, uuid; although none of the output plugins do; though according to the documentation they should.

PS. I'm attaching this as an issue to the filter plugin, just because that's what I was working from, but clearly this affects multiple repositories and the documentation, so I'm happy to file this on another repo if you like (and can point me in the correct direction).

Cheers,
Cameron

Dominant language
Java
Stars
19
Forks
39
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from logstash-plugins/logstash-filter-java_filter_example

All issues in logstash-plugins/logstash-filter-java_filter_example

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.