Yes you can send extra parameters to your parsing function.
If you haven’t already setup your custom parser to send metric or events to your platform, you can find the setup guide here: http://docs.datadoghq.com/guides/logs/
Once you have done this, you should have something like this in your datadog.conf:
And in your parsers_module.py a function defined as:
def custom_parser(logger, line)
You can now change the arity of your function to take extra parameter as shown here:
So if you change your configuration file to:
And your parsing function as:
def custom_parser(logger, line, parser_state, *parser_args):
You will then have a tuple parameter in *parser_args as (customvar1, customvar2) which is ready to use in your code by using parser_args and parser_args.
Please note: the parameter parser_state does not have to be used but it has to be in the signature of the function. And if you have only one parameter, you will have to use parser_args to get it.
As an example, if we have the same parser as in the documentation but this time we do not want to extract the metric name from the log but to set it thanks to this parameter:
In my configuration file I have:
See attachment for the python function.