Giter VIP home page Giter VIP logo

Comments (5)

spujadas avatar spujadas commented on May 26, 2024

Hi Brad,

First, a quick disclaimer: I'm not a Logstash guru by any means. 😕

I think there are two reasons why your config file isn't working:

  • As far as I understand, the if ... else ... block can't go inside an elasticsearch section.
  • I believe that mutate only works in a filter section, so you can't use it to dynamically alter index and document_type.

Again, not an expert so you may want to post your issue to the Logstash community to check what the "right" way to this would be, but the following config should work:

output {
  if [@metadata][beat] =~ "filebeat-" {
    elasticsearch {
      hosts => ["localhost"]
      sniffing => true
      manage_template => false
      index => "%{[@metadata][beat]}-%{+YYYY.MM.dd}" 
      document_type => "%{[@metadata][type]}" 
    } 
  } else {
    elasticsearch { 
      hosts => ["localhost"]
      sniffing => true
      manage_template => false
      index => "other" 
      document_type => "stuff" 
    }
  }
  stdout { 
    codec => rubydebug 
  }
}

(I see that in https://discuss.elastic.co/t/how-to-handle-multiple-inputs-with-logstash-to-different-indices/24541 the name of the index is assigned using grok at filter time – might be worth a shot.)

from elk-docker.

humbled avatar humbled commented on May 26, 2024

Looks like it's done the job thanks. I'll update if I come across any downsides. I'll tidy up our implementation down the track if we add many more input types.

Is it worth pulling something similar into your image? I guess the same issue will crop up for anything using the lumberjack input?

from elk-docker.

spujadas avatar spujadas commented on May 26, 2024

OK cool, thanks.

The image has indeed been strongly biased towards Beats since Lumberjack was deprecated in favour of Filebeat. To keep things clean I probably won't be updating the image (each user's situation will be different, so accommodating the most common use case here), but I'll certainly add some words in the documentation to guide users in the right direction should they need to add support for a non-Beats shipper alongside Beats.

from elk-docker.

humbled avatar humbled commented on May 26, 2024

Turns out the above if wasn't right. Here it is for completeness:

output {
  if [@metadata][beat] {
    elasticsearch {
      hosts => ["localhost"]
      sniffing => true
      manage_template => false
      index => "%{[@metadata][beat]}-%{+YYYY.MM.dd}" 
      document_type => "%{[@metadata][type]}" 
    } 
  } else {
    elasticsearch { 
      hosts => ["localhost"]
      sniffing => true
      manage_template => false
      index => "other" 
      document_type => "stuff" 
    }
  }
  stdout { 
    codec => rubydebug 
  }
}

from elk-docker.

spujadas avatar spujadas commented on May 26, 2024

Nice one. Thanks for the update.

from elk-docker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.