< Return to Video

Splunk Tutorial For Beginners | Stats vs Eventstats vs Streamstats Command in Splunk

  • 0:04 - 0:10
    [Music]
  • 0:10 - 0:13
    welcome to another lame log analysis
  • 0:13 - 0:15
    made easy tutorial this one we're going
  • 0:15 - 0:19
    to talk about stats event stats and
  • 0:19 - 0:22
    stream stats and we're basically this
  • 0:22 - 0:24
    this uh tutorial will be to brief you on
  • 0:24 - 0:27
    the difference between the three and
  • 0:27 - 0:28
    they are slightly different I'm going to
  • 0:28 - 0:29
    try different a few different ways to
  • 0:29 - 0:31
    show it and hopefully by the end of this
  • 0:31 - 0:34
    uh tutorial you'll have a good idea of
  • 0:34 - 0:36
    how they can be used uh I'll put another
  • 0:36 - 0:39
    video on after this one of use cases for
  • 0:39 - 0:41
    example analytic hunting and stuff that
  • 0:41 - 0:43
    you might actually use the different
  • 0:43 - 0:46
    queries for but let's start first off
  • 0:46 - 0:48
    stats command um I just started here
  • 0:48 - 0:51
    index equals internal table is source
  • 0:51 - 0:53
    and Source type stats give me the
  • 0:53 - 0:55
    distinct Count Of The Source by The
  • 0:55 - 0:59
    Source type um DC is distinct count so
  • 0:59 - 1:01
    basically I'm looking at internal log I
  • 1:01 - 1:02
    just want to do something you could do
  • 1:02 - 1:05
    it uh anywhere you want and I'm just uh
  • 1:05 - 1:07
    getting all the distinct sources by
  • 1:07 - 1:09
    Source type when I ran that I see that
  • 1:09 - 1:12
    this Source type uh Splunk assist
  • 1:12 - 1:15
    internal log has two sources uh this one
  • 1:15 - 1:17
    has three most of these just have one
  • 1:17 - 1:20
    this one Splunk D has four sources and
  • 1:20 - 1:22
    what you'll not what it does is it takes
  • 1:22 - 1:25
    155,156
  • 1:30 - 1:31
    in case you ever want to get Splunk
  • 1:31 - 1:33
    certified or hear these things these are
  • 1:33 - 1:35
    transformation commands transformation
  • 1:35 - 1:38
    commands take logs and change them into
  • 1:38 - 1:41
    primarily into tables uh it it takes the
  • 1:41 - 1:43
    raw log format and turns it into a table
  • 1:43 - 1:45
    often with stats you'll collapse like
  • 1:45 - 1:49
    here massive reduction uh anyway and
  • 1:49 - 1:53
    we've done that so let's show that stats
  • 1:53 - 1:56
    let's show event stats event stats it's
  • 1:56 - 2:01
    going to take oh um here very another
  • 2:01 - 2:02
    example of that command we're going to
  • 2:02 - 2:05
    just use this is uh corite index I'm
  • 2:05 - 2:07
    looking at my connection logs I'm doing
  • 2:07 - 2:08
    Source IP destination I'm still staying
  • 2:08 - 2:11
    with the stats command here I'm going to
  • 2:11 - 2:12
    give me give me all of the distinct
  • 2:12 - 2:15
    counts of destination IPS to a source IP
  • 2:15 - 2:18
    so how many different IP addresses did
  • 2:18 - 2:21
    each Source IP go to there were 31,800
  • 2:21 - 2:23
    total events but it only displays 81
  • 2:23 - 2:27
    because it collapses them down I can see
  • 2:27 - 2:31
    that 192 1680 103 went to 33 different
  • 2:31 - 2:36
    addresses 25 7 10 43 Etc and that is
  • 2:36 - 2:39
    stats now look let's look at event stats
  • 2:39 - 2:41
    event stats going back to my original
  • 2:41 - 2:46
    example we had 155,000 18 events showed
  • 2:46 - 2:48
    here the exact same query give me a
  • 2:48 - 2:50
    distinct count on this
  • 2:50 - 2:54
    internal what you'll notice is I had
  • 2:54 - 2:58
    55,1 18 results come back close enough
  • 2:58 - 3:01
    clearly was based off when they ran uh
  • 3:01 - 3:05
    and how many displays
  • 3:29 - 3:32
    155,156 up as individual lines of the
  • 3:32 - 3:34
    entire group so it's going to go look at
  • 3:34 - 3:36
    this entire data set and come back with
  • 3:36 - 3:39
    the statistical numbers for each line
  • 3:39 - 3:41
    and so we can if we move on we'll see
  • 3:41 - 3:43
    when Splunk metric log
  • 3:43 - 3:45
    changes somewhere down the line we'll
  • 3:45 - 3:48
    eventually get there it changes now we
  • 3:48 - 3:50
    have this access log and there's just
  • 3:50 - 3:53
    one unique two unique and so each here
  • 3:53 - 3:55
    you got the two you
  • 3:55 - 3:59
    can and two blah blah and down the lines
  • 3:59 - 4:01
    we go
  • 4:01 - 4:03
    so basically this is just statistic
  • 4:03 - 4:05
    stating and each line gets it stuff
  • 4:05 - 4:06
    added to
  • 4:06 - 4:10
    it another example using my corite logs
  • 4:10 - 4:13
    hopefully this pushes it out here's my
  • 4:13 - 4:16
    source IP here's my destination IP uh
  • 4:16 - 4:17
    one of the things you'll notice be
  • 4:17 - 4:20
    careful with stats you lose values when
  • 4:20 - 4:24
    you use stats so here has stats 10,000
  • 4:24 - 4:25
    um I would need to do something
  • 4:25 - 4:27
    different to allow me to have be able to
  • 4:27 - 4:29
    bring back more than 10,000 events but
  • 4:29 - 4:31
    just so I I'm we're just going to move
  • 4:31 - 4:33
    on and ignore the fact that if I had let
  • 4:33 - 4:35
    the limits be as big it would be
  • 4:35 - 4:39
    31780 events and so I come back and we
  • 4:39 - 4:42
    can see how many times did zero how many
  • 4:42 - 4:45
    different IP addresses did 0.0.0 talk to
  • 4:45 - 4:48
    one this it t and it doesn't matter how
  • 4:48 - 4:50
    many times it shows up it only talked
  • 4:50 - 4:52
    one time now here we can see
  • 4:52 - 4:56
    133 it t it says there were two we can
  • 4:56 - 4:59
    see the first one 192 168
  • 4:59 - 5:01
    0.125
  • 5:01 - 5:05
    125 125 125 still the same but somewhere
  • 5:05 - 5:07
    around here there's going to be oh there
  • 5:07 - 5:10
    it is this one here there's my that's
  • 5:10 - 5:11
    the second one and that's why we have
  • 5:11 - 5:14
    two but it marks two to every one of
  • 5:14 - 5:16
    these
  • 5:16 - 5:18
    events and same if I had something with
  • 5:18 - 5:21
    three or up like here 44 if I count it
  • 5:21 - 5:24
    all that there will be 44 distinct IP
  • 5:24 - 5:27
    addresses uh in all these pairings that
  • 5:27 - 5:30
    go together here I've got two which is
  • 5:30 - 5:32
    251
  • 5:32 - 5:34
    119 that's why I've got
  • 5:34 - 5:38
    two so event stats it'll take the
  • 5:38 - 5:41
    entire uh beginning to end of all your
  • 5:41 - 5:43
    data do its mathematical analysis and
  • 5:43 - 5:46
    every log that came back will get that
  • 5:46 - 5:49
    value written into it stream stats does
  • 5:49 - 5:52
    slightly different stream stats I'm
  • 5:52 - 5:55
    going to show my last example here
  • 5:55 - 5:59
    NOP this one's my last example nope
  • 5:59 - 6:02
    where did I put that that okay this one
  • 6:02 - 6:05
    here I'm just going to show stream stats
  • 6:05 - 6:07
    actually does very similar to what event
  • 6:07 - 6:10
    stats does but it takes each line as it
  • 6:10 - 6:13
    comes through the uh stream from the
  • 6:13 - 6:15
    indexer and computes it and keeps
  • 6:15 - 6:19
    growing so for example here I did a head
  • 6:19 - 6:21
    100 I've I'm not going to use any of the
  • 6:21 - 6:22
    values I'm just going to say stream
  • 6:22 - 6:25
    stats count and I just want to know so
  • 6:25 - 6:28
    if you done stats count if I done a head
  • 6:28 - 6:30
    100 and I do a stats count guess what
  • 6:30 - 6:33
    the Count's going to be 100 or less if
  • 6:33 - 6:35
    there's not 100 values that come back uh
  • 6:35 - 6:37
    but if I do stream stats I'm going to
  • 6:37 - 6:39
    count as a event count so I can see it
  • 6:39 - 6:42
    growing and I'm going to table it and
  • 6:42 - 6:43
    the very first value that comes back it
  • 6:43 - 6:45
    says how many total events are there
  • 6:45 - 6:47
    well when the first event comes back
  • 6:47 - 6:49
    there'll be one then when the second
  • 6:49 - 6:50
    event comes back how many total will
  • 6:50 - 6:53
    there be two when the third one comes in
  • 6:53 - 6:55
    line how many will be there be three
  • 6:55 - 6:58
    four five six seven Etc until I reach
  • 6:58 - 7:02
    the back and it's 100 so what happens is
  • 7:02 - 7:05
    this statistical number keeps growing as
  • 7:05 - 7:08
    the items come through the stream event
  • 7:08 - 7:09
    stats totals the
  • 7:09 - 7:12
    entire uh bundle from beginning to end
  • 7:12 - 7:14
    statistical numbers and puts them on
  • 7:14 - 7:16
    each line stream stats takes each line
  • 7:16 - 7:19
    as it comes through and does the math on
  • 7:19 - 7:21
    them so let's show another kind of
  • 7:21 - 7:25
    putting this in practice here this is my
  • 7:25 - 7:27
    internal logs Source we're doing the
  • 7:27 - 7:30
    stinct count 11111 and we can basically
  • 7:30 - 7:34
    okay so 1111111 nothing's
  • 7:34 - 7:36
    changing is there a place where we get
  • 7:36 - 7:39
    something that
  • 7:43 - 7:46
    changes uh too much all right let's see
  • 7:46 - 7:48
    we might go
  • 7:48 - 7:53
    to my bro log make it
  • 7:53 - 7:55
    easier yeah too many of these to uh mess
  • 7:55 - 7:58
    around with we'll go to bro I I did
  • 7:58 - 8:00
    stream stats not that one stream stats
  • 8:00 - 8:02
    here I'm doing
  • 8:02 - 8:06
    IPS and so we can see here
  • 8:06 - 8:09
    one so all these come back it talked how
  • 8:09 - 8:12
    many times has 468 talked here how many
  • 8:12 - 8:16
    distinct IPS one still when it comes
  • 8:16 - 8:18
    here is it seeing anything new nope so
  • 8:18 - 8:20
    it's one seeing anything new nope it's
  • 8:20 - 8:22
    one so is it seeing anything new nope
  • 8:22 - 8:25
    it's one oh wait this is a new IP
  • 8:25 - 8:28
    pairing so the number jumps to two now
  • 8:28 - 8:30
    it flips back but it's already seen that
  • 8:30 - 8:34
    one so it stays at two two two two two
  • 8:34 - 8:37
    two and then when it reaches a Brand New
  • 8:37 - 8:39
    Pair how many times has it seen this one
  • 8:39 - 8:42
    talk to this one goes back to one then
  • 8:42 - 8:44
    it grows again because oh there's a new
  • 8:44 - 8:46
    there's new communication there so two
  • 8:46 - 8:49
    two two oh brand new communication so it
  • 8:49 - 8:52
    resets back to one and so that's what
  • 8:52 - 8:55
    stream stats will do it will based off
  • 8:55 - 8:58
    your pairing the buy each time you have
  • 8:58 - 9:00
    a buy on there if the the uh that field
  • 9:00 - 9:04
    changes the count restarts if I didn't
  • 9:04 - 9:05
    put a Buy in
  • 9:05 - 9:08
    there this number would just keep R keep
  • 9:08 - 9:09
    growing each time it finds a new
  • 9:09 - 9:11
    distinct count on the destination
  • 9:11 - 9:14
    IP and basically it's just going to keep
  • 9:14 - 9:17
    adding up and so you've got stats which
  • 9:17 - 9:19
    Aggregates all of your F all of your
  • 9:19 - 9:22
    events into uh very simplified forms and
  • 9:22 - 9:24
    it does statistical for the
  • 9:24 - 9:28
    entire uh the entire summarized set of
  • 9:28 - 9:32
    data there then you have event stats
  • 9:32 - 9:34
    which it grabs the entire from beginning
  • 9:34 - 9:36
    to end does the mathematical statistics
  • 9:36 - 9:38
    on it and adds that value to each line
  • 9:38 - 9:42
    and it repeats it so if there were seven
  • 9:42 - 9:44
    distinct values here all seven would
  • 9:44 - 9:47
    have the exact same value and stream
  • 9:47 - 9:49
    stats it orders it it basically each
  • 9:49 - 9:51
    item coming through the pipe through the
  • 9:51 - 9:54
    stream will change your statistics and
  • 9:54 - 9:56
    so you're not it will it will it's a
  • 9:56 - 9:58
    different way of looking at it all three
  • 9:58 - 10:00
    are different ways of of uh looking at
  • 10:00 - 10:02
    statistical packages statist uh getting
  • 10:02 - 10:04
    some understanding of the data as that
  • 10:04 - 10:06
    flows through but that's basic principle
  • 10:06 - 10:08
    if you want it quick and dirty you want
  • 10:08 - 10:10
    just a summarized bit of data on there
  • 10:10 - 10:13
    stats is your stats is your is
  • 10:13 - 10:16
    keing and stream stats is on the other
  • 10:16 - 10:17
    example where you're basically looking
  • 10:17 - 10:21
    for anomalies or averages over time over
  • 10:21 - 10:24
    the period And I will be showing another
  • 10:24 - 10:26
    tutorial right after this of useful
  • 10:26 - 10:28
    queries where you can change the windows
  • 10:28 - 10:31
    and change how it groups things together
  • 10:31 - 10:33
    but stream stats is one of the is an
  • 10:33 - 10:36
    amazing query for being able to know do
  • 10:36 - 10:39
    do previous values have an effect on
  • 10:39 - 10:41
    future values for looking for anomalies
  • 10:41 - 10:44
    and and so anyway I hope this helps you
  • 10:44 - 10:46
    from being a lame analyst to a Splunk
  • 10:46 - 10:49
    ninja and if you like this uh feel free
  • 10:49 - 10:52
    to subscribe to my Channel please uh put
  • 10:52 - 10:54
    down below any comments questions you
  • 10:54 - 10:56
    might have any content you want me to uh
  • 10:56 - 10:58
    uh do a video on I love to hear from you
  • 10:58 - 11:00
    guys I like to do content that you guys
  • 11:00 - 11:02
    want to see anyway I hope you'll keep
  • 11:02 - 11:05
    coming back and uh keep watching these
  • 11:05 - 11:07
    videos
Title:
Splunk Tutorial For Beginners | Stats vs Eventstats vs Streamstats Command in Splunk
Description:

more » « less
Video Language:
English
Duration:
11:06

English subtitles

Revisions Compare revisions