Knowledge Management

single-argument macro will not work (but argumentless version does)

woodcock
Esteemed Legend

Consider the following pair of macros, the former of which functions as expected whereas the latter fails with an error:


[fl] # stands for First and Last
definition = stats count min(_time) as FIRST, max(_time) as LAST by source | convert ctime(FIRST) timeformat="%m/%d/%y %H:%M" | convert ctime(LAST) timeformat="%m/%d/%y %H:%M"

[fl(1)] # stands for First and Last
args StatsBy
definition = stats count min(_time) as FIRST, max(_time) as LAST by $StatsBy$ | convert ctime(FIRST) timeformat="%m/%d/%y %H:%M" | convert ctime(LAST) timeformat="%m/%d/%y %H:%M"

The error I get is this:
Error in 'SearchParser': Could not find macro 'fl' that takes 1 arguments. Expecting stanza name 'fl(1)'.

Tags (2)
0 Karma
1 Solution

_d_
Splunk Employee
Splunk Employee

It seems like you're missing the equal sign after your args of the second stanza.

[fl(1)] # stands for First and Last
args = StatsBy
definition = stats count min(_time) as FIRST, max(_time) as LAST by $StatsBy$ | convert ctime(FIRST) timeformat="%m/%d/%y %H:%M" | convert ctime(LAST) timeformat="%m/%d/%y %H:%M"

Hope this helps.

> please upvote and accept answer if you find it useful - thanks!

View solution in original post

0 Karma

_d_
Splunk Employee
Splunk Employee

It seems like you're missing the equal sign after your args of the second stanza.

[fl(1)] # stands for First and Last
args = StatsBy
definition = stats count min(_time) as FIRST, max(_time) as LAST by $StatsBy$ | convert ctime(FIRST) timeformat="%m/%d/%y %H:%M" | convert ctime(LAST) timeformat="%m/%d/%y %H:%M"

Hope this helps.

> please upvote and accept answer if you find it useful - thanks!

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...