array_concat

This page explains how to use the array_concat function in APL.

The array_concat function in APL (Axiom Processing Language) concatenates two or more arrays into a single array. Use this function when you need to merge multiple arrays into a single array structure. It’s particularly useful for situations where you need to handle and combine collections of elements across different fields or sources, such as log entries, OpenTelemetry trace data, or security logs.

Usage

Syntax

array_concat(array1, array2, ...)

Parameters

  • array1: The first array to concatenate.
  • array2: The second array to concatenate.
  • ...: Additional arrays to concatenate.

Returns

An array containing all elements from the input arrays in the order they're provided.

Use case examples

In log analysis, you can use array_concat to merge collections of user requests into a single array to analyze request patterns across different endpoints.

Query

['sample-http-logs']
| take 50
| summarize combined_requests = array_concat(pack_array(uri), pack_array(method))

Run in Playground

Output

_timeurimethodcombined_requests
2024-10-28T12:30:00/api/v1/textdata/cnfigsPOST["/api/v1/textdata/cnfigs", "POST"]

This example concatenates the uri and method values into a single array for each log entry, allowing for combined analysis of access patterns and request methods in log data.

In OpenTelemetry traces, use array_concat to join span IDs and trace IDs for a comprehensive view of trace behavior across services.

Query

['otel-demo-traces']
| take 50
| summarize combined_ids = array_concat(pack_array(span_id), pack_array(trace_id))

Run in Playground

Output

combined_ids
["span1", "trace1", "span2", ...]
_timetrace_idspan_idcombined_ids
2024-10-28T12:30:00trace_abc123span_001["trace_abc123", "span_001"]

This example creates an array containing both span_id and trace_id values, offering a unified view of the trace journey across services.

In security logs, array_concat can consolidate multiple IP addresses or user IDs to detect potential attack patterns involving different locations or users.

Query

['sample-http-logs']
| where status == '500'
| take 50
| summarize failed_attempts = array_concat(pack_array(id), pack_array(['geo.city']))

Run in Playground

Output

_timeidgeo.citycombined_ids
2024-10-28T12:30:00fc1407f5-04ca-4f4e-ad01-f72063736e08Avenal["fc1407f5-04ca-4f4e-ad01-f72063736e08", "Avenal"]

This query combines failed user IDs and cities where the request originated, allowing security analysts to detect suspicious patterns or brute force attempts from different regions.

Other query languages