Created
May 25, 2024 07:18
-
-
Save tomoyk/4d8d764fc51b37a324b08ad1ab1ace9e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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