[Solved] Custom Logstash filter validation question

Hi,

I have a working Logstash filter on which I want to enhance the validation;

I have a config item of;

config :da_order, :validate => :array, :default => ["Destination IMSI", "Destination MSC Address", "Destination Address"]

Is there any way that I can either write a custom validator for this config variable or use an existing one to ensure that the array has 3 values and that each value matches a specific string ?

Thanks,

This is a custom plugin that you've written, right? There might be a way to supply a validation function, but otherwise you can make the check in the register method and raise a LogStash::ConfigurationError exception if @da_order doesn't comply with the protocol.

Yes its a custom filter. A validation function is exactly what I am looking for but I cannot see any examples that illustrate that technique.

Thanks for the register method suggestion.

As @magnusbaeck correctly said, there is actually no way to pass your custom validation function for the config options, however this is a great extension point for our config validation, see https://github.com/elastic/logstash/issues/5395 for a followup issue in logstash.

For now the best you can do is using the register method.

  • purbon