syslog-ng icon indicating copy to clipboard operation
syslog-ng copied to clipboard

Feature request: type-hinting in SQL destination

Open pycal opened this issue 6 years ago • 10 comments

I'm parsing JSON messages using json-parser, and sending them to a SQL destination. Right now syslog-ng encodes all values as strings; I'd like to send integers to my sql destination.

When I do something like this, I get an error because syslog-ng is sending an integer formatted as a string:

destination d_postgres {
  sql(
    ...
    columns(flow_id INTEGER)
    values("${.json.flow_id}")
  );
};

pycal avatar Nov 26 '18 16:11 pycal

Indeed this would be useful. It's not on my radar though.

On Mon, Nov 26, 2018 at 5:52 PM Cailen McQuattie [email protected] wrote:

I'm parsing JSON messages using json-parser, and sending them to a SQL destination. Right now syslog-ng encodes all values as strings; I'd like to send integers to my sql destination.

When I do something like this, I get an error because syslog-ng is sending an integer formatted as a string:

destination d_postgres { sql( ... columns(flow_id INTEGER) values("${.json.flow_id}") ); };

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/balabit/syslog-ng/issues/2429, or mute the thread https://github.com/notifications/unsubscribe-auth/AArldgFQsKhHYtDCzP2wYy7OZy8hk_v2ks5uzBw5gaJpZM4YzbUJ .

bazsi avatar Nov 26 '18 17:11 bazsi

Understood @bazsi and thanks for replying.

Is there a way you can recommend dealing with this using the current feature set?

pycal avatar Nov 27 '18 15:11 pycal

Create the table in database manually with desired data types. If tables/columns already exist then syslog-ng does not create any table but uses the existing ones (which will have INTEGER columns)

Wernfried avatar Nov 28 '18 13:11 Wernfried

you can specify types to columns though.

columns('id INTEGER', 'value TEXT') and so on.

We would just be using '10' always, e.g. with the apostrophes present. If the database would convert this automatically to the desired data type, it would work.

On Wed, Nov 28, 2018 at 2:32 PM Wernfried [email protected] wrote:

Create the table in database manually with desired data types. If tables/columns already exist then syslog-ng does not create any table but uses the existing ones (which will have INTEGER columns)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/balabit/syslog-ng/issues/2429#issuecomment-442446607, or mute the thread https://github.com/notifications/unsubscribe-auth/AArldpiwGcUasK6GO1fX56mcyPloApIHks5uzo-lgaJpZM4YzbUJ .

bazsi avatar Nov 28 '18 15:11 bazsi

@pycal please assign it to me

aman566 avatar Jan 18 '19 12:01 aman566

@aman566 it is not possible to use the Assignees field for users outside of balabit org + issue owner; so claiming in the comment should do. feel free to work on it.

Kokan avatar Jan 18 '19 12:01 Kokan

So can I send PR if possible @Kokan

aman566 avatar Jan 18 '19 14:01 aman566

of course

Kokan avatar Jan 18 '19 14:01 Kokan

Hi @bazsi ,

I want to work on this issue. Can you give me a brief idea of what changes do I need to make?

vatsal-encs avatar Apr 16 '20 23:04 vatsal-encs

I'd want to work on this issue. Please give this problem to me.

Madhusmeeta avatar Jan 08 '23 17:01 Madhusmeeta