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

Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

Understanding generators in Python2019 Community Moderator ElectionGenerator function not working pythonFor loop not executing two timesGenerators - Printing generated valuesWhy can a python generator only be used once?What exactly do generators do?What does the “yield” keyword do?What does “list comprehension” mean? How does it work and how can I use it?sklearn Kfold acces single fold instead of for loopIs a generator the callable? Which is the generator?Apply Border To Range Of Cells Using OpenpyxlCalling an external command in PythonWhat are metaclasses in Python?What is the difference between @staticmethod and @classmethod?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?Understanding slice notationUnderstanding Python super() with __init__() methodsDoes Python have a string 'contains' substring method?

How can I change the color of pagination dots of UIPageControl?How to change UIPageControl dotsIs there a way to change page indicator dots colorCustomize dot with image of UIPageControl at index 0 of UIPageControlNo visible @interface for 'NSObject<PageControlDelegate>' declares the selector 'pageControlPageDidChange:'How to change the color of pagination dots in UIPageControl with a different color per pagepagecontrol indicator custom image instead of DefaultChanging the colour of UIPageControl dots in MonoTouchpagecontrol selectable page visibility color?Alternative way to load ViewControllers on a UIPageControlHow to set only layer.border-color for UIpage control dots in swiftHow can I develop for iPhone using a Windows development machine?How to change the name of an iOS app?UITableView - change section header coloruipagecontrol indicator(dot)issueCustom UIPageControl dots color not changingchange the interspace between UIPageControl dotsHow to change Status Bar text color in iOSHow can I change image tintColor in iOS and WatchKitUIPageControl dots with larger space in between each dotsHow to change the color of pagination dots in UIPageControl with a different color per page