Rsyslog alter log line before forwarding











up vote
0
down vote

favorite












being on Ubuntu 16.04.5 LTS with rsyslogd.



We have the following situation:



(1) An appliance forwards syslog to the Ubuntu host.
(2) Ubuntu Host stores those forwarded messages in a separate logfile
(3) Ubuntu Host also forwards this to a 3rd machine



Details how configuration currently looks like



(1)
In /etc/rsyslog.conf, follwing has been enabled:



# provides UDP syslog reception
module(load="imudp")
input(type="imudp" port="514")

# provides TCP syslog reception
module(load="imtcp")
input(type="imtcp" port="514")


(2)
Has been achieved by creating 30-remotehosts.conf in /etc/rsyslog.d with following content:



:fromhost-ip, isequal, "<sending_IP>" /var/log/remotesyslog/<name>.log
& ~


(3) has been achieved by way of creating 10-send_to_other_hosts.conf in /etc/rsyslog.d with following content:



:fromhost-ip, isequal, "<sending_IP>"   @<destination_IP>:514


So far so good, works as expected.



However, what we would need now is to alter the logline before sending to the destination.



One example log line currently is



Dec  7 11:10:07 srvde450.rce-group.local [S=582442040] [SID=9642c9:20:3850677]  1 RTP packets lost: CID=217 [Code:0x600b] [CID:217] [Time:07-12@10:10:13]


We would neet it to be changed to the following before sending to the destination:



[S=582442040] [SID=9642c9:20:3850677]  1 RTP packets lost: CID=217 [Code:0x600b] [CID:217] [Time:07-12@10:10:13]


So remove timestamp and source.



How could that be achieved?










share|improve this question









New contributor




bezibaerchen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
























    up vote
    0
    down vote

    favorite












    being on Ubuntu 16.04.5 LTS with rsyslogd.



    We have the following situation:



    (1) An appliance forwards syslog to the Ubuntu host.
    (2) Ubuntu Host stores those forwarded messages in a separate logfile
    (3) Ubuntu Host also forwards this to a 3rd machine



    Details how configuration currently looks like



    (1)
    In /etc/rsyslog.conf, follwing has been enabled:



    # provides UDP syslog reception
    module(load="imudp")
    input(type="imudp" port="514")

    # provides TCP syslog reception
    module(load="imtcp")
    input(type="imtcp" port="514")


    (2)
    Has been achieved by creating 30-remotehosts.conf in /etc/rsyslog.d with following content:



    :fromhost-ip, isequal, "<sending_IP>" /var/log/remotesyslog/<name>.log
    & ~


    (3) has been achieved by way of creating 10-send_to_other_hosts.conf in /etc/rsyslog.d with following content:



    :fromhost-ip, isequal, "<sending_IP>"   @<destination_IP>:514


    So far so good, works as expected.



    However, what we would need now is to alter the logline before sending to the destination.



    One example log line currently is



    Dec  7 11:10:07 srvde450.rce-group.local [S=582442040] [SID=9642c9:20:3850677]  1 RTP packets lost: CID=217 [Code:0x600b] [CID:217] [Time:07-12@10:10:13]


    We would neet it to be changed to the following before sending to the destination:



    [S=582442040] [SID=9642c9:20:3850677]  1 RTP packets lost: CID=217 [Code:0x600b] [CID:217] [Time:07-12@10:10:13]


    So remove timestamp and source.



    How could that be achieved?










    share|improve this question









    New contributor




    bezibaerchen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.






















      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      being on Ubuntu 16.04.5 LTS with rsyslogd.



      We have the following situation:



      (1) An appliance forwards syslog to the Ubuntu host.
      (2) Ubuntu Host stores those forwarded messages in a separate logfile
      (3) Ubuntu Host also forwards this to a 3rd machine



      Details how configuration currently looks like



      (1)
      In /etc/rsyslog.conf, follwing has been enabled:



      # provides UDP syslog reception
      module(load="imudp")
      input(type="imudp" port="514")

      # provides TCP syslog reception
      module(load="imtcp")
      input(type="imtcp" port="514")


      (2)
      Has been achieved by creating 30-remotehosts.conf in /etc/rsyslog.d with following content:



      :fromhost-ip, isequal, "<sending_IP>" /var/log/remotesyslog/<name>.log
      & ~


      (3) has been achieved by way of creating 10-send_to_other_hosts.conf in /etc/rsyslog.d with following content:



      :fromhost-ip, isequal, "<sending_IP>"   @<destination_IP>:514


      So far so good, works as expected.



      However, what we would need now is to alter the logline before sending to the destination.



      One example log line currently is



      Dec  7 11:10:07 srvde450.rce-group.local [S=582442040] [SID=9642c9:20:3850677]  1 RTP packets lost: CID=217 [Code:0x600b] [CID:217] [Time:07-12@10:10:13]


      We would neet it to be changed to the following before sending to the destination:



      [S=582442040] [SID=9642c9:20:3850677]  1 RTP packets lost: CID=217 [Code:0x600b] [CID:217] [Time:07-12@10:10:13]


      So remove timestamp and source.



      How could that be achieved?










      share|improve this question









      New contributor




      bezibaerchen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      being on Ubuntu 16.04.5 LTS with rsyslogd.



      We have the following situation:



      (1) An appliance forwards syslog to the Ubuntu host.
      (2) Ubuntu Host stores those forwarded messages in a separate logfile
      (3) Ubuntu Host also forwards this to a 3rd machine



      Details how configuration currently looks like



      (1)
      In /etc/rsyslog.conf, follwing has been enabled:



      # provides UDP syslog reception
      module(load="imudp")
      input(type="imudp" port="514")

      # provides TCP syslog reception
      module(load="imtcp")
      input(type="imtcp" port="514")


      (2)
      Has been achieved by creating 30-remotehosts.conf in /etc/rsyslog.d with following content:



      :fromhost-ip, isequal, "<sending_IP>" /var/log/remotesyslog/<name>.log
      & ~


      (3) has been achieved by way of creating 10-send_to_other_hosts.conf in /etc/rsyslog.d with following content:



      :fromhost-ip, isequal, "<sending_IP>"   @<destination_IP>:514


      So far so good, works as expected.



      However, what we would need now is to alter the logline before sending to the destination.



      One example log line currently is



      Dec  7 11:10:07 srvde450.rce-group.local [S=582442040] [SID=9642c9:20:3850677]  1 RTP packets lost: CID=217 [Code:0x600b] [CID:217] [Time:07-12@10:10:13]


      We would neet it to be changed to the following before sending to the destination:



      [S=582442040] [SID=9642c9:20:3850677]  1 RTP packets lost: CID=217 [Code:0x600b] [CID:217] [Time:07-12@10:10:13]


      So remove timestamp and source.



      How could that be achieved?







      linux ubuntu rsyslog rsyslogd






      share|improve this question









      New contributor




      bezibaerchen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question









      New contributor




      bezibaerchen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question








      edited 2 days ago





















      New contributor




      bezibaerchen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 2 days ago









      bezibaerchen

      11




      11




      New contributor




      bezibaerchen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      bezibaerchen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      bezibaerchen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote













          You should be able to do this by specifying a template for the data which would just have the msg field. Note, however, that the remote server may not parse the resulting non-standard line, so it may not be able to handle it using a default setup.



          Create a template with, for example,



          $template myedit,"%msg%n"


          and use it in your filter line:



          :fromhost-ip, isequal, "<sending_IP>"   @<destination_IP>:514;myedit





          share|improve this answer





















            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "106"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });






            bezibaerchen is a new contributor. Be nice, and check out our Code of Conduct.










            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f486550%2frsyslog-alter-log-line-before-forwarding%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            1
            down vote













            You should be able to do this by specifying a template for the data which would just have the msg field. Note, however, that the remote server may not parse the resulting non-standard line, so it may not be able to handle it using a default setup.



            Create a template with, for example,



            $template myedit,"%msg%n"


            and use it in your filter line:



            :fromhost-ip, isequal, "<sending_IP>"   @<destination_IP>:514;myedit





            share|improve this answer

























              up vote
              1
              down vote













              You should be able to do this by specifying a template for the data which would just have the msg field. Note, however, that the remote server may not parse the resulting non-standard line, so it may not be able to handle it using a default setup.



              Create a template with, for example,



              $template myedit,"%msg%n"


              and use it in your filter line:



              :fromhost-ip, isequal, "<sending_IP>"   @<destination_IP>:514;myedit





              share|improve this answer























                up vote
                1
                down vote










                up vote
                1
                down vote









                You should be able to do this by specifying a template for the data which would just have the msg field. Note, however, that the remote server may not parse the resulting non-standard line, so it may not be able to handle it using a default setup.



                Create a template with, for example,



                $template myedit,"%msg%n"


                and use it in your filter line:



                :fromhost-ip, isequal, "<sending_IP>"   @<destination_IP>:514;myedit





                share|improve this answer












                You should be able to do this by specifying a template for the data which would just have the msg field. Note, however, that the remote server may not parse the resulting non-standard line, so it may not be able to handle it using a default setup.



                Create a template with, for example,



                $template myedit,"%msg%n"


                and use it in your filter line:



                :fromhost-ip, isequal, "<sending_IP>"   @<destination_IP>:514;myedit






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 2 days ago









                meuh

                31.2k11754




                31.2k11754






















                    bezibaerchen is a new contributor. Be nice, and check out our Code of Conduct.










                    draft saved

                    draft discarded


















                    bezibaerchen is a new contributor. Be nice, and check out our Code of Conduct.













                    bezibaerchen is a new contributor. Be nice, and check out our Code of Conduct.












                    bezibaerchen is a new contributor. Be nice, and check out our Code of Conduct.
















                    Thanks for contributing an answer to Unix & Linux Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f486550%2frsyslog-alter-log-line-before-forwarding%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Accessing regular linux commands in Huawei's Dopra Linux

                    Can't connect RFCOMM socket: Host is down

                    Kernel panic - not syncing: Fatal Exception in Interrupt