Archived community.zenoss.org | full text search
Skip navigation
2771 Views 13 Replies Latest reply: Nov 8, 2012 12:18 AM by chazzvid RSS
sadat khan Rank: White Belt 18 posts since
Sep 6, 2012
Currently Being Moderated

Oct 18, 2012 10:36 AM

transform to split event message

hello,

       i have a script which parses weblogic logs at 5 minute intervals, extracts the lines with error codes and for each line , sends the following to zenoss:-

 

timestamp

error code

error message

 

            i am sending the message separated by new line (\n)... at zenoss i am trying to apply a transform to split the event message according to \n and then create separate events for each line... however the split does not seem to work ... i am doing something like - linelist=evt.message.split('\n') - and this should populate the list linelist with the lines in event message as items... but that is not happening. Any pointers ?

 

regards

 

Sadat

  • jshardlow Rank: Green Belt 98 posts since
    Jun 12, 2008
    Currently Being Moderated
    1. Oct 18, 2012 10:45 AM (in response to sadat khan)
    Re: transform to split event message

    To get each line, I think it'd be something like:

     

    linelist=evt.message.split('\n')
    line1=linelist[0]
    line2=linelist[1]
    line3=linelist[2]
    

     

    Though the split may not be seeing '\n' as a line break. So you could try adding an escape character to treat the \n properly:

     

    linelist=evt.message.split('\\n')
    
  • jshardlow Rank: Green Belt 98 posts since
    Jun 12, 2008
    Currently Being Moderated
    3. Oct 19, 2012 5:54 AM (in response to sadat khan)
    Re: transform to split event message

    Your loop looks to be OK. This is it running in a Python shell:

     

    >>> txt="one/ntwo/nthree"
    >>> linelist=txt.split('/n')
    >>> for line in linelist:
    ...   print "LINE " + line
    ... 
    LINE one
    LINE two
    LINE three
    >>> 
    

     

    As you may have figured out what your code snippet is doing is repeatedly manipulating the current event. Unfortunately I don't know how to create a new event in Python inside a transform. I've been having a look round, and the only thing I've found concerns creating an event from outside of Zenoss: docs/DOC-2476

     

    You may be able to get some ideas from that link. Sorry I can't be of more help.

  • jshardlow Rank: Green Belt 98 posts since
    Jun 12, 2008
    Currently Being Moderated
    5. Oct 19, 2012 7:30 AM (in response to sadat khan)
    Re: transform to split event message

    You might see something in zenhub.log if you change the zenhub log level to DEBUG.

  • dpetzel Rank: Brown Belt 1,141 posts since
    Oct 17, 2010
    Currently Being Moderated
    7. Oct 19, 2012 1:16 PM (in response to sadat khan)
    Re: transform to split event message

    zenhub.log will give you the details yor after. Its a little tough to pick them out, and its been a little bit since I looked at it, but it says something about "before transform" and "after transform" (thats not the exact wording). The debug log will show you what happened to the message after each transform

  • jshardlow Rank: Green Belt 98 posts since
    Jun 12, 2008
    Currently Being Moderated
    10. Oct 24, 2012 10:36 AM (in response to sadat khan)
    Re: transform to split event message

    Setting zenhub log level at debug means that it will show any messages of level debug and above. eg. info, warning, error, critical.

  • chazzvid Newbie 5 posts since
    Dec 4, 2011
    Currently Being Moderated
    13. Nov 8, 2012 12:18 AM (in response to sadat khan)
    Re: transform to split event message

    Just a thought, maybe a transform is not the best place to run your external event scripts? 

     

    Should it be better as an event trigger? 

More Like This

  • Retrieving data ...

Legend

  • Correct Answers - 4 points
  • Helpful Answers - 2 points