Skip to content

Instantly share code, notes, and snippets.

@tomoyk
Created May 25, 2024 07:18
Show Gist options
  • Save tomoyk/4d8d764fc51b37a324b08ad1ab1ace9e to your computer and use it in GitHub Desktop.
Save tomoyk/4d8d764fc51b37a324b08ad1ab1ace9e to your computer and use it in GitHub Desktop.
input {
file {
path => "/var/log/nginx/access.*.log"
start_position => "access_pos"
sincedb_path => "/var/log/nginx/access.pos"
add_field => { "log_filename" => "%{path}" }
}
file {
path => "/var/log/nginx/error.*.log"
start_position => "error_pos"
sincedb_path => "/var/log/nginx/error.pos"
add_field => { "log_filename" => "%{path}" }
}
}
filter {
mutate {
if [path] =~ "/var/log/nginx/" {
gsub => [
"log_filename", "/var/log/nginx/", ""
]
}
}
}
output {
google_cloud_storage {
bucket => "your-bucket-name"
key_path => "/path/to/your-service-account-key.json"
log_file_prefix => "logs/"
temp_directory => "/tmp/logstash-gcs"
gzip => true
date_pattern => "%Y/%m/%d"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment