blob: 29b08a75f5700d6b713778f8ddb760fc081fdebf [file] [log] [blame]
<#compress>
|| FILE || SERVER || ACCESSLOG || SPLUNK ||
<#list dataSources as dataSource>
<#assign fileName = dataSource.fileName>
<#assign serverName = "N.A">
<#-- Transform to a single line to avoid matching OS-specific line endings -->
<#assign text = dataSource.getText()?replace("\r", "")?replace("\n", " ")>
<#assign accessLog = getAccessLog(text)>
<#assign serverName = getServerName(text)>
| ${fileName} | ${serverName} | ${accessLog} | [${splunkSearchUrl(accessLog)}] |
</#list>
</#compress>
<#--------------------------------------------------------------------------->
<#function splunkSearchUrl accessLog>
<#return "https://server.invalid/en-US/app/name/search?q=search%20source%3D%22${accessLog?url}%22">
</#function>
<#--------------------------------------------------------------------------->
<#function getAccessLog text>
<#assign matches = text?matches(r".*access_log\s*([\w\.\-\/\\]*);.*")>
<#if matches>
<#return matches?groups[1]?trim>
<#else>
<#return "N.A.">
</#if>
</#function>
<#--------------------------------------------------------------------------->
<#function getServerName text>
<#assign matches = text?matches(r".*server_name\s*([\w\.\-\\]*);.*")>
<#if matches>
<#return matches?groups[1]?trim>
<#else>
<#return "N.A.">
</#if>
</#function>