[syslog-ng] Change Position Information inside Messasge

Laszlo Szemere (lszemere) Laszlo.Szemere at oneidentity.com
Fri Mar 27 20:04:48 UTC 2020


Hello,
 following the:
 - config
 - input
 - outputs



Config:
    @version: 3.26

    source s_net1 {
      udp(
        port(8001)
        flags(no-parse)
      );
    };

    destination d_file1 {
      file("/tmp/prefix-first-second-suffix.log"
        template("$1 - $2 - $3 - $4\n")
      );
    };

    destination d_file2 {
      file("/tmp/prefix-second-first-suffix.log"
        template("$1 - $3 - $2 - $4\n")
      );
    };

    rewrite r_rule {
      subst("([a-z]+)-([a-z]+)-([a-z]+)-([a-z]+)", "", value("MSG"), flags(store-matches));
    };

    log {
      source(s_net1);
      rewrite(r_rule);
      destination(d_file1);
      destination(d_file2);
    };



Message:
    echo "hello-foo-bar-world" > /dev/udp/127.0.0.1/8001
    echo hello-i-j-world > /dev/udp/127.0.0.1/8001

Output:
    szemere at tp:/tmp$ cat prefix-first-second-suffix.log
    hello - foo - bar - world
    hello - i - j - world

    szemere at tp:/tmp$ cat prefix-second-first-suffix.log
    hello - bar - foo - world
    hello - j - i - world




Best regards,
László Szemere


________________________________
From: syslog-ng <syslog-ng-bounces at lists.balabit.hu> on behalf of William Luiz Ribeiro Vasconcelos Da Silva <wsilva_ericsson at timbrasil.com.br>
Sent: Thursday, March 26, 2020 21:36
To: Syslog-ng users' and developers' mailing list <syslog-ng at lists.balabit.hu>
Subject: [syslog-ng] RES: Change Position Information inside Messasge

CAUTION: This email originated from outside of the organization. Do not follow guidance, click links, or open attachments unless you recognize the sender and know the content is safe.


Hi,

  Do you have any example to share?

Atenciosamente,

WILLIAM LUIZ R V SILVA
Mediation

Ericsson
Rua Maria Preste Maia, 300
02879-130, Brazil
Phone  +55 11   2760-3785
Mobile +55 11  97979-9886
wsilva_ericsson at timbrasil.com.br
https://nam05.safelinks.protection.outlook.com/?url=www.ericsson.com&data=02%7C01%7Claszlo.szemere%40oneidentity.com%7Cfba08320ff2d45ad333e08d7d1c557e6%7C91c369b51c9e439c989c1867ec606603%7C0%7C0%7C637208517827005664&sdata=2dZY0kDSq9UWK32%2F7hGwHujw2bqfYhPy7Kce7WCpHtk%3D&reserved=0



-----Mensagem original-----
De: syslog-ng <syslog-ng-bounces at lists.balabit.hu> Em nome de Laszlo Szemere (lszemere)
Enviada em: quinta-feira, 26 de março de 2020 17:01
Para: Syslog-ng users' and developers' mailing list <syslog-ng at lists.balabit.hu>
Assunto: Re: [syslog-ng] Change Position Information inside Messasge

Hello William,
 What you are looking for is the "store-matches" flag of the regular expressions. https://nam05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.syslog-ng.com%2Ftechnical-documents%2Fdoc%2Fsyslog-ng-open-source-edition%2F3.25%2Fadministration-guide%2F68%23TOPIC-1374104&data=02%7C01%7Claszlo.szemere%40oneidentity.com%7Cfba08320ff2d45ad333e08d7d1c557e6%7C91c369b51c9e439c989c1867ec606603%7C0%7C0%7C637208517827005664&sdata=TvYjtacvhyn%2F1HVUopa7zmS98DoD065LvnerpRZGrtg%3D&reserved=0

 You can "store" the matching part of a subst rewrite rule. Which can be later used in a template function, on the destination site. So you can "reassemble" your log message in any form you want.

Br,
Laci

________________________________________
From: syslog-ng <syslog-ng-bounces at lists.balabit.hu> on behalf of William Luiz Ribeiro Vasconcelos Da Silva <wsilva_ericsson at timbrasil.com.br>
Sent: Thursday, March 26, 2020 19:10
To: Syslog-ng users' and developers' mailing list
Subject: [syslog-ng] Change Position Information inside Messasge

CAUTION: This email originated from outside of the organization. Do not follow guidance, click links, or open attachments unless you recognize the sender and know the content is safe.

Hello everyone,

Is it possible to change a position of an information within the message?

From: 2020-03-26; 17: 55: 22; RTCGNMGA0101: RT_SRC_NAT_PBA_ALLOC :; 100.64.1.114:38784-38847; 177.51.112.218;

TO:
2020-03-26; 17: 55: 22; RTCGNMGA0101: RT_SRC_NAT_PBA_ALLOC:; 100.64.1.114; 177.51.112.218:38784-38847;

Basically, I would like to change the position of the connection port within the message.

How to do this?

TKS

Atenciosamente,

WILLIAM LUIZ R V SILVA
Mediation

Ericsson
Mobile +55 11  97979-9886
https://nam05.safelinks.protection.outlook.com/?url=www.ericsson.com&data=02%7C01%7Claszlo.szemere%40oneidentity.com%7Cfba08320ff2d45ad333e08d7d1c557e6%7C91c369b51c9e439c989c1867ec606603%7C0%7C0%7C637208517827005664&sdata=2dZY0kDSq9UWK32%2F7hGwHujw2bqfYhPy7Kce7WCpHtk%3D&reserved=0<https://nam05.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.ericsson.com%2F&data=02%7C01%7Claszlo.szemere%40oneidentity.com%7Cfba08320ff2d45ad333e08d7d1c557e6%7C91c369b51c9e439c989c1867ec606603%7C0%7C0%7C637208517827005664&sdata=BRPrwmu3c1k%2BQDk7JQJttwX3g9Shrx6r%2BGd6llYJqpk%3D&reserved=0>

[Descrição: Descrição: Ericsson]<https://nam05.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.ericsson.com%2F&data=02%7C01%7Claszlo.szemere%40oneidentity.com%7Cfba08320ff2d45ad333e08d7d1c557e6%7C91c369b51c9e439c989c1867ec606603%7C0%7C0%7C637208517827005664&sdata=BRPrwmu3c1k%2BQDk7JQJttwX3g9Shrx6r%2BGd6llYJqpk%3D&reserved=0>


Esta mensagem, incluindo seus anexos, pode conter informações privilegiadas e/ou de caráter confidencial, não podendo ser retransmitida sem autorização do remetente. Se você não é o destinatário ou pessoa autorizada para recebê-la, informamos que o seu uso, divulgação, cópia ou arquivamento são proibidos. Portanto, se você recebeu esta mensagem por engano, por favor nos informe respondendo imediatamente a este e-mail e delete o seu conteúdo.

This message, including its attachments, may contain privileged or confidential information, and it must not be fowarded without the express authorization of the sender. If you are not the intended recipient, we hereby inform you that the use, disclosure, copy or filing are forbidden. So, if you received this message as a mistake, please inform us by answering this e-mail and deleting its contents

Questo messaggio, inclusi gli allegati, potrebbe contenere informazioni privilegiate e/o riservate, e non deve essere ritrasmesse senza l'autorizzazione del mittente. Se non siete il destinatario o la persona autorizzata a riceverlo, informiamo che il suo utilizzo, diffusione, copia o archiviazione sono proibite. Quindi, se avete ricevuto questo messaggio per errore, per cortesia ci informi rispondendo immediatamente a questa email e cancelli il suo contenuto
______________________________________________________________________________
Member info: https://nam05.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.balabit.hu%2Fmailman%2Flistinfo%2Fsyslog-ng&data=02%7C01%7Claszlo.szemere%40oneidentity.com%7Cfba08320ff2d45ad333e08d7d1c557e6%7C91c369b51c9e439c989c1867ec606603%7C0%7C0%7C637208517827005664&sdata=6HOVn0d5QrU3J9npEHbeyNtCuOT1un9ifxG%2BMlrIUDM%3D&reserved=0
Documentation: https://nam05.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.balabit.com%2Fsupport%2Fdocumentation%2F%3Fproduct%3Dsyslog-ng&data=02%7C01%7Claszlo.szemere%40oneidentity.com%7Cfba08320ff2d45ad333e08d7d1c557e6%7C91c369b51c9e439c989c1867ec606603%7C0%7C0%7C637208517827005664&sdata=ra%2FXK9VZ1X%2FqOxY%2FzztPsmQDhhJzFFuhiS%2Fl15wBfV8%3D&reserved=0
FAQ: https://nam05.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.balabit.com%2Fwiki%2Fsyslog-ng-faq&data=02%7C01%7Claszlo.szemere%40oneidentity.com%7Cfba08320ff2d45ad333e08d7d1c557e6%7C91c369b51c9e439c989c1867ec606603%7C0%7C0%7C637208517827005664&sdata=kC%2B5oIy7WnkneMvrhYVmeqBIcdhI01aMLzND5qK%2BSeA%3D&reserved=0

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.balabit.hu/pipermail/syslog-ng/attachments/20200327/ed9607ef/attachment-0001.html>


More information about the syslog-ng mailing list