Hello,

I tried with this:
set $.newmsg = replace("nan nan nan","nan","'nan'::double precision");
template(name="RMM_energy_value" type="list" option.sql="on") {
  constant(value="INSERT INTO energyvalue (datetime, made_by, Nh_T1, Nh_T2, 
Ph_im_T1, Ph_im_T2, Ph_ex_T1, Ph_ex_T2, Qh_im_T1, Qh_im_T2, Qh_ex_T1, Qh_ex_T2 
) values ('")
  property(name="timereported" dateformat="pgsql" date.inUTC="on")
  constant(value="','")
  property(name="hostname")
  constant(value="',")
  property(name="$.newmsg")
  constant(value=")")
}

and with:
set $.newmsg = replace($msg,"nan","'nan'::double precision”);

and with:
set $.newmsg = “hello”;

but postgresql db receives this:
INSERT INTO energyvalue (datetime, made_by, Nh_T1, Nh_T2, Ph_im_T1, Ph_im_T2, 
Ph_ex_T1, Ph_ex_T2, Qh_im_T1, Qh_im_T2, Qh_ex_T1, Qh_ex_T2 ) values 
('2020-12-17 18:46:42','18137709’,)

Seems that $.newmsg is empty.

What I’m doing wrong?

thanks
Salvatore

> On 17 Dec 2020, at 18:34, Salvatore Totaro via rsyslog 
> <rsyslog@lists.adiscon.com> wrote:
> 
> Hi,
> 
> I have a msg property made in this way:
> 
> 1.5470373000e+05,nan,1.5060465000e+05,nan,2.1682000000e+02,nan,2.4761550000e+04,nan,1.6121420000e+04,nan
> 
> In order to insert this row in my postgres db I use this template:
> 
> template(name="energy_value" type="list" option.sql="on") {
>  constant(value="INSERT INTO energyvalue (datetime, made_by, Nh_T1, Nh_T2, 
> Ph_im_T1, Ph_im_T2, Ph_ex_T1, Ph_ex_T2, Qh_im_T1, Qh_im_T2, Qh_ex_T1, 
> Qh_ex_T2 ) values ('")
>  property(name="timereported" dateformat="pgsql" date.inUTC="on")
>  constant(value="','")
>  property(name="hostname")
>  constant(value="',")
>  property(name="msg")
>  constant(value=")")
> }
> 
> but postgresql has problem with nan value. The solution is to replace nan 
> token with ‘nan’::double precision
> 
> I tried to use replace function but with no luck. What is the right way to 
> replace a regex like (N|nA|aN|n) with ‘nan’::double precision?
> 
> thanks
> Salvatore
> 
> 
> _______________________________________________
> rsyslog mailing list
> https://lists.adiscon.net/mailman/listinfo/rsyslog
> http://www.rsyslog.com/professional-services/
> What's up with rsyslog? Follow https://twitter.com/rgerhards
> NOTE WELL: This is a PUBLIC mailing list, posts are ARCHIVED by a myriad of 
> sites beyond our control. PLEASE UNSUBSCRIBE and DO NOT POST if you DON'T 
> LIKE THAT.

_______________________________________________
rsyslog mailing list
https://lists.adiscon.net/mailman/listinfo/rsyslog
http://www.rsyslog.com/professional-services/
What's up with rsyslog? Follow https://twitter.com/rgerhards
NOTE WELL: This is a PUBLIC mailing list, posts are ARCHIVED by a myriad of 
sites beyond our control. PLEASE UNSUBSCRIBE and DO NOT POST if you DON'T LIKE 
THAT.

Reply via email to