Unable to write to avro file from logstash

Hi,

I am trying to write the file using avro codel in logstash.

Below is my simple configuration:

===
input {
file {
path => "/Users/srini/Downloads/imp/2016-01-22/*.json"
start_position => "beginning"
}
}

output {
file {
  path => "/Users/srini/Downloads/imp/2016-01-32/"
  codec => avro {schema_uri => "/Users/srini/Sri_Search/av.avsc"}
 }
  stdout { codec => rubydebug }
}

===

After this i have copied a json file to the target folder.
But, nothing is happening.

Below is the json and avsc files.

Json:

{"username":"miguno","tweet":"Rock: Nerf paper, scissors is fine.","timestamp": 1366150681 }

Avsc file:

{
  "type" : "record",
  "name" : "twitter_schema",
  "namespace" : "com.miguno.avro",
  "fields" : [ {
    "name" : "username",
    "type" : "string",
    "doc"  : "Name of the user account on Twitter.com"
  }, {
    "name" : "tweet",
    "type" : "string",
    "doc"  : "The content of the user's Twitter message"
  }, {
    "name" : "timestamp",
    "type" : "long",
    "doc"  : "Unix epoch time in seconds"
  } ],
  "doc:" : "A basic schema for storing Twitter messages"
}
  1. Can we use codec with output format.?
  2. Why it is unable to take any data.? I have movied a new file to the folder. At least it is not throwing any error.

The destination file (the path option of your file output) is a directory. I'm pretty sure it needs to be a path to a file.

HI @magnusbaeck

I have changed the configuration to

input {
    file {
        path => "/Users/srini/Downloads/imp/2016-01-22/*.json"
        start_position => "beginning"
    }
}

output {
file {
  path => "/Users/srini/Downloads/imp/2016-01-31/test-%{+YYYY-MM-dd}.avro"
  codec => avro { schema_uri => "/Users/srini/Sri_Search/av.avsc" }
 }
  stdout { codec => rubydebug }
} 

and restarted the logstash and copied new file into folder. But, still no use.

Read the Logstash logs. If there's nothing interested, increase logging verbosity with --verbose.

Hi @magnusbaeck

I have tried that.. I gave --verbose and nothing has been printed. I have also deleted .sincedb* (though irrelevant, just to see what it can do).

However, if i gave wrong file that does not match the format, it is throwing error. But nothing is being printed/done for the right files.

Did you get a chance to try with the files that i have given.?

Thank You,
Regards,
Srini.

Did you get a chance to try with the files that i have given.?

No, I don't have time to do that.

If I were to debug this, I'd make the file input and outputs work okay independently from each other, i.e. first define a stdin input as the only input and pass it data that you know is correct and thus verify that the output works. Perhaps use a stdout output with an avro codec instead of a file output. Increase logging even more with --debug as necessary.