logstash ec2 instanceid

How to get Logstash to read your ec2 instance id



EC2_INSTANCE_ID=$(curl -s
myjava=$(which java)
if [ -z $myjava ]; then
  echo "java is required; please install openjdk or jre"
  exit 1
# spawn logstash
$myjava -jar $lsjar agent -f $conf

config file /opt/logstash/simple.conf

input {
  exec {
    type => "instance-id"
    command => "echo -e -n ${EC2_INSTANCE_ID}"
    interval => 5
filter {
  grok {
    type => "instance-id"
    pattern => "[A-Za-z0-9_-]+"
    named_captures_only => true
output {
  stdout { debug => true debug_format => "json" }

1 comment to logstash ec2 instanceid

Leave a Reply

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>