rsyslog 7 search and replace message content2019 Community Moderator ElectionLooping through the content of a file in Bashsed command find and replace in file and overwrite file doesn't work, it empties the fileRsyslog search and replace outputRsyslog replace newline to <br/> in message partConfigure rsyslog to log all commandsrsyslog template - parse failure in regular expressionReading RSysLog tcp messagesRsyslog incoming messages rotationOwn format rsyslog messageFormat rsyslog messages - remove IP of logserver

Gantt Chart like rectangles with log scale

Is it true that good novels will automatically sell themselves on Amazon (and so on) and there is no need for one to waste time promoting?

Life insurance that covers only simultaneous/dual deaths

Dice rolling probability game

Is it possible to upcast ritual spells?

Why do passenger jet manufacturers design their planes with stall prevention systems?

If the DM rolls initiative once for a group of monsters, how do end-of-turn effects work?

Provisioning profile doesn't include the application-identifier and keychain-access-groups entitlements

What approach do we need to follow for projects without a test environment?

What do Xenomorphs eat in the Alien series?

If I can solve Sudoku can I solve Travelling Salesman Problem(TSP)? If yes, how?

A Cautionary Suggestion

How to read the value of this capacitor?

how to write formula in word in latex

How to write cleanly even if my character uses expletive language?

Is a party consisting of only a bard, a cleric, and a warlock functional long-term?

Science-fiction short story where space navy wanted hospital ships and settlers had guns mounted everywhere

Happy pi day, everyone!

Look at your watch and tell me what time is it. vs Look at your watch and tell me what time it is

Creature kill and resurrect effects on the stack interaction?

What has been your most complicated TikZ drawing?

Official degrees of earth’s rotation per day

How to create the Curved texte?

What options are left, if Britain cannot decide?



rsyslog 7 search and replace message content



2019 Community Moderator ElectionLooping through the content of a file in Bashsed command find and replace in file and overwrite file doesn't work, it empties the fileRsyslog search and replace outputRsyslog replace newline to <br/> in message partConfigure rsyslog to log all commandsrsyslog template - parse failure in regular expressionReading RSysLog tcp messagesRsyslog incoming messages rotationOwn format rsyslog messageFormat rsyslog messages - remove IP of logserver










1















In rsyslog I am trying to search for a certain keyword in my log message and replace with another but seem to be running in to an issue. Looked around and found very few examples of this but couldn't figure out what am I doing wrong.



I have the following in myrsyslog.conf file



template(name="logline" type="string" string="%timegenerated% %HOSTNAME% %syslogtag% %$!msg%n")

if re_match($msg,'APP_MAJOR_ALERT$')
then
set $!msg = replace($msg, "APP_MAJOR_ALERT", "APP_MINOR_ALERT");
else
set $!msg = $msg;


action(type="omfile" file="/tmp/logfile" template="logline")


Now this is similar to other examples floating around, I am using re_match to search for lines ending with the search keyword (APP_MAJOR_ALERT) and if it matches then I am replacing MAJOR with MINOR. The else part does nothing but prints the message as is, which seems to work fine.



However in case of a match I am seeing the log simply printing "0" as message. Going through rsyslog (version 7.4.10) documentation indicates that the replace function should be returning the modified string but in my case it returns a "0" I guess.



Sep 26 14:41:22 localhost ec2-user: 0


The test input provided was



logger "ERROR o.s.c.c.d.h.DiscoveryClientHealthIndicator - Error com.ecwid.consul.v1.OperationException: OperationException(statusCode=500, statusMessage='Internal Server Error', statusContent='rpc error: rpc error: No cluster leader' svc_APP_GROUP,id_APP_NAME,APP_MAJOR_ALERT"


Cant figure out where I am wrong. Perhaps a silly mistake but unable to spot it. Few pair of eyes might help here.










share|improve this question
























  • Unix & Linux might be a better place to post this.

    – Barmar
    Sep 26 '18 at 21:00











  • Added to Unix & Linux as well, hoping for an answer.

    – Anand Nadar
    Sep 26 '18 at 21:25












  • Arent't you missing a set, as in set $!msg = replace...?

    – meuh
    Sep 27 '18 at 9:46











  • Somehow that went missing in my copy paste. Checked my configuration and it has the "set $!msg" for both assignments. Corrected my question.

    – Anand Nadar
    Sep 27 '18 at 12:53











  • Alright so going through documentation of rsyslog 7 (rsyslog.com/doc/v7-stable/rainerscript/functions.html) indicates that replace function wasn't available at that time. So I may have to find another way of doing this since my CentOs isnt compatible with rsyslog 8.

    – Anand Nadar
    Sep 27 '18 at 17:23















1















In rsyslog I am trying to search for a certain keyword in my log message and replace with another but seem to be running in to an issue. Looked around and found very few examples of this but couldn't figure out what am I doing wrong.



I have the following in myrsyslog.conf file



template(name="logline" type="string" string="%timegenerated% %HOSTNAME% %syslogtag% %$!msg%n")

if re_match($msg,'APP_MAJOR_ALERT$')
then
set $!msg = replace($msg, "APP_MAJOR_ALERT", "APP_MINOR_ALERT");
else
set $!msg = $msg;


action(type="omfile" file="/tmp/logfile" template="logline")


Now this is similar to other examples floating around, I am using re_match to search for lines ending with the search keyword (APP_MAJOR_ALERT) and if it matches then I am replacing MAJOR with MINOR. The else part does nothing but prints the message as is, which seems to work fine.



However in case of a match I am seeing the log simply printing "0" as message. Going through rsyslog (version 7.4.10) documentation indicates that the replace function should be returning the modified string but in my case it returns a "0" I guess.



Sep 26 14:41:22 localhost ec2-user: 0


The test input provided was



logger "ERROR o.s.c.c.d.h.DiscoveryClientHealthIndicator - Error com.ecwid.consul.v1.OperationException: OperationException(statusCode=500, statusMessage='Internal Server Error', statusContent='rpc error: rpc error: No cluster leader' svc_APP_GROUP,id_APP_NAME,APP_MAJOR_ALERT"


Cant figure out where I am wrong. Perhaps a silly mistake but unable to spot it. Few pair of eyes might help here.










share|improve this question
























  • Unix & Linux might be a better place to post this.

    – Barmar
    Sep 26 '18 at 21:00











  • Added to Unix & Linux as well, hoping for an answer.

    – Anand Nadar
    Sep 26 '18 at 21:25












  • Arent't you missing a set, as in set $!msg = replace...?

    – meuh
    Sep 27 '18 at 9:46











  • Somehow that went missing in my copy paste. Checked my configuration and it has the "set $!msg" for both assignments. Corrected my question.

    – Anand Nadar
    Sep 27 '18 at 12:53











  • Alright so going through documentation of rsyslog 7 (rsyslog.com/doc/v7-stable/rainerscript/functions.html) indicates that replace function wasn't available at that time. So I may have to find another way of doing this since my CentOs isnt compatible with rsyslog 8.

    – Anand Nadar
    Sep 27 '18 at 17:23













1












1








1


0






In rsyslog I am trying to search for a certain keyword in my log message and replace with another but seem to be running in to an issue. Looked around and found very few examples of this but couldn't figure out what am I doing wrong.



I have the following in myrsyslog.conf file



template(name="logline" type="string" string="%timegenerated% %HOSTNAME% %syslogtag% %$!msg%n")

if re_match($msg,'APP_MAJOR_ALERT$')
then
set $!msg = replace($msg, "APP_MAJOR_ALERT", "APP_MINOR_ALERT");
else
set $!msg = $msg;


action(type="omfile" file="/tmp/logfile" template="logline")


Now this is similar to other examples floating around, I am using re_match to search for lines ending with the search keyword (APP_MAJOR_ALERT) and if it matches then I am replacing MAJOR with MINOR. The else part does nothing but prints the message as is, which seems to work fine.



However in case of a match I am seeing the log simply printing "0" as message. Going through rsyslog (version 7.4.10) documentation indicates that the replace function should be returning the modified string but in my case it returns a "0" I guess.



Sep 26 14:41:22 localhost ec2-user: 0


The test input provided was



logger "ERROR o.s.c.c.d.h.DiscoveryClientHealthIndicator - Error com.ecwid.consul.v1.OperationException: OperationException(statusCode=500, statusMessage='Internal Server Error', statusContent='rpc error: rpc error: No cluster leader' svc_APP_GROUP,id_APP_NAME,APP_MAJOR_ALERT"


Cant figure out where I am wrong. Perhaps a silly mistake but unable to spot it. Few pair of eyes might help here.










share|improve this question
















In rsyslog I am trying to search for a certain keyword in my log message and replace with another but seem to be running in to an issue. Looked around and found very few examples of this but couldn't figure out what am I doing wrong.



I have the following in myrsyslog.conf file



template(name="logline" type="string" string="%timegenerated% %HOSTNAME% %syslogtag% %$!msg%n")

if re_match($msg,'APP_MAJOR_ALERT$')
then
set $!msg = replace($msg, "APP_MAJOR_ALERT", "APP_MINOR_ALERT");
else
set $!msg = $msg;


action(type="omfile" file="/tmp/logfile" template="logline")


Now this is similar to other examples floating around, I am using re_match to search for lines ending with the search keyword (APP_MAJOR_ALERT) and if it matches then I am replacing MAJOR with MINOR. The else part does nothing but prints the message as is, which seems to work fine.



However in case of a match I am seeing the log simply printing "0" as message. Going through rsyslog (version 7.4.10) documentation indicates that the replace function should be returning the modified string but in my case it returns a "0" I guess.



Sep 26 14:41:22 localhost ec2-user: 0


The test input provided was



logger "ERROR o.s.c.c.d.h.DiscoveryClientHealthIndicator - Error com.ecwid.consul.v1.OperationException: OperationException(statusCode=500, statusMessage='Internal Server Error', statusContent='rpc error: rpc error: No cluster leader' svc_APP_GROUP,id_APP_NAME,APP_MAJOR_ALERT"


Cant figure out where I am wrong. Perhaps a silly mistake but unable to spot it. Few pair of eyes might help here.







linux unix centos rsyslog






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 27 '18 at 12:52







Anand Nadar

















asked Sep 26 '18 at 19:19









Anand NadarAnand Nadar

100212




100212












  • Unix & Linux might be a better place to post this.

    – Barmar
    Sep 26 '18 at 21:00











  • Added to Unix & Linux as well, hoping for an answer.

    – Anand Nadar
    Sep 26 '18 at 21:25












  • Arent't you missing a set, as in set $!msg = replace...?

    – meuh
    Sep 27 '18 at 9:46











  • Somehow that went missing in my copy paste. Checked my configuration and it has the "set $!msg" for both assignments. Corrected my question.

    – Anand Nadar
    Sep 27 '18 at 12:53











  • Alright so going through documentation of rsyslog 7 (rsyslog.com/doc/v7-stable/rainerscript/functions.html) indicates that replace function wasn't available at that time. So I may have to find another way of doing this since my CentOs isnt compatible with rsyslog 8.

    – Anand Nadar
    Sep 27 '18 at 17:23

















  • Unix & Linux might be a better place to post this.

    – Barmar
    Sep 26 '18 at 21:00











  • Added to Unix & Linux as well, hoping for an answer.

    – Anand Nadar
    Sep 26 '18 at 21:25












  • Arent't you missing a set, as in set $!msg = replace...?

    – meuh
    Sep 27 '18 at 9:46











  • Somehow that went missing in my copy paste. Checked my configuration and it has the "set $!msg" for both assignments. Corrected my question.

    – Anand Nadar
    Sep 27 '18 at 12:53











  • Alright so going through documentation of rsyslog 7 (rsyslog.com/doc/v7-stable/rainerscript/functions.html) indicates that replace function wasn't available at that time. So I may have to find another way of doing this since my CentOs isnt compatible with rsyslog 8.

    – Anand Nadar
    Sep 27 '18 at 17:23
















Unix & Linux might be a better place to post this.

– Barmar
Sep 26 '18 at 21:00





Unix & Linux might be a better place to post this.

– Barmar
Sep 26 '18 at 21:00













Added to Unix & Linux as well, hoping for an answer.

– Anand Nadar
Sep 26 '18 at 21:25






Added to Unix & Linux as well, hoping for an answer.

– Anand Nadar
Sep 26 '18 at 21:25














Arent't you missing a set, as in set $!msg = replace...?

– meuh
Sep 27 '18 at 9:46





Arent't you missing a set, as in set $!msg = replace...?

– meuh
Sep 27 '18 at 9:46













Somehow that went missing in my copy paste. Checked my configuration and it has the "set $!msg" for both assignments. Corrected my question.

– Anand Nadar
Sep 27 '18 at 12:53





Somehow that went missing in my copy paste. Checked my configuration and it has the "set $!msg" for both assignments. Corrected my question.

– Anand Nadar
Sep 27 '18 at 12:53













Alright so going through documentation of rsyslog 7 (rsyslog.com/doc/v7-stable/rainerscript/functions.html) indicates that replace function wasn't available at that time. So I may have to find another way of doing this since my CentOs isnt compatible with rsyslog 8.

– Anand Nadar
Sep 27 '18 at 17:23





Alright so going through documentation of rsyslog 7 (rsyslog.com/doc/v7-stable/rainerscript/functions.html) indicates that replace function wasn't available at that time. So I may have to find another way of doing this since my CentOs isnt compatible with rsyslog 8.

– Anand Nadar
Sep 27 '18 at 17:23












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
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',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
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
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f52524738%2frsyslog-7-search-and-replace-message-content%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • 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%2fstackoverflow.com%2fquestions%2f52524738%2frsyslog-7-search-and-replace-message-content%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

Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived

Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme