6
responses

hi,

Is somebody has got an experience of im_dbi ?

I tried this example but /tmp/output is filled of blank char ?
I checked nxlog log at starting, everything is OK.
Driver mysql has been installed correcly

<Input dbi>
Module im_dbi
Driver mysql
Option host 127.0.0.1
Option username mysql
Option password mysql
Option dbname logdb
SQL SELECT id, facility, severity, hostname, \
timestamp, application, message \
FROM log
</Input>

<Output file>
Module om_file
File "tmp/output"
</Output>

<Route dbi_to_file>
Path dbi => file
</Route>

AskedSeptember 28, 2018 - 12:12pm

Answer (1)

Hi iCirco,

It appears that your configuration is correct, provided that your MySQL database has that schema. I'd recommend testing the query

SELECT id, facility, severity, hostname, timestamp, application, message FROM log

directly against your MySQL server with a MySQL client to verify it returns some results. Once we're able to verify that query does in fact return results we can further troubleshoot from there.

-Cameron

Comments (5)

  • iCirco's picture

    hello,

    I tried my query and it's OK in my MySQL Query browser, it returns fews lines (I tried on a little table with 20 lines)

    But, when I insert data in table, I can see that a blank line is insert in /tmp/output but nothing else happens. I excpected that the line inserted in the table should appear in /tmp/output.

    I work on centos 7.2

  • iCirco's picture

    My SQL Query :

    SELECT id, nom FROM planbam;
    128, 'd'
    129, 'test'
    130, 'test'
    131, 'test'
    132, 'test'
    133, 'test'
    134, 'test'
    135, 'test'
    136, 'test'
    137, 'test'
    138, 'test'
    139, 'test'
    140, 'test'
    141, 'test'
    142, 'test'
    143, 'TEST'
    144, 'TEST'
    145, 'TEST'
    146, 'TEST'

    my nxlog.conf :

    <Input dbi>
    Module im_dbi
    Driver mysql
    Option host xx.xx.xx.xx
    Option username xxx
    Option password xxx
    Option dbname test
    SQL SELECT id, nom FROM planbam
    </Input>

    <Output file>
    Module om_file
    File "/tmp/output"
    </Output>

    <Route dbi_to_file>
    Path dbi => file
    </Route>

    when I insert new line in planbam, /tmp/output is inserted of blank line (1 blank on each line)

  • Zhengshi's picture
    (NXLog)

    Hello,

    Did you try the settings that b0ti had mentioned below? Let us know the output of adding the json

    The record inserted comes back as fields that needs to be mapped to how output is written by om_file via $raw_event. You'll need to format the output using xm_kvp, xm_json, etc.

    Try adding Exec to_json(); to your output block and define xm_json.

  • b0ti's picture
    (NXLog)

    when I insert data in table ... I excpected that the line inserted

    Did you insert a line? I don't think so.
    The record inserted comes back as fields that needs to be mapped to how output is written by om_file via $raw_event. You'll need to format the output using xm_kvp, xm_json, etc.

    Try adding Exec to_json(); to your output block and define xm_json.