`input {
jdbc {
jdbc_driver_library => "/etc/logstash/conf.d/postgresql-jdbc.jar"
jdbc_driver_class => "org.postgresql.Driver"
jdbc_connection_string => "jdbc:postgresql://host:port/db"
jdbc_user => user
jdbc_password => pass
schedule => "* */4 * * *" # Schedule to run the query (e.g., every four hour)
statement => "SELECT * FROM advertising_metrics WHERE date >= current_date - interval '7 day';"
}
}
output {
elasticsearch {
hosts => "https://host:port/" # Elasticsearch host and port
user => user
password => pass
ssl_enabled => true
ssl_certificate_authorities => ["/etc/elasticsearch/certs/http_ca.crt"]
index => "reporting" # Name of the index in Elasticsearch
}
}`
I want to transfer last week’s data from postgresql to elasticsearch through logstash, but it keeps giving formatting error, I have tried different ways. Also can anyone guide me, I want to keep only recent week data in elasticsearch, removing the previous data continuously, how can I configure that in elasticsearch? Please tell me what’s wrong with the statement format.
New contributor
Nabiha Khan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.