0

I'm trying to use Syslog-ng so that it forwards the messages to a python destination. However, I keep getting a "Error parsing destination, destination plugin python not found ..." message.

I am following this tutorial exactly. https://syslog-ng.gitbooks.io/getting-started/content/chapters/chapter_5/section_1.html

From what I can gather, keywords "java" and "python" require Syslog-ng 3.7+. Which I have upgraded to from 3.5.6. I have also changed the provided config file @version: 3.7 to @version: 3.8.

Any ideas why Syslog-ng doesn't recognize the keyword "python" in my config file?

As I mention in the comments below, I am working on this tutorial because I am a bigger project that requires me to understand Syslog-ng config API and didn't want over complicate my question with other issues.

Here is the script that was provided.

@version: 3.7
@include "scl.conf"

source s_local {
    system();
    internal();
};

destination python_to_file {
            python(
                class("betterpythonexample.TextDestination")
                on-error("fallback-to-string")
                value-pairs(scope(everything))
                );
                };

log {
    source(s_local);
    destination(python_to_file);
};   

This is the python code in the example.

    class LogDestination(object):

    def open(self):
        """Open a connection to the target service"""
        return True

    def close(self):
        """Close the connection to the target service"""
        pass

    def is_opened(self):
        """Check if the connection to the target is able to receive messages"""
        return True

    def init(self):
        """This method is called at initialization time"""
        return True

    def deinit(self):
        """This method is called at deinitialization time"""
        pass

    def send(self, msg):
        """Send a message to the target service

        It should return True to indicate success, False will suspend the
        destination for a period specified by the time-reopen() option."""
        pass


class TextDestination(LogDestination):
    def __init__(self):
        self.outfile = None

    def init(self):
        self.outfile = open('/tmp/example.txt', 'a')
        self.outfile.write("initialized\n")
        self.outfile.flush()
        return True

    def open(self):
        self.outfile.write("opened\n")
        self.outfile.flush()
        return True

    def close(self):
        self.outfile.write("closed\n")
        self.outfile.flush()
        return True

    def deinit(self):
        self.outfile.write("deinit\n")
        self.outfile.flush()
        self.outfile.close();
        return True

    def send(self, msg):
        self.outfile.write("Name Value Pairs are \n")

        for key,v in msg.items():
            self.outfile.write(str(key)+" "+str(v)+"\n");
        self.outfile.flush()
        return True
  • SO is for programming questions, not system administration. – Barmar Oct 13 '16 at 00:45
  • I was not aware my question was a system administration problem. I'm trying to build a pipeline from Syslog-ng to MongoDB to Kafka. Each of those I have scripts and programs for with their own set of questions. However, I didn't want to describe the complete project because I thought it would distract from this issue. My issue is that I am following a programming tutorial on Syslog-ng and despite changing very little the tutorial example fails to work. I note which tutorial and my efforts so far. So how is this not a programming question? – Bandith Phommounivong Oct 13 '16 at 01:18
  • I have added more details, so hopefully it is clearer that I am trying to debug whether my issue. Maybe I didn't install something, maybe I miss semi colons, or misused syslog-ng API. – Bandith Phommounivong Oct 13 '16 at 01:36
  • Hi, have you compiled syslog-ng from source? Have you used the --enable-python compiling option? Or if you are using a binary package, from where have you downloaded it? I'm also curious in your use case, why do you need a Python destination? You mention that you want to send logs to mongodb and kafka, syslog-ng has native destination drivers for both. – Robert Fekete Oct 13 '16 at 06:22
  • yum install syslog-ng-python is what resolved this issue. – Bandith Phommounivong Oct 19 '16 at 16:43

0 Answers0