Skip to content

How can I exclude ipv6 from filebeat field host.ip? #13839

Answered by tobz
jmjoy asked this question in Q&A
Discussion options

You must be logged in to vote

👋🏻

I think you could accomplish this with VRL. VRL actually does now (as of v0.22.0) have iteration support via for_each. Here's my initial thought on how you might achieve this in a remap transform:

# Will hold all of the filtered IPs.
filtered_ips = []

# Iterate over each IP in `.host.ip`. We forcefully make sure that
# `.host.ip` is actually an array, otherwise the VRL program errors.
for_each(array!(.host.ip)) -> |_index, ip| {
  # We're not yet sure if the elements in `.host.ip` are strings,
  # so try and coerce them, since `ipv6_to_ipv4` needs a string.
  ip_str, err = string(ip)
  if err == null {
    # The IP value is a string, so now we run it through `ipv6_to_ipv4`
    # which…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@jmjoy
Comment options

@tobz
Comment options

tobz Aug 4, 2022
Collaborator

@jmjoy
Comment options

Answer selected by jmjoy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants