Re: pdnslog ON RECURSOR SHOWS ON MULTIPLE LINES ON SYSLOG

Pius Nganga via Pdns-dev <[email protected]> Fri, 29 Jan 2021 15:31:38 +0300
Newsgroups gmane.network.dns.powerdns.devel
Message-ID <CANtG0d_jxfW=9wwiwr43zvY4rcDn33F8SsuG531CSgSN6ct17g@mail.gmail.com>
--===============6622038268137262714==
Content-Type: multipart/alternative; boundary="00000000000035964f05ba093098"

--00000000000035964f05ba093098
Content-Type: text/plain; charset="UTF-8"

Thanks Peter,

The 'data' variable had a new line at the end. We removed the new line and
it now works as expected.

On Fri, Jan 29, 2021 at 2:41 PM Peter van Dijk via Pdns-dev <
[email protected]> wrote:

> Hello,
>
> On Fri, 2021-01-29 at 06:36 +0300, Pius Nganga via Pdns-dev wrote:
> > Hi,
> >
> > We are using a lua script for filtering urls based on pre-set policies
> inside the preresolve() method of pdns recursor. We are doing this by
> checking dq.remoteaddr:toString() and reading the policies for it from
> sqlite db then taking the necessary action( mark the query as either
> blocked or safe.) Before returning the function, we are logging the result
> to syslog using pdnslog as follows;
> >
> >
> pdnslog('Network:'..dq.remoteaddr:toString()..'|device:'..device_mac..'|ip:'..device_ip..'|url:'..dq.qname:toString()..'|category:'..data..'|policy
> ID:'..row.policy_id..'|Status:Safe')
> >
> > The blocking part is working as expected, the challenge is that the
> above log shows as two lines on syslog or journalctl as shown below;
> >
> > Jan 29 01:25:35 ns pdns_recursor[24914]:
> Network:105.162.6.128|device:dd:ef:ca:d8:4e:74|ip:192.168.100.4|url:www.google.com.|category:Search
> Engines
> > Jan 29 01:25:35 ns pdns_recursor[24914]: |ID:3|Status:Safe
> >
> >
> > Our intention is to have it log on one line as;
> >
> > Jan 29 01:25:35 ns pdns_recursor[24914]:
> Network:105.162.6.128|dev:dd:ef:ca:d8:4e:74|ip:192.168.100.4|url:www.google.com.|category:Search
> Engines|ID:3|Status:Safe
> >
> >
> > Any idea on how we can enforce pdnslog to write on a single line?
>
> I suspect your 'data' variable ends in a new line. You'll have to remove
> that new line from it.
>
> Kind regards,
> --
> Peter van Dijk
> PowerDNS.COM BV - https://www.powerdns.com/
>
> _______________________________________________
> Pdns-dev mailing list
> [email protected]
> https://mailman.powerdns.com/mailman/listinfo/pdns-dev
>

--00000000000035964f05ba093098
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_default" style=3D"font-family:comic sa=
ns ms,sans-serif;font-size:small;color:#000000">Thanks Peter,<br><br></div>=
<div class=3D"gmail_default" style=3D"font-family:comic sans ms,sans-serif;=
font-size:small;color:#000000">The &#39;data&#39; variable had a new line a=
t the end. We removed the new line and it now works as expected.<br></div><=
/div><br><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">O=
n Fri, Jan 29, 2021 at 2:41 PM Peter van Dijk via Pdns-dev &lt;<a href=3D"m=
ailto:[email protected]">[email protected]</a>&gt; =
wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0=
px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello,<br=
>
<br>
On Fri, 2021-01-29 at 06:36 +0300, Pius Nganga via Pdns-dev wrote:<br>
&gt; Hi,<br>
&gt; <br>
&gt; We are using a lua script for filtering urls based on pre-set policies=
 inside the preresolve() method of pdns recursor. We are doing this by chec=
king dq.remoteaddr:toString() and reading the policies for it from sqlite d=
b then taking the necessary action( mark the query as either blocked or saf=
e.) Before returning the function, we are logging the result to syslog usin=
g pdnslog as follows;<br>
&gt; <br>
&gt; pdnslog(&#39;Network:&#39;..dq.remoteaddr:toString()..&#39;|device:&#3=
9;..device_mac..&#39;|ip:&#39;..device_ip..&#39;|url:&#39;..dq.qname:toStri=
ng()..&#39;|category:&#39;..data..&#39;|policy ID:&#39;..row.policy_id..&#3=
9;|Status:Safe&#39;)<br>
&gt; <br>
&gt; The blocking part is working as expected, the challenge is that the ab=
ove log shows as two lines on syslog or journalctl as shown below;<br>
&gt; <br>
&gt; Jan 29 01:25:35 ns pdns_recursor[24914]: Network:105.162.6.128|device:=
dd:ef:ca:d8:4e:74|ip:192.168.100.4|url:www.google.com.|category:Search Engi=
nes<br>
&gt; Jan 29 01:25:35 ns pdns_recursor[24914]: |ID:3|Status:Safe<br>
&gt; <br>
&gt; <br>
&gt; Our intention is to have it log on one line as;<br>
&gt; <br>
&gt; Jan 29 01:25:35 ns pdns_recursor[24914]: Network:105.162.6.128|dev:dd:=
ef:ca:d8:4e:74|ip:192.168.100.4|url:www.google.com.|category:Search Engines=
|ID:3|Status:Safe<br>
&gt; <br>
&gt; <br>
&gt; Any idea on how we can enforce pdnslog to write on a single line?<br>
<br>
I suspect your &#39;data&#39; variable ends in a new line. You&#39;ll have =
to remove that new line from it.<br>
<br>
Kind regards,<br>
-- <br>
Peter van Dijk<br>
PowerDNS.COM BV - <a href=3D"https://www.powerdns.com/" rel=3D"noreferrer" =
target=3D"_blank">https://www.powerdns.com/</a><br>
<br>
_______________________________________________<br>
Pdns-dev mailing list<br>
<a href=3D"mailto:[email protected]" target=3D"_blank">Pdns-dev=
@mailman.powerdns.com</a><br>
<a href=3D"https://mailman.powerdns.com/mailman/listinfo/pdns-dev" rel=3D"n=
oreferrer" target=3D"_blank">https://mailman.powerdns.com/mailman/listinfo/=
pdns-dev</a><br>
</blockquote></div>

--00000000000035964f05ba093098--

--===============6622038268137262714==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Pdns-dev mailing list
[email protected]
https://mailman.powerdns.com/mailman/listinfo/pdns-dev

--===============6622038268137262714==--