format_url function constructs a properly formatted URL from a dynamic object containing URL components (scheme, host, path, port, etc.). Use this function when you need to build URLs programmatically from parsed components or when reconstructing URLs from log data.
For users of other query languages
If you come from other query languages, this section explains how to adjust your existing queries to achieve the same results in APL.Splunk SPL users
Splunk SPL users
In Splunk SPL, you typically concatenate URL parts manually with
eval. APL’s format_url provides a structured approach.ANSI SQL users
ANSI SQL users
In ANSI SQL, URL formatting requires string concatenation with null handling. APL’s
format_url simplifies this operation.Usage
Syntax
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| url_parts | dynamic | Yes | A dynamic object containing URL components: scheme, host, path, port, fragment, user, password, query. |
Returns
Returns a properly formatted URL string constructed from the provided components.Use case examples
- Log analysis
- OpenTelemetry traces
- Security logs
Reconstruct full URLs from parsed components to analyze complete request patterns.QueryRun in PlaygroundOutput
This query reconstructs full URLs from URI paths by adding the scheme and host, useful for generating clickable links in reports.
| _time | method | status | full_url |
|---|---|---|---|
| 2024-11-06T10:00:00Z | GET | 200 | https://api.example.com/api/users |
| 2024-11-06T10:01:00Z | POST | 201 | https://api.example.com/api/orders |
| 2024-11-06T10:02:00Z | GET | 200 | https://api.example.com/api/products |
List of related functions
- parse_url: Parses a URL string into its components. Use this to reverse the formatting operation and extract URL parts.
- parse_urlquery: Parses URL query parameters. Use this when you need to work with query string parameters specifically.
- url_encode: Encodes a string for safe use in URLs. Use this to encode individual URL components before formatting.
- strcat: Concatenates strings. Use this for simple URL construction without the structure of format_url.