Getting Data In

Question in sendemail.py

hjwang
Contributor

i found the part of code in sendemail.py is as follow:

if  len(results) != 0:
        cols = []
        for k,v in results[0].items():
           **# ignore attributes that start with "_"
           if k.startswith("_") and k!="_raw" and k!="_time":
               continue**
           cols.append(k)

        # output column names
        for col in cols:
            text += "<th>" + col + "</th>"
        text += "</tr>\n"
        # output each result's values
        for result in results:
            text += "<tr valign=top>"
            for col in cols:
                val = result.get(col, "")
                escval = saxutils.escape(val)
                text += "<td><pre>" + escval + "</pre></td>"
            text += "</tr>\n"
        text += "</table>"
return text

in this code, the column starts with "_" will be ignore and should not be append into cols list, but i found the search result in email alert still contain this column, unless i use field- command then it would be removed, do i missunderstand it? thanks and regards,

Tags (2)
0 Karma
1 Solution

southeringtonp
Motivator

What field is showing up that you don't want? Is it _time?

The script should remove all columns that begin with an underscore, except for _time and _raw.

If either of those is your unwanted field, then yes, you'll to either use fields - to get override the sendemail script with your own version.

View solution in original post

0 Karma

southeringtonp
Motivator

What field is showing up that you don't want? Is it _time?

The script should remove all columns that begin with an underscore, except for _time and _raw.

If either of those is your unwanted field, then yes, you'll to either use fields - to get override the sendemail script with your own version.

0 Karma

hjwang
Contributor

Thanks,southeringtonp, now i understand.

0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...