hideAmara will be doing a system update on Tuesday, May 20th, 2025, at 9:00pm - 10:00pm ET​ (US Time)
Please save your work often if you are working during this time.

< Return to Video

Splunk Basic : Everything to know about macros

  • 0:00 - 0:03
    okay today we will discuss about plan
  • 0:03 - 0:06
    macros okay so his plan macros you can
  • 0:06 - 0:09
    think of it as a reusable component in
  • 0:09 - 0:13
    your Splunk search where suppose a
  • 0:13 - 0:16
    particular search portion if it is using
  • 0:16 - 0:19
    if you are using many times mmm then you
  • 0:19 - 0:20
    can put it in a macro so that you can
  • 0:20 - 0:24
    call that micro and the macro will be
  • 0:24 - 0:26
    replaced runtime with that search string
  • 0:26 - 0:29
    okay so macros are very very useful when
  • 0:29 - 0:32
    suppose you have many dashboards in your
  • 0:32 - 0:35
    application and in all this - but you
  • 0:35 - 0:39
    have some search which is running in all
  • 0:39 - 0:42
    the - boots right so in this case you
  • 0:42 - 0:43
    can implement that such portion in a
  • 0:43 - 0:46
    macro where you can just call that macro
  • 0:46 - 0:48
    instead of this whole search string in
  • 0:48 - 0:50
    your dashboards so in the future if you
  • 0:50 - 0:52
    want to do any changes in that search
  • 0:52 - 0:55
    logic you will just change into the into
  • 0:55 - 0:59
    one place in that in macro body okay so
  • 0:59 - 1:01
    so by implementing macro basically we
  • 1:01 - 1:04
    are achieving two things one is the
  • 1:04 - 1:07
    modularity of your code easily
  • 1:07 - 1:10
    maintaining of your code and as well as
  • 1:10 - 1:11
    your search string will be very much
  • 1:11 - 1:16
    smaller okay so there are there are
  • 1:16 - 1:19
    couple - two different types of macro we
  • 1:19 - 1:21
    generally deals with one is eval based
  • 1:21 - 1:23
    macro and there is no an evil based
  • 1:23 - 1:26
    macro so before we discuss those things
  • 1:26 - 1:30
    let me show you the data I have it here
  • 1:30 - 1:33
    so I have some people name and their
  • 1:33 - 1:36
    basic salary and and variable percent so
  • 1:36 - 1:40
    I'll show you to how to create evil
  • 1:40 - 1:42
    waste macro how to create non evil West
  • 1:42 - 1:44
    Metro and what are the differences
  • 1:44 - 1:48
    between them and and then how to call
  • 1:48 - 1:50
    macarons at a macro also we will try to
  • 1:50 - 1:52
    discuss that one okay so first let us
  • 1:52 - 1:57
    see how we can create a non evil macro
  • 1:57 - 2:00
    so now an evil macro and honorable macro
  • 2:00 - 2:04
    if you see functionality-wise both are
  • 2:04 - 2:07
    same so when we define a macro the macro
  • 2:07 - 2:10
    body you are giving this string right so
  • 2:10 - 2:13
    dynamically in the run time
  • 2:13 - 2:16
    macro will be definite will be replaced
  • 2:16 - 2:18
    by that macro body by spelling search
  • 2:18 - 2:23
    okay now when we talk about evil waste
  • 2:23 - 2:26
    macro it is expected that the macro is
  • 2:26 - 2:30
    returning a string when you use non evil
  • 2:30 - 2:32
    waste macro you can directly put the
  • 2:32 - 2:34
    search string inside the macro so let me
  • 2:34 - 2:37
    show you suppose I wanted to calculate
  • 2:37 - 2:40
    total salary based on this formula
  • 2:40 - 2:43
    called basic salary let me show you
  • 2:43 - 2:50
    basic salary plus basic into that
  • 2:50 - 2:54
    percentage variable percentage variable
  • 2:54 - 2:58
    percent okay so to do that to create any
  • 2:58 - 3:01
    macro from the Splunk uy this is how you
  • 3:01 - 3:04
    do it we'll go to settings we go to
  • 3:04 - 3:08
    advanced search okay from there if you
  • 3:08 - 3:11
    see there is a option called such Mac
  • 3:11 - 3:13
    rooms you go there you select your app
  • 3:13 - 3:16
    from there so I'll be creating this
  • 3:16 - 3:18
    matter in my tmdb app so I have selected
  • 3:18 - 3:21
    tmdb over here then new search macro
  • 3:21 - 3:24
    okay if you see the destination I've
  • 3:24 - 3:26
    already selected as TM GB I'll give it a
  • 3:26 - 3:36
    name let's say total salary okay so now
  • 3:36 - 3:39
    whether a macro is evil waste or not
  • 3:39 - 3:41
    determined by this check box if you
  • 3:41 - 3:43
    check this one it will be well waste
  • 3:43 - 3:45
    macro if you don't just check this one
  • 3:45 - 3:48
    it will be a non evil West macro so the
  • 3:48 - 3:50
    first we will discuss about non evil
  • 3:50 - 3:52
    missed macro so what I am trying to say
  • 3:52 - 3:55
    is when you what I said is whenever we
  • 3:55 - 3:57
    are creating a non evil West micro we
  • 3:57 - 3:59
    can directly give a search string over
  • 3:59 - 4:01
    there so my search team will be
  • 4:01 - 4:03
    something like this I will be creating a
  • 4:03 - 4:06
    new field called total salary so that's
  • 4:06 - 4:14
    why that evil total salary equals to now
  • 4:14 - 4:17
    I will be passing this to my basic
  • 4:17 - 4:20
    salary and variable percent to this
  • 4:20 - 4:23
    macro right row do that what I will do
  • 4:23 - 4:26
    I'll create a argument of this macro
  • 4:26 - 4:28
    in basic salary so in the argument
  • 4:28 - 4:33
    section you will be giving control see
  • 4:33 - 4:36
    these two things basic salary and
  • 4:36 - 4:40
    variable percent as two arguments as the
  • 4:40 - 4:43
    macro has two arguments it is mandatory
  • 4:43 - 4:47
    that in this name section you give how
  • 4:47 - 4:49
    many number of arguments you have in
  • 4:49 - 4:51
    your macro if it is one you have to give
  • 4:51 - 4:56
    one here okay now the formula is my
  • 4:56 - 4:59
    basic salary now this basic salary is my
  • 4:59 - 5:03
    input variable right so to access input
  • 5:03 - 5:05
    variable you access like this just like
  • 5:05 - 5:12
    it token okay basic salary plus my basic
  • 5:12 - 5:21
    salary into that variable percent again
  • 5:21 - 5:26
    as input I am accessing right then
  • 5:26 - 5:30
    divide it by 100 so this will be minus
  • 5:30 - 5:34
    macro body now there is a two options
  • 5:34 - 5:35
    for validation expression interrogation
  • 5:35 - 5:37
    error message I will show you in the
  • 5:37 - 5:42
    next macro see if I save it okay
  • 5:42 - 5:45
    so if you see the macro has been created
  • 5:45 - 5:50
    now if I call this macro over here so to
  • 5:50 - 5:52
    call a macro this is how you call there
  • 5:52 - 5:54
    is a tick mark if you see okay from your
  • 5:54 - 6:01
    keyboard then the macro name total
  • 6:01 - 6:05
    salary and it has two arguments right my
  • 6:05 - 6:09
    basic salary and my variable percent
  • 6:09 - 6:13
    then tick end now this basic salary is
  • 6:13 - 6:15
    corresponds to this basic salary and
  • 6:15 - 6:17
    variable person corresponds to this
  • 6:17 - 6:18
    variable person failed
  • 6:18 - 6:21
    now when you define the macro I have
  • 6:21 - 6:23
    given the same name as macro input you
  • 6:23 - 6:26
    can give any any input variable name
  • 6:26 - 6:28
    over here the same name you have to use
  • 6:28 - 6:31
    over here as well but when you pass a
  • 6:31 - 6:34
    macro pass this visix ready and variable
  • 6:34 - 6:36
    person to this macro you'll be giving
  • 6:36 - 6:37
    this field name only
  • 6:37 - 6:40
    so let us run it and see what's going on
  • 6:40 - 6:44
    if you see it has created a total salary
  • 6:44 - 6:48
    failed with this formal output 4000 plus
  • 6:48 - 6:52
    4000 into 15% is 4,600 right so it is
  • 6:52 - 6:55
    basically same as the run time what is
  • 6:55 - 6:58
    happening is something like this so if I
  • 6:58 - 7:00
    instead of total salary if I just gave
  • 7:00 - 7:04
    this one and instead of this token
  • 7:04 - 7:08
    variable I just give my flake name here
  • 7:08 - 7:14
    the output will be same variable percent
  • 7:14 - 7:19
    the output will be same so this is how
  • 7:19 - 7:21
    what is happening as well so run time
  • 7:21 - 7:25
    Splunk is replacing this macro body with
  • 7:25 - 7:28
    this variable inputs and then it is
  • 7:28 - 7:30
    running the query so ultimately this
  • 7:30 - 7:33
    squad is getting run okay so but the
  • 7:33 - 7:35
    thing is this this code if you put it in
  • 7:35 - 7:37
    a macro you can call that macro anybody
  • 7:37 - 7:39
    new such so that means that this code
  • 7:39 - 7:42
    portions will be reusable now okay now
  • 7:42 - 7:46
    let's see an example where we can use
  • 7:46 - 7:48
    this validation expression and
  • 7:48 - 7:49
    validation error message now a
  • 7:49 - 7:52
    validation expression is used when you
  • 7:52 - 7:55
    want to do some kind of validation on
  • 7:55 - 8:00
    your macro inputs okay so and validation
  • 8:00 - 8:03
    error message means when this input is
  • 8:03 - 8:05
    getting or this validation is getting
  • 8:05 - 8:06
    filled this error message will be
  • 8:06 - 8:09
    displayed over there so to do that what
  • 8:09 - 8:15
    I will do is I'll create another macro
  • 8:15 - 8:20
    okay so now let's say we have basic
  • 8:20 - 8:23
    salary and variable percent right let's
  • 8:23 - 8:25
    say we want to calculate a bonus
  • 8:25 - 8:28
    percentage with this formula called
  • 8:28 - 8:32
    variable percent variable percent plus
  • 8:32 - 8:36
    any any of the person any number let's
  • 8:36 - 8:38
    say seven percent or eight in a number
  • 8:38 - 8:41
    I'll provide inputs it will give me it
  • 8:41 - 8:43
    will add those two percentage value and
  • 8:43 - 8:46
    give me the bonus percent okay so to do
  • 8:46 - 8:48
    that I will just create that similar
  • 8:48 - 8:52
    macro name bonus
  • 8:52 - 8:57
    okay so the formula will be again it
  • 8:57 - 9:06
    will be non evil based okay eval bonus
  • 9:08 - 9:14
    equals two so my variable percent right
  • 9:14 - 9:16
    I have to provide as a input so I'll
  • 9:16 - 9:19
    giving input so let's say this time I
  • 9:19 - 9:22
    will rename this to something maybe so
  • 9:22 - 9:28
    I'll say dollar VP dollar then plus
  • 9:28 - 9:31
    another input I will be giving let's say
  • 9:31 - 9:37
    bonus input okay so this bonus I will be
  • 9:37 - 9:42
    adding here okay Nonna's so we have two
  • 9:42 - 9:44
    inputs that means we have to give two
  • 9:44 - 9:47
    over here now I'll add an expression now
  • 9:47 - 9:50
    I always want this bonus to be in number
  • 9:50 - 9:54
    okay do that i'll so this validation
  • 9:54 - 9:56
    expression has to be a boolean
  • 9:56 - 9:59
    expression or eval okay so if you saw my
  • 9:59 - 10:01
    previous video we we discussed about
  • 10:01 - 10:04
    various evil expressions right and some
  • 10:04 - 10:06
    of the expressions returns bully and the
  • 10:06 - 10:09
    strict like operator or in operator or
  • 10:09 - 10:12
    easy num operator which basically checks
  • 10:12 - 10:15
    whether a particular input is number or
  • 10:15 - 10:17
    not so you will be using is numb over
  • 10:17 - 10:21
    here on this bonus that means I am
  • 10:21 - 10:23
    checking whether whatever I am providing
  • 10:23 - 10:25
    as the input to this bonus variable
  • 10:25 - 10:29
    parameter whether it is number or not if
  • 10:29 - 10:32
    it is not number will I will give this
  • 10:32 - 10:37
    in this output error message bonus must
  • 10:37 - 10:41
    be and number okay
  • 10:41 - 10:50
    so let's save this macro okay now I will
  • 10:50 - 10:57
    call this macro here let it be my total
  • 10:57 - 11:02
    salary macro called as is if I just do
  • 11:02 - 11:04
    control see
  • 11:04 - 11:07
    okay here I'm calling my total salary so
  • 11:07 - 11:09
    to stick the output now after that I'll
  • 11:09 - 11:15
    be calling the bonus macro it's a
  • 11:15 - 11:18
    similar way tick macro named micro
  • 11:18 - 11:20
    inputs one of the inputs will be my
  • 11:20 - 11:23
    variable percent and another another
  • 11:23 - 11:26
    output may be let's say 8 percent I want
  • 11:26 - 11:28
    to add with the variable percent so what
  • 11:28 - 11:31
    will be output in this case it should
  • 11:31 - 11:34
    create a new field called bonus with 15
  • 11:34 - 11:36
    plus 8 20 plus 8 something like this
  • 11:36 - 11:39
    okay if you see you can create you can
  • 11:39 - 11:42
    access different different macros in
  • 11:42 - 11:48
    your whole search okay now let's say I
  • 11:48 - 11:53
    have provided a string here it says test
  • 11:53 - 11:55
    ok what is happening so if you provide
  • 11:55 - 11:58
    this thing here that validation is
  • 11:58 - 12:00
    getting failed we have added over here
  • 12:00 - 12:02
    is numb so that set is giving you this
  • 12:02 - 12:06
    error bonus must be a number so this is
  • 12:06 - 12:10
    how macro input validation works ok let
  • 12:10 - 12:15
    us continue now we will discuss about
  • 12:15 - 12:19
    how to create an eval macro so to do
  • 12:19 - 12:23
    that what we'll do is first let me show
  • 12:23 - 12:25
    you two things if you remember from my
  • 12:25 - 12:28
    previous video we have created a command
  • 12:28 - 12:32
    called gate churners right and that
  • 12:32 - 12:34
    common takes an input with the journal
  • 12:34 - 12:36
    ID and if we are not giving any general
  • 12:36 - 12:39
    idea giving star it will give you all
  • 12:39 - 12:42
    the journal titles right and also we
  • 12:42 - 12:48
    have a we have created a our we have
  • 12:48 - 12:51
    index our data into this main index
  • 12:51 - 12:52
    right so you have another data set
  • 12:52 - 12:54
    called main where we have we're having
  • 12:54 - 12:56
    this salary and this information just
  • 12:56 - 12:59
    now you are working with a data set so
  • 12:59 - 13:01
    suppose there is a requirement that
  • 13:01 - 13:05
    based on certain condition either I need
  • 13:05 - 13:09
    to go with this data set or I need to go
  • 13:09 - 13:11
    with this data set in this type of
  • 13:11 - 13:14
    scenario where dynamically you have to
  • 13:14 - 13:16
    determine which data set to work on or
  • 13:16 - 13:17
    dynamically
  • 13:17 - 13:21
    in which search string to which search
  • 13:21 - 13:23
    things were written that means to
  • 13:23 - 13:25
    assistant to work with eval macros are
  • 13:25 - 13:28
    coming into picture okay so because the
  • 13:28 - 13:31
    main concept behind evil macro is it has
  • 13:31 - 13:34
    to return a string so in that case how
  • 13:34 - 13:36
    we will create is like this let's say
  • 13:36 - 13:40
    new search macro I'll give a name call
  • 13:40 - 13:47
    gate channel or main index okay just
  • 13:47 - 13:49
    like the name just to show you the use
  • 13:49 - 13:52
    case of it so here what I will write I
  • 13:52 - 13:54
    will write it if or case statement
  • 13:54 - 13:55
    really mostly we light a key for case
  • 13:55 - 13:59
    statement for eval based macro so case
  • 13:59 - 14:02
    so that we can have different different
  • 14:02 - 14:03
    condition and based on the condition we
  • 14:03 - 14:05
    will be returning the search string but
  • 14:05 - 14:07
    ultimately if you see we are in the
  • 14:07 - 14:09
    start sitting only at the end of the day
  • 14:09 - 14:11
    so that Splunk will replace that macro
  • 14:11 - 14:13
    with that search string so i'm saying i
  • 14:13 - 14:18
    will provide argument here let's say
  • 14:18 - 14:21
    same same argument name let's say so
  • 14:21 - 14:23
    either i will provide gate channel or i
  • 14:23 - 14:26
    will provide main as my or argument
  • 14:26 - 14:28
    value okay i'll show you how how i
  • 14:28 - 14:32
    provide that one case i am saying my
  • 14:32 - 14:38
    input taller this one dollar is equals
  • 14:38 - 14:43
    to let us say gate channel okay as it is
  • 14:43 - 14:47
    within quotes remember that if this one
  • 14:47 - 14:50
    has to be quotes as well or when you are
  • 14:50 - 14:52
    calling you have to call with this with
  • 14:52 - 14:54
    course i prefer to be like this only so
  • 14:54 - 14:56
    that everything is in your inside your
  • 14:56 - 14:59
    macro only in that case the string I
  • 14:59 - 15:05
    will return is this kind get Jenna star
  • 15:05 - 15:07
    now you have to be very careful over
  • 15:07 - 15:10
    here when you dil Dil with a generating
  • 15:10 - 15:12
    command if you seek it generates a
  • 15:12 - 15:14
    generating comment right thats why this
  • 15:14 - 15:15
    has to be the first command in your
  • 15:15 - 15:20
    search string now for generating comment
  • 15:20 - 15:23
    when you run it if you see there is a
  • 15:23 - 15:25
    bar over here search bar right after
  • 15:25 - 15:27
    that only if I run this command without
  • 15:27 - 15:30
    this word nothing will come up
  • 15:30 - 15:32
    it requires this bar but when you put
  • 15:32 - 15:35
    this gate Jenner star this generating
  • 15:35 - 15:39
    command inside a macro so you put it
  • 15:39 - 15:41
    without the bar so that when you call
  • 15:41 - 15:44
    the macro you will call with bar then
  • 15:44 - 15:45
    macro name I will show you that one as
  • 15:45 - 15:48
    well but that's why I am giving without
  • 15:48 - 15:51
    the bar here this is this has to be very
  • 15:51 - 15:53
    careful with the generating comments
  • 15:53 - 15:55
    because if you put bar inside it will
  • 15:55 - 16:01
    not work now when my input is main ok in
  • 16:01 - 16:05
    that case I will return the string
  • 16:05 - 16:10
    called search index equals two main here
  • 16:10 - 16:13
    also another good thing is when you run
  • 16:13 - 16:15
    index equals two main from your search
  • 16:15 - 16:17
    prompt right you do not need to mention
  • 16:17 - 16:19
    search then index equals two main
  • 16:19 - 16:22
    because that is by default comes up but
  • 16:22 - 16:24
    when you use it in a macro or somewhere
  • 16:24 - 16:24
    else
  • 16:24 - 16:27
    you have to put it like this search then
  • 16:27 - 16:31
    index equals to me okay so this thing I
  • 16:31 - 16:33
    will be returning says my macro has one
  • 16:33 - 16:37
    input so I will be giving one here okay
  • 16:37 - 16:39
    validation we are not doing anything now
  • 16:39 - 16:44
    so let's save it okay this is our third
  • 16:44 - 16:49
    macro so get general or main see if I
  • 16:49 - 16:54
    run this macro now okay so as I said it
  • 16:54 - 16:56
    has a generating comment that's why I am
  • 16:56 - 17:00
    giving a bar over here then my take and
  • 17:00 - 17:04
    then my input let's say I will be giving
  • 17:04 - 17:10
    input s get general I want to know I
  • 17:10 - 17:11
    want to work with the data set to get
  • 17:11 - 17:21
    channel okay so if let's see okay
  • 17:21 - 17:28
    bracket this missing over here save now
  • 17:28 - 17:30
    if you see if I run this macro again it
  • 17:30 - 17:32
    is giving me same because sometimes it's
  • 17:32 - 17:35
    not you don't take the refreshed value
  • 17:35 - 17:37
    so what I will do in this case just copy
  • 17:37 - 17:42
    this code close it Danny taking such
  • 17:42 - 17:43
    Factory unknown search comma
  • 17:43 - 17:56
    and case to see what's going on okay it
  • 17:56 - 17:58
    has to be evil waste macro because it is
  • 17:58 - 18:01
    running a string now right so let's say
  • 18:01 - 18:11
    wait and let it is not okay now if you
  • 18:11 - 18:14
    see if I run this gate general macro so
  • 18:14 - 18:15
    it is giving me this data set where it
  • 18:15 - 18:17
    is running that gate general Starr
  • 18:17 - 18:19
    generating command and giving me this
  • 18:19 - 18:24
    result if I say main in this case it is
  • 18:24 - 18:26
    giving me this data set where I have
  • 18:26 - 18:30
    index my data so this is how you can
  • 18:30 - 18:33
    create a evil waste macro okay so now
  • 18:33 - 18:37
    macro has a diff separate permissions as
  • 18:37 - 18:40
    well if you see from this macro macro
  • 18:40 - 18:44
    list page you can and you can set the
  • 18:44 - 18:46
    permissions as well so currently I will
  • 18:46 - 18:48
    show you I will set this permission as
  • 18:48 - 18:50
    this upon't Li and read I will say
  • 18:50 - 18:53
    everyone and right let's say admin let's
  • 18:53 - 18:57
    do it for all the macros permission so
  • 18:57 - 18:59
    you have to be very careful with the
  • 18:59 - 19:02
    macro permissions as well otherwise any
  • 19:02 - 19:05
    unprivileged user will not be able to
  • 19:05 - 19:07
    run this macro and your dashboard will
  • 19:07 - 19:12
    not show up anything so read/write okay
  • 19:12 - 19:14
    now we have set the permissions of the
  • 19:14 - 19:17
    macro as well now let's see what's going
  • 19:17 - 19:19
    on at the background so I am in my
  • 19:19 - 19:24
    Splunk home I will go to a TC apps tmdb
  • 19:24 - 19:27
    F and I will go to my local folder if
  • 19:27 - 19:29
    you see whenever you creates a macro
  • 19:29 - 19:31
    it's creates a another Khan file called
  • 19:31 - 19:34
    macro scones I will open this file and
  • 19:34 - 19:37
    if you see all different macros we have
  • 19:37 - 19:39
    created its gate separate separate
  • 19:39 - 19:43
    stanza for that macro name and with all
  • 19:43 - 19:46
    the input numbers right and args is the
  • 19:46 - 19:49
    inputs of this macros wait for bonus if
  • 19:49 - 19:53
    you see here for bonus my arguments are
  • 19:53 - 19:56
    VPN bonus like two arguments those are
  • 19:56 - 19:57
    showing up here this
  • 19:57 - 19:59
    the macro definition this is the error
  • 19:59 - 20:02
    message you set it for this macro this
  • 20:02 - 20:03
    is the validation you have set it for
  • 20:03 - 20:06
    this macro and this is evil is telling
  • 20:06 - 20:08
    you whether this macro is well based or
  • 20:08 - 20:11
    not as our last macro get general or
  • 20:11 - 20:14
    main is evil ways that Troy is evil is
  • 20:14 - 20:16
    one for rest of the - macros easy well
  • 20:16 - 20:21
    is zero okay now you can you can call a
  • 20:21 - 20:24
    macro another inside another macro so to
  • 20:24 - 20:27
    do that let's do this exercise where we
  • 20:27 - 20:28
    have created these totals energy right
  • 20:28 - 20:30
    and also bonus
  • 20:30 - 20:32
    so inside total Cirelli we will try to
  • 20:32 - 20:35
    call this bonus one who do that I will
  • 20:35 - 20:38
    do one thing I will clone this total
  • 20:38 - 20:40
    celery macro no I like this let's let's
  • 20:40 - 20:44
    get a new one only it's a total salary
  • 20:44 - 20:48
    total salary
  • 20:50 - 20:51
    yv2
  • 20:51 - 20:54
    version - okay so what I will do it will
  • 20:54 - 20:57
    not be well based macro let's say my
  • 20:57 - 21:02
    previous will be there he well right so
  • 21:02 - 21:06
    it has two arguments basic salary and
  • 21:06 - 21:11
    variable percent right now I'll be
  • 21:11 - 21:14
    adding this bonus as well so bonus
  • 21:14 - 21:16
    requires another extra input called
  • 21:16 - 21:19
    bonus right so I will be adding this as
  • 21:19 - 21:23
    a extra input comma this so my total
  • 21:23 - 21:27
    macro inputs will be three basic salary
  • 21:27 - 21:30
    and variable pay will be he'll be used
  • 21:30 - 21:33
    here and variable pay and bonus will be
  • 21:33 - 21:36
    used in another evil statement which we
  • 21:36 - 21:38
    have which will be a calling in this
  • 21:38 - 21:41
    bonus macro right so in this case I will
  • 21:41 - 21:44
    be calling this bonus macro inside so
  • 21:44 - 21:49
    I'll say this one pipe then my bonus
  • 21:49 - 21:52
    macro bonus macro takes two arguments
  • 21:52 - 21:55
    one is variable percent and another is
  • 21:55 - 22:00
    bonus so variable percent I'll pass and
  • 22:00 - 22:04
    I'll pass this bonus as well so ideally
  • 22:04 - 22:07
    the behavior should be same as we have
  • 22:07 - 22:11
    seen before right so
  • 22:11 - 22:19
    done tick okay so now let's save it okay
  • 22:19 - 22:22
    so total sir I do so before before I do
  • 22:22 - 22:27
    that so let us run our macro so I'll
  • 22:27 - 22:32
    just copy paste that code portion here
  • 22:32 - 22:36
    right so I'll just copy paste this code
  • 22:36 - 22:38
    portion here
  • 22:38 - 22:41
    it's a macro total salary nan okay I
  • 22:41 - 22:47
    think total I am my macro is total 7
  • 22:54 - 23:00
    this mismatch parenthesis okay okay so
  • 23:00 - 23:03
    it has created this one in this new new
  • 23:03 - 23:06
    field in the new search field what I
  • 23:06 - 23:10
    will do is on after this one
  • 23:10 - 23:13
    I will be calling my total salary
  • 23:13 - 23:16
    version 2 macro okay what it is doing
  • 23:16 - 23:18
    the work of both of these 2 bonus and
  • 23:18 - 23:21
    total salary right so total salary
  • 23:21 - 23:27
    version - okay so my tick version 2
  • 23:27 - 23:30
    version 2 requires three arguments one
  • 23:30 - 23:32
    is my basic salary variable percent and
  • 23:32 - 23:35
    the similar person value I will gives 8
  • 23:35 - 23:37
    so that we can at least compare what's
  • 23:37 - 23:41
    the outputs so if I run this one see if
  • 23:41 - 23:43
    it is it is working in the same way
  • 23:43 - 23:45
    where it is getting this bonus field and
  • 23:45 - 23:47
    total salary and if you see the output
  • 23:47 - 23:50
    is same as well
  • 23:50 - 23:54
    15:22 we have given seven here okay
  • 23:54 - 23:58
    let's let's run it with seven only see
  • 23:58 - 23:59
    if you see fifteen twenty two twenty two
  • 23:59 - 24:02
    twenty seventeen ten seventy like this
  • 24:02 - 24:06
    okay so this is how you can call a macro
  • 24:06 - 24:08
    inside another macro as well so if you
  • 24:08 - 24:12
    see here by by by by this structure you
  • 24:12 - 24:15
    can achieve a very complex structure as
  • 24:15 - 24:18
    well and complex structure which which
  • 24:18 - 24:20
    is basically a useable component in
  • 24:20 - 24:24
    Splunk search query okay so this is how
  • 24:24 - 24:27
    you need to know basically to deal with
  • 24:27 - 24:30
    macros and macros are very useful in
  • 24:30 - 24:33
    Splunk because not only it it it gives
  • 24:33 - 24:36
    you the modularity approach but also
  • 24:36 - 24:39
    it's it's is give you the very shorter
  • 24:39 - 24:41
    search string and very readable course
  • 24:41 - 24:45
    as well ok see you in next video
Title:
Splunk Basic : Everything to know about macros
Description:

more » « less
Video Language:
English
Duration:
24:44

English subtitles

Revisions Compare revisions