I have a table in which one column is text which may or may not include a URL. (Think like a twitter feed). Is there an easy way to make the URL's clickable or do I need to format the text somehow?
asked 26 Oct '10, 19:19
There is no way that I know of to do this with the current table modules. You would need to super one of the existing table modules or roll your own special module.
answered 26 Oct '10, 22:12
So I used a big hammer to simply copy all the SimpleResultsTable files in $SPLUNKHOME/share/splunk/search_mrsparkle/modules/results to URLResultsTable and then added the following code (stolen from here: http://stackoverflow.com/questions/1112012/replace-url-with-a-link-using-regex-in-python)
PAT1 = re.compile(r"(^|[\n ])(([\w]+?://[\w#$%&~.-;:=,?@+])(/[\w#$%&~/.-;:=,?@+])?)", re.IGNORECASE | re.DOTALL)
PAT2 = re.compile(r"#(^|[\n ])(((www|ftp).[\w#$%&~.-;:=,?@+])(/[\w#$%&~/.-;:=,?@+])?)", re.IGNORECASE | re.DOTALL)
An then right before the return of generateResults()
It sounds like this might be easier to do in application.js, but I'm not sure how to filter the entire output stream from there.
answered 12 Nov '10, 20:28
Note that this becomes quite easy if you use the Sideview Table module instead of the SimpleResultsTable module, and it doesn't require writing a custom module or any custom code at all.
Say your field was called "url", and say it was a fully formed URL, including the
There are docs about this feature within Sideview Utils itself. Note that you'll need a relatively recent version of Sideview Utils (currently 2.3) from the Sideview site ( http://sideviewapps.com/apps/sideview-utils ) and not the older version available on Splunkbase.
Once you get the app installed/upgraded, you can find those docs under "Module Documentation > The Table Module > Table - Embedding Examples".
To paraphrase the official docs though, if the Table finds itself with any module immediately downstream that has a group attribute matching "row.fields.someField", and it finds that it actually has a field called "someField" in the results it's rendering, then instead of rendering ordinary text as the contents of those tablecells, it will process and render the given module config. In this case we've given it just a simple HTML module, and as you can see we tell it to render a link in the tablecell instead.