Build the Splunk error-lookup URL¶
ApiResponseHandler.BuildMessageURL(IEnvironmentService) composes a Splunk deep-link URL for the current MessageID, falling back to hard-coded defaults when configuration is unavailable.
| Field | Value |
|---|---|
| Operation ID | OP-03 |
| Trigger | Post-process an API response, step 7. |
| Inputs | IEnvironmentService (may be null) |
| Outputs | string URL |
| Primary components | ApiResponseHandler.BuildMessageURL(IEnvironmentService) |
| Entry point | src/SAIF.Web.API/ApiResponseHandler.cs |
Steps¶
- Initialize
resultUrlandsplunkQueryto"". - If
envService != null, readresultUrl = envService.GetConfigSetting("splunksearch")andsplunkQuery = envService.GetConfigSetting("splunk.error.query")(BR-WEBAPI-006). - Skipped entirely when the service is unresolved.
IEnvironmentService.GetConfigSettingis implemented inSAIF.Framework.Core; its internal steps could not be embedded — the package is not indexed for this run.**- If
resultUrlis null/empty, substitute the hard-coded defaultshttps://splunk/en-US/app/search/searchandsearch index=db_mssql sourcetype=Businessonline.error earliest=-1month(BR-WEBAPI-006). - Only
resultUrlis tested; ifsplunksearchis configured butsplunk.error.queryis blank, the query portion stays empty. - Append
?q={Uri.EscapeDataString(splunkQuery + " " + MessageID)}(BR-WEBAPI-006).
Corroborated by the BuildsResponseUrl and NullEnvironmentService tests in src/SAIF.Web.API.Tests/SAIF.Web.API.Tests/ApiResponseHandlerTests.cs.
Process flow¶
flowchart TD
Start([Called from OP-01 step 7]) --> HasEnv{envService available?}
HasEnv -->|Yes| Read["Read splunksearch /<br>splunk.error.query"]
HasEnv -->|No| Default["Use hard-coded defaults"]
Read --> Empty{resultUrl empty?}
Empty -->|Yes| Default
Empty -->|No| Append
Default --> Append["Append ?q={query}<br>{MessageID}"]
Append --> End([Return MessageIDUrl])
Failure and edge-case behavior¶
- A configured
splunksearchwith a blanksplunk.error.queryyields a URL with an empty query fragment (no independent fallback for the query alone).
Note: Statements marked with ** could not be confirmed; treat as unknown until verified.
Related documentation¶
Sources¶
src/SAIF.Web.API/ApiResponseHandler.cssrc/SAIF.Web.API.Tests/SAIF.Web.API.Tests/ApiResponseHandlerTests.cs