►
From YouTube: Fluent Talks | 004 | Fluent Bit + Lua
Description
Please join us for Fluent Talks! Our weekly webinar and office hours, on Fridays at 2PM Central. Streaming live on YouTube.
This week we'll be discussing Fluent Bit + Lua. We'll include some cool scripts and real-world examples to help you get the most out of this powerful Fluent Bit filter.
#lua
A
A
A
Hello,
hello,
hi.
Everyone
thanks
and
welcome
to
this
fourth
episode
of
fluent
talks
sponsored
by
kalitia.
Today
we
have
one
of
our
engineers
joining
the
this
session.
His
name
is
tiago
he's
joining
us
from
brazil.
I
think
that
he
can
introduce
himself
later
and
today
we're
going
to
cover
a
little
bit
of
knowledge
of
lua,
scripting
and
lua
scripting.
A
Sorry,
I
got
some
return
on
my
oh.
You
just
lost
everything,
so
we're
going
to
do
some
intro
about
a
lua,
how
to
use
lua
tables
a
and
why
this
is
important,
because,
when
you're
doing
managing
pipelines
with
fluid,
sometimes
you
want
to
modify
your
data,
but
actually
sometimes
the
filters
are
not
enough,
and
sometimes
you
need
to
have
more
custom
logic
like
conditionals
or
remove
kit
or
nest
some
keys
at
a
different
level,
and
that
is
really
important,
and
since
we
have
a
lower
filter,
that
is
the
the
right
choice
for
choice.
A
B
A
B
B
Can
you
hear
me
yeah,
you're,
good,
all
right,
so
I'm
going
to
start
with
the
brief
introduction
to
the
word:
it's
a
dynamically
typed
language,
very
simple,
but
at
the
same
time
it's
it's
powerful.
You
can
do
a
lot
of
things
with
it.
You
can
do
object-oriented
programming,
functional
programming,
it's
very
efficient.
B
I've
never
done
any
performance
in
benchmarks
myself,
but
I've
read
that
it's
it's
a
bit
faster
than
other
similar
language
like
python
and
ruby,
and
it's
basically
it's
the
main
use
cases
to
embed
and
extend
other
problems.
It
was
designed
to
be
easily
embeddable
very
lightweight.
B
If
you
try
to
embed
another
language
like
python,
because
if
you
know
that
it's
it's
a
bit
conventional,
you
have
to
manage
a
garbage
collection.
Reference
and
lua
has
clean
enough
api.
That
makes
it
simple
to
that
and
it's
even
even
though
lua
is
not
very
used
like
as
and
use
a
programming
language
like
you.
Normally,
you
don't
write
programs
in
lua,
it's
very
widely
used
as
an
extension
language
in
many
games,
world
of
warcraft,
for
example,
very
famous
game.
B
It's
it
uses
lua
and
many
other
games.
I
think
roblox
also
uses
lua,
so
it's
very
widely
deployed
in
our
district
and
since
the
goal
is
embedded,
it's
also
the
target
platform
for
who
is
the
ncc.
B
So
it's
on
purpose,
it's
a
very
old,
it's
an
old
version
of
c.
That's,
I
think
it's
the
most
portable
platform
that
exists
today.
So
when
you,
if
you
can
have
a
c
compiler
for
a
platform,
then
you
can
build
lua
for
it.
It's
for
that
reason,
there
are
very
few
batteries
included.
Basically,
lua
is
the
standard
library
of
lua
is
mostly
a
high-level
wrapper
around
the
c
standard
library.
B
So
there
is
legit.
It's
an
alternative
implementation
of
lua
5.1.
B
It's
fully
compatible
and
it
has
a
cheat
compiler
that
that
translates
lua
bytecode
to
the
the
machine
bytecode,
and
this
is
very
optimized.
It's
I
think
it's
some
might
say:
that's
the
fastest
fastest
scripting
runtime
that
exists.
There
are
many
benchmarks
that
show
it
having
greater
performance
than
many
runtimes
that
are
created
by
big
companies
like
javascript
v8.
B
B
So
let's
have
a
look
at
some
of
the
data
types
of
some
basic
blue
code
here,
as
you
can
see,
it
has
the
standard
types
like
boolean
numbers.
It
doesn't
have
integers
so
now,
lewis
numbers
are
basically
doubles.
B
B
So
the
main
data
structure
of
it's
actually
the
only
data
structure
of
lua
are
tables
tables
are
basically
hash
tables.
It's
implemented
as
hash
tables.
It's
it's
an
associative
array
with
tables
you
can
out
of
the
box
with
standard
library.
You
can
use
tables
as
lists
and
as
maps.
B
So
you
can
see
an
example
here
we
have
a
list
of
three
items
and
you
can
insert
items
you
can
iterate
to
the
the
items
with
the
index
and
you
can
also
use
it
as
a
map,
associative
array.
You
can
add
arbitrary
keys
and
in
value
street
and
with
tables
you
can.
Basically,
you
can
basically
implement
any
everything
else
that
you
want.
B
One
thing
to
notice
that
if
you
look
at
the
I
I've
created
some
examples
here
when
you
do
an
assignment
like
that,
when
you
assign
to
to
a
variable
like
that,
it's
actually
assigned
to
a
global
variable
so
to
to
create
a
local
variable
inside
a
function
to
ensure
that
the
variable
is
not
defined.
B
You
have
to
precede
the
the
variable
with
local.
It's
how
you
declare
a
variable
to
be
local
to
the
function.
I'm
going
to
show
there'll
be
some
examples
later.
The
exceptions
are
parameters,
of
course.
So
when
you
have
a
function
like
this,
the
whatever
you
define
inside
the
function
is
only
visible
inside
the
function.
B
Very
simple
way
to
define
a
function,
if
else
basically
functions
of
of
the
language
so
loops
you
you
can.
B
The
main
way
to
iterate
is
by
using
iterators,
which
is
a
it's
a
construct
of
I'm
not
going
to
go
into
much
detail
into
how
it
works.
But
basically
you
call
a
certain
function.
That's
that
returns
on
it
iterator-
and
this
is
this-
makes
it
compatible
with
the
for
loop,
and
you
also
use.
If
you
want
to
do
a
plastic
look
like
iterator
to
arrange
there
is
a
function
that
returns
a
range
iterator.
B
So
that's
basically
it's
very
some
very
basic
things.
I've
shown
about
the
language.
I
think
that
it
will
be
very
extensive
to
cover
everything.
There
is
supports
quite
a
few
extra
features.
B
It
supports
cool
routines,
it
supports
while
loops
and
many
other
features-
and
I
think
the
best
place
to
learn
more
about
that
is
the
reference
manual.
B
I'm
going
to
show
some
examples
later,
but
for
now
I'd
like
to
talk
about
the
ecosystem
package
acquisition
for
work.
So
this
this
program
called
ruler,
rocks
you
can
install
it
on
many
linux
distributions,
it's
very
easy
to
install
and
it
allows
you
to
install
lua
packages.
It's
I
think
it's
similar
to
npm
for
node.js
and
pip
for
python.
B
So
anyone
can
create
packages
for
modules
and
publish
to
lure
rocks
registry
and
it
will
be
installable
like
this.
You
can
install
modules
and
then
you
can
require
you
can
use
the
modules
like
this
called
the
require
function
and
that's
basically
it's
very
familiar.
It
should
be
very
familiar
to
javascript
node.js
programmers.
B
And
this
is
all
easily
accessible
through
flintability.
B
Normally
you
have
you,
you
can
use
20
bit
configuration
tags
or
matching
tags
to
apply
certain
plugins
to
to
records,
but
with
lua
you
can
also
use
any
kind
of
criteria
to
draw
to
modify
records.
So
it's
very
flexible.
You
can
split
or
remove
records
and
you
can
install
any
pack.
You
can
use
any
lower
rocks
package.
B
Assuming
you
install
this
inspect
module,
it's
a
module
that
allows
you
to
stringify
any
newer
object,
including
tables.
This
is
not
something
that's
available
on
the
standard
library,
so
you
need
to
use
a
third
party
module
for
that,
and
this
is
what
what's
being
done.
B
It's
basically,
this
handler
function
is
going
to
be
called
by
fluid
bit
with
this.
The
following
parameters,
tag,
timestamp
and
record
record
is
a
table
that
contains
the
fluent
bit
record
keys
and
in
this
example,
we
don't
do
anything.
We
return
zero
as
the
code,
this
coded
it
tells
what
tells
fluid
what
to
do
with
the
record,
with
the
record
that
you're
returning,
if
you
return
zero,
it
means
flint
beats
not
going
to
modify
the
record
that
was
fast.
B
B
I've
created
these
in
obviously
this
into
a
repository,
so
anyone
can
run
this
later,
but
this
is
basically
how
you
run
it.
You
in
this
example
we're
using
the
input
plug-in
for
the
cpu
cpu
data,
we're
passing
through
the
lua
filter,
matching
all
tags
and
we're
telling
that
it
should
run
this.
This
script
called
log.lua
and
call
the
function
handler
and
for
output
we're
just
using
no
because
this
is
just
an
example
we're
showing
how
to
just
how
to
lock
records.
B
So
if
you
run
this
you'll
be
seeing
every
record
passed
sent
to
the
from
the
the
cpu
input,
but
it
will
be
printed
using
the
lua,
inspect
module.
B
So
here's
another
example:
it's
a
very
naive,
csv
password
it's
so
it
also
shows
a
bit
lua
patan
matching
library,
lua
doesn't
have
regular
expressions.
It
has
a
very
simple
pattern:
matching
it's
it's
not
that
it's
similar
to
regular
expression
but
less
powerful.
B
It
allows
you
to
have
some
of
these
constructs
that
are
similar
to
regular
expression.
Basically,
here
we
say
this
assuming
that
we're
receiving
records
that
contain
csv
data
on
the
on
the
log
key.
B
We
pass
fields
like
this.
I'm
also
going
to
show
this
running
later,
but
you
can
see
below
how
it
it.
This
is
called
very
similar
in
this
case
we're
also
returning
one,
because
we
want
the
flint
bit
to
modify
the
record
in.
A
A
B
B
B
B
So
this
is
the
git
repository
that
contains
source
material
for
this
talk
and
I've
created
a
docker
file
and
some
some
things
that
allow
make
it
easy
to
run
so.
The
first
example
that
we
saw
that
was
login
cpu
data
to
using
lua
inspect
model.
B
B
This
is
the
file.
That's
been
run,
let's
show
the
the
symbol,
csv
asap.
B
B
So
this
is,
let
me
show
the
file.
B
So
what
we're
doing
here
is
basically
we're
splitting
each
row
and
assigned
to
the
this
view
key
on
the
on
the
record
and,
as
you
can
see,
it's
zero
on
the
timestamp,
because
we
replace
the
timestamp
just
to
show
how
it
works.
B
B
We
are
passing
the
csv
dot
script
and
we're
calling
the
process
record,
and
this
is
the
function
that's
called
by
fluency.
As
you
can
see,
we
declare
headers
variable
in
the
module
and
the
first
record
that
we
received
are
actually
going
to
be
the
headers
of
the
csv
file.
B
See
it
here
contains
the
column
names
and
the
first
thing
we
do
is
we
call
the
split
csv
function
and
we
return
-1
to
drop
this
record
because
we
don't
want
point
b
to
process
direct
the
record.
It's
just
the
headers
and
we
store
the
headers
into
this
table
and
after
that,
all
the
next
record
that
we
receive
we're
going
to
basically
call
the
split
csv
function.
And
then
we
create
a
table
that
contains
the
record
data
and
we
assign
each
header
key
from
the
fuse.
B
This
is
basically
the
same
as
the
csv
example
that
they
wrote,
but
this
one
is,
you
uses
l
crack
opec.
Is
it's
a
powerful
library
do
a
library
for
patent
match
it's
actually
a
full
busing
library.
You
can
pass
even
a
full
programming
language
using
lpeg
and
you
define
the
grammar
using
language.
Constructs
I'm
not
going
to
go
into
much
detail,
but
basically
allows
you
to
override
operators
to
do
whatever
you
want.
B
So
the
library
auto
created
this
language
that
allows
you
to
define
languages
grammars
and
then
you
can
use
it
to
pass
anything
here.
We
just
took
this
grammar
out
of
the
object
website
and
we
use
it
process
csv
in.
B
As
the
other
case,
but
in
this
case
just
to
illustrate-
you
can
see
that
we're
returning
two
and
we're
changing
the
timestamp
to
zero,
but
this
is
not
going
to
be
used
because
we're
done
in
two.
So
let
me
show
how
that
works.
B
B
So
all
these
material,
all
this
source
code
is
available.
Anyone
can
run
I've
created
a
docker
file
that
will
set
up
a
flatbeat,
a
docker
image
based
on
flatbeats
official
image,
and
it
will
install
all
the
dependencies.
So
all
you
need
is
docker
and
there
are
some
instructions
on
on
the
repository.
A
I
know
that
not
all
users
are
aware
about
the
capabilities,
and
the
intention
of
this
is
like
how
we
can
also
provide
more
knowledge
on
managing
records
across
the
fluent
bit
pipelines,
and
we
experimented
also
with
other
ideas
on
how
to
improve
experience
with
scripting
with
lou
and
fluence,
and
we
might
have
some
news.
You
know
in
a
couple
of
weeks,
so
well,
lua
is
rather
used.
If
he
used
to
manage,
I
don't
know
nginx
web
servers
right
configuration
has
conditions
with
lua.
A
If
you
used
to,
I
don't
know,
develop
games
and
roblox
also
is
purely
lua
based.
So
this
is
a
very
interesting
scripting
language,
with
just-in-time,
compiling
functionality
that,
when
you
said
the
the
performance
penalty
is
very,
very
minimal.
So
actually
we
found
use
cases
where
people
has
a.
I
don't
know
five
to
seven
or
eight
filters,
and
actually
all
of
that
was
a
bit
more
expensive
competing
time.
A
They
just
have
one
single
lua
script,
doing
the
same
job,
so
the
invitation
for
the
the
audience
is
just
take
a
look
at
the
lua
script
into
the
filters.
We're
going
to
have
all
the
information
listed
in
this
this
session
and
then
the
youtube
channel
and
feel
free
to
just
leave
your
question
we'll
be
happy
to
to
answer
them
and
if
you
want
to
contribute
to
deploy,
you
know
that
we
hang
in
the
fluent
website
or
github.
B
B
A
B
If
you
go
into
the
discussions
tab,
I
think.
B
Okay,
he
did
it
here,
it
is
so
this
is
the
discussion.
B
It
was
created
last
year,
but
anyone
can
come
here
and
contribute
give
suggestions.
A
A
Well,
I
I
think
that
we
have
and
reached
the
end
of
this
session,
thanks
diablo
for
your
time
on
this
presentation,
and
we
hope
to
have
you
again
presented
here-
maybe
a
different
topic
or
more
advanced
lua,
stuff
and
yeah.
We
just
left
the
invitation
open
to
the
audience
to
take
a
look
at
the
fluency
project
and
yeah.
Follow
the
fluent
talks,
we're
going
to
share
different
technical
topics,
not
just
about
flambe
but
others
about.