How can we get the input csv file path or filename in email.
Below is my config for the input and output:
input {
file {
path => "path to file/*.csv"
type => "csv"
start_position => beginning
}
file {
path => "path to log/logstash-plain.log"
type => "syslog"
sincedb_path => "null"
filter{}
output
{
if [type] == "csv"
{
elasticsearch {
hosts => "localhost:9200"
index => "cmss"
document_type => "cms"
document_id => "%{id}"
}
}
if [type] == "syslog"
{
if "[ERROR ]" in [message]
{
email {
address => ".........................."
subject => "logstash alert"
to => "......................."
body => "%{message}"
}
}
}
You should be able to find the input filename in the path field so you can just reference that field in the email output's body option just like you're currently doing with the message field.
Yes, I tried with the same way, which you can see below, But it sends multiple emails with the path according to the number of document or rows of loading file.
output
{
if [type] == "csv"
{
elasticsearch {
hosts => "localhost:9200"
index => "cmss"
document_type => "cms"
document_id => "%{id}"
}
email {
address => ".........................."
subject => "logstash alert"
to => "......................."
body => "%{path}"
}
}
if [type] == "syslog"
{
if "[ERROR ]" in [message]
{
email {
address => ".........................."
subject => "logstash alert"
to => "......................."
body => "%{message}"
}
}
}
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.