Docs
DocumentationQuery ReferenceAPI Reference
Open Console→→
DocumentationQuery ReferenceAPI Reference

Introduction

Query reference overview

APL

IntroductionSample queriesAll features
Functions
Scalar functions
Array functions
Overview
array_concat
array_extract
array_iff
array_index_of
array_length
array_reverse
array_rotate_left
array_rotate_right
array_select_dict
array_shift_left
array_shift_right
array_slice
array_sort_asc
array_sort_desc
array_split
array_sum
bag_has_key
bag_keys
bag_pack
bag_zip
isarray
len
pack_array
pack_dictionary
strcat_array
Conditional functions
Overview
case
iff
Conversion functions
Overview
dynamic_to_json
ensure_field
isbool
toarray
tobool
todatetime
todouble, toreal
todynamic
tohex
toint, tolong
tostring
totimespan
Datetime functions
Overview
ago
datetime_add
datetime_diff
datetime_part
dayofmonth
dayofweek
dayofyear
endofday
endofmonth
endofweek
endofyear
getmonth
getyear
hourofday
monthofyear
now
startofday
startofmonth
startofweek
startofyear
unixtime_microseconds_todatetime
unixtime_milliseconds_todatetime
unixtime_nanoseconds_todatetime
unixtime_seconds_todatetime
week_of_year
GenAI functions
Overview
genai_concat_contents
genai_conversation_turns
genai_cost
genai_estimate_tokens
genai_extract_assistant_response
genai_extract_function_results
genai_extract_system_prompt
genai_extract_tool_calls
genai_extract_user_prompt
genai_get_content_by_index
genai_get_content_by_role
genai_get_pricing
genai_get_role
genai_has_tool_calls
genai_input_cost
genai_is_truncated
genai_message_roles
genai_output_cost
Hash functions
Overview
hash
hash_md5
hash_sha1
hash_sha256
hash_sha512
IP functions
Overview
format_ipv4
format_ipv4_mask
geo_info_from_ip_address
has_any_ipv4
has_any_ipv4_prefix
has_ipv4
has_ipv4_prefix
ipv4_compare
ipv4_is_in_range
ipv4_is_in_any_range
ipv4_is_match
ipv4_is_private
ipv4_netmask_suffix
ipv6_compare
ipv6_is_in_any_range
ipv6_is_in_range
ipv6_is_match
parse_ipv4
parse_ipv4_mask
Mathematical functions
Overview
abs
acos
asin
atan
atan2
cos
cot
degrees
exp
exp2
exp10
gamma
isfinite
isinf
isint
isnan
log
log2
log10
loggamma
max_of
min_of
not
pi
pow
radians
rand
range
round
set_difference
set_has_element
set_intersect
set_union
sign
sin
sqrt
tan
Metadata functions
Overview
column_ifexists
cursor_current
ingestion_time
Pair functions
Overview
find_pair
pair
parse_pair
Rounding functions
Overview
bin
bin_auto
ceiling
floor
String functions
Overview
base64_decode_toarray
base64_decode_tostring
base64_encode_fromarray
base64_encode_tostring
coalesce
countof
countof_regex
extract
extract_all
format_bytes
format_url
gettype
indexof
indexof_regex
isascii
isempty
isnotempty
isnotnull
isnull
parse_bytes
parse_csv
parse_json
parse_path
parse_url
parse_urlquery
quote
regex_quote
replace
replace_regex
replace_string
reverse
split
strcat
strcat_delim
strcmp
string_size
strlen
strrep
strip_ansi_escapes
substring
tolower
totitle
toupper
translate
trim
trim_end
trim_end_regex
trim_regex
trim_space
trim_start
trim_start_regex
unicode_codepoints_from_string
unicode_codepoints_to_string
url_decode
url_encode
SQL functions
Overview
parse_sql
format_sql
Time series functions
Overview
series_abs
series_acos
series_add
series_asin
series_atan
series_ceiling
series_cos
series_cosine_similarity
series_divide
series_dot_product
series_equals
series_exp
series_fft
series_fill_backward
series_fill_const
series_fill_forward
series_fill_linear
series_fir
series_floor
series_greater
series_greater_equals
series_ifft
series_iir
series_less
series_less_equals
series_log
series_magnitude
series_max
series_min
series_multiply
series_not_equals
series_pearson_correlation
series_pow
series_sign
series_sin
series_stats
series_stats_dynamic
series_subtract
series_sum
series_tan
Type functions
Overview
isimei
ismap
isreal
iscc
isstring
isutf8
Aggregation functions
Overview
arg_min
arg_max
avg
avgif
count
countif
dcount
dcountif
histogram
histogramif
make_list
make_list_if
make_set
make_set_if
max
maxif
min
minif
percentile
percentileif
percentiles_array
percentiles_arrayif
phrases
rate
spotlight
stdev
stdevif
sum
sumif
topk
topkif
variance
varianceif
Operators
Tabular operators
Overview
count
distinct
extend
extend-valid
externaldata
getschema
join
limit
lookup
make-series
mv-expand
order
parse
parse-kv
parse-where
project
project-away
project-keep
project-rename
project-reorder
redact
sample
search
sort
summarize
take
top
union
where
Scalar operators
Set membership operators
Overview
in
!in
in~
!in~
Logical
Numerical
String
Reference
Entity names
Map fields
Null values
Scalar data types
Set statement
Special field attributes
Migrate
Splunk SPL
SQL
Sumo Logic

MPL

Language featuresHistograms and summariesSample queriesMigrate
APL/Migrate

Migrate from Splunk SPL to APL

This step-by-step guide provides a high-level mapping from Splunk SPL to APL.

Splunk and Axiom are powerful tools for log analysis and data exploration. The Query tab uses Axiom Processing Language (APL). There are some differences between the query languages for Splunk and Axiom. When transitioning from Splunk to APL, you will need to understand how to convert your Splunk SPL queries into APL.

This guide provides a high-level mapping from Splunk to APL.

Basic Searching

Splunk uses a search command for basic searching, while in APL, simply specify the dataset name followed by a filter.

Splunk:

shell
search index="myIndex" error

APL:

APLRun in Playground
['myDatasaet']
| where FieldName contains “error”

Filtering

In Splunk, perform filtering using the search command, usually specifying field names and their desired values. In APL, perform filtering by using the where operator.

Splunk:

shell
Search index=”myIndex” error 
| stats count

APL:

APLRun in Playground
['myDataset']
| where fieldName contains “error”
| count 

Aggregation

In Splunk, the stats command is used for aggregation. In APL, perform aggregation using the summarize operator.

Splunk:

shell
search index="myIndex" 
| stats count by status

APL:

APLRun in Playground
['myDataset'] 
| summarize count() by status

Time Frames

In Splunk, select a time range for a search in the time picker on the search page. In APL, filter by a time range using the where operator and the timespan field of the dataset.

Splunk:

shell
search index="myIndex" earliest=-1d@d latest=now

APL:

APLRun in Playground
['myDataset']
| where _time >= ago(1d) and _time <= now()

Sorting

In Splunk, the sort command is used to order the results of a search. In APL, perform sorting by using the sort by operator.

Splunk:

shell
search index="myIndex" 
| sort - content_type

APL:

APLRun in Playground
['myDataset'] 
| sort by countent_type desc

Selecting Fields

In Splunk, use the fields command to specify which fields to include or exclude in the search results. In APL, use the project operator, project-away operator, or the project-keep operator to specify which fields to include in the query results.

Splunk:

shell
index=main sourcetype=mySourceType
| fields status, responseTime

APL:

APLRun in Playground
['myDataset'] 
| extend newName = oldName
| project-away oldName

Renaming Fields

In Splunk, rename fields using the rename command, while in APL rename fields using the extend, and project operator. Here is the general syntax:

Splunk:

shell
index="myIndex" sourcetype="mySourceType"
| rename oldFieldName AS newFieldName

APL:

APLRun in Playground
['myDataset']
| where method == "GET"
| extend new_field_name = content_type
| project-away content_type

Calculated Fields

In Splunk, use the eval command to create calculated fields based on the values of other fields, while in APL use the extend operator to create calculated fields based on the values of other fields.

Splunk

shell
search index="myIndex" 
| eval newField=field1+field2

APL:

APLRun in Playground
['myDataset'] 
| extend newField = field1 + field2

Structure and Concepts

The following table compares concepts and data structures between Splunk and APL logs.

ConceptSplunkAPLComment
data cachesbucketscaching and retention policiesControls the period and caching level for the data. This setting directly affects the performance of queries.
logical partition of dataindexdatasetAllows logical separation of the data.
structured event metadataN/AdatasetSplunk doesn’t expose the concept of metadata to the search language. APL logs have the concept of a dataset, which has fields and columns. Each event instance is mapped to a row.
data recordeventrowTerminology change only.
typesdatatypedatatypeAPL data types are more explicit because they’re set on the fields. Both have the ability to work dynamically with data types and roughly equivalent sets of data types.
query and searchsearchqueryConcepts essentially are the same between APL and Splunk

Functions

The following table specifies functions in APL that are equivalent to Splunk Functions.

SplunkAPL
strcatstrcat()
splitsplit()
ififf()
tonumbertodouble(), tolong(), toint()
upper, lowertoupper(), tolower()
replacereplace_string() or replace_regex()
substrsubstring()
tolowertolower()
touppertoupper()
matchmatches regex
regexmatches regex (in splunk, regex is an operator. In APL, it’s a relational operator.)
searchmatch== (In splunk, searchmatch allows searching the exact string.)
randomrand(), rand(n) (Splunk’s function returns a number between zero to 231 -1. APL returns a number between 0.0 and 1.0, or if a parameter is provided, between 0 and n-1.)
nownow()

In Splunk, the function is invoked by using the eval operator. In APL, it’s used as part of the extend or project.

In Splunk, the function is invoked by using the eval operator. In APL, it can be used with the where operator.

Filter

APL log queries start from a tabular result set in which a filter is applied. In Splunk, filtering is the default operation on the current index. You may also use the where operator in Splunk, but Axiom doesn’t recommend it.

ProductOperatorExample
SplunksearchSample.Logs="330009.2" method="GET" _indextime>-24h
APLwhere['sample-http-logs']
| where method == "GET" and _time > ago(24h)

Get n events or rows for inspection

APL log queries also support take as an alias to limit. In Splunk, if the results are ordered, head returns the first n results. In APL, limit isn’t ordered, but it returns the first n rows that are found.

ProductOperatorExample
SplunkheadSample.Logs=330009.2
| head 100
APLlimit['sample-htto-logs']
| limit 100

Get the first n events or rows ordered by a field or column

For the bottom results, in Splunk, use tail. In APL, specify ordering direction by using asc.

ProductOperatorExample
SplunkheadSample.Logs="33009.2"
| sort Event.Sequence
| head 20
APLtop['sample-http-logs']
| top 20 by method

Extend the result set with new fields or columns

Splunk has an eval function, but it’s not comparable to the eval operator in APL. Both the eval operator in Splunk and the extend operator in APL support only scalar functions and arithmetic operators.

ProductOperatorExample
SplunkevalSample.Logs=330009.2
| eval state= if(Data.Exception = "0", "success", "error")
APLextend['sample-http-logs']
| extend Grade = iff(req_duration_ms >= 80, "A", "B")

Rename

APL uses the project operator to rename a field. In the project operator, a query can take advantage of any indexes that are prebuilt for a field. Splunk has a rename operator that does the same.

ProductOperatorExample
SplunkrenameSample.Logs=330009.2
| rename Date.Exception as execption
APLproject['sample-http-logs']
| project updated_status = status

Format results and projection

Splunk uses the table command to select which columns to include in the results. APL has a project operator that does the same and more.

ProductOperatorExample
SplunktableEvent.Rule=330009.2
| table rule, state
APLproject['sample-http-logs']
| project status, method

Splunk uses the field - command to select which columns to exclude from the results. APL has a project-away operator that does the same.

ProductOperatorExample
Splunkfields -Sample.Logs=330009.2
| fields - quota, hightest_seller
APLproject-away['sample-http-logs']
| project-away method, status

Aggregation

See the list of summarize aggregations functions that are available.

Splunk operatorSplunk exampleAPL operatorAPL example
statssearch (Rule=120502.*)
| stats count by OSEnv, Audience
summarize['sample-http-logs']
| summarize count() by content_type, status

Sort

In Splunk, to sort in ascending order, you must use the reverse operator. APL also supports defining where to put nulls, either at the beginning or at the end.

ProductOperatorExample
SplunksortSample.logs=120103
| sort Data.Hresult
| reverse
APLorder by['sample-http-logs']
| order by status desc

Whether you’re just starting your transition or you’re in the thick of it, this guide can serve as a helpful roadmap to assist you in your journey from Splunk to Axiom Processing Language.

Dive into the Axiom Processing Language, start converting your Splunk queries to APL, and explore the rich capabilities of the Query tab. Embrace the learning curve, and remember, every complex query you master is another step forward in your data analytics journey.

Was this page helpful?
Suggest edits on GitHub
PreviousSpecial field attributesNextMigrate from SQL to APL
On this page
Basic SearchingFilteringAggregationTime FramesSortingSelecting FieldsRenaming FieldsCalculated FieldsStructure and ConceptsFunctionsFilterGet n events or rows for inspectionGet the first n events or rows ordered by a field or columnExtend the result set with new fields or columnsRenameFormat results and projectionAggregationSort