How can I setup logstash with Python. Note that I am using mysql as my database and api's are built using django-ninja. So, kind of I want to connect logstash with MySQL using Python.
Please reply if any other detail is required.
FROM docker.elastic.co/logstash/logstash:7.9.3
# Download JDBC connector for Logstash
RUN curl -L --output "mysql-connector-java-8.0.22.tar.gz" "https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-8.0.22.tar.gz" \
&& tar -xf "mysql-connector-java-8.0.22.tar.gz" "mysql-connector-java-8.0.22/mysql-connector-java-8.0.22.jar" \
&& mv "mysql-connector-java-8.0.22/mysql-connector-java-8.0.22.jar" "mysql-connector-java-8.0.22.jar" \
&& rm -r "mysql-connector-java-8.0.22" "mysql-connector-java-8.0.22.tar.gz"
ENTRYPOINT ["/usr/local/bin/docker-entrypoint"]
Logstash is a java application, it will use the JDBC to connect to relation databases.
Logstash will connect to your database and send the data to the configured output, which normally is Elasticsearch, your python code/api would have nothing to do in this process.
Please be patient in waiting for responses to your question and refrain from pinging multiple times asking for a response or opening multiple topics for the same question. This is a community forum, it may take time for someone to reply to your question. For more information please refer to the Community Code of Conduct specifically the section "Be patient". Also, please refrain from pinging folks directly, this is a forum and anyone that participates might be able to assist you.
If you are in need of a service with an SLA that covers response times for questions then you may want to consider talking to us about a subscription.
It's fine to answer on your own thread after 2 or 3 days (not including weekends) if you don't have an answer.
FROM docker.elastic.co/logstash/logstash:7.9.3
# Download JDBC connector for Logstash
RUN curl -L --output "mysql-connector-java-8.0.22.tar.gz" "https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-8.0.22.tar.gz" \
&& tar -xf "mysql-connector-java-8.0.22.tar.gz" "mysql-connector-java-8.0.22/mysql-connector-java-8.0.22.jar" \
&& mv "mysql-connector-java-8.0.22/mysql-connector-java-8.0.22.jar" "mysql-connector-java-8.0.22.jar" \
&& rm -r "mysql-connector-java-8.0.22" "mysql-connector-java-8.0.22.tar.gz"
ENTRYPOINT ["/usr/local/bin/docker-entrypoint"]
Now, my question is that if I setup logstash as in the docker-compose and logstash dockerfile in the repo, will it work for Python as well ?
Because JDBC works for Java and my application is built upon Django and Django-Ninja ??
Overall, I am trying to sync mysql with Elasticsearch, so if my api is doing any create, update or delete it should also reflect in Elasticsearch.
I'm not sure how Python is related here but anyway, one of the major problem you might have to solve at first is to use the same version for the Elasticsearch cluster (8.12.2) and Logstash which is currently using 7.9.3. This won't work.
Again I don't really see what you want to do. I mean: what is the use case...
If your goal is to have your application, storing data in MySQL and indexed into Elasticsearch (for search), then indeed Logstash can help for that. But I'd recommend modifying the application layer if possible and send data to elasticsearch in the same "transaction" as you are sending your data to the database.
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.