Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Testing the ELK in DevOps | Monitoring & Logging in DevOps
Introduction to DevOps

bookTesting the ELK in DevOps

Now that the Docker Compose file is fully configured and all services are defined, it is time to test the system. Testing ensures that each component β€” the Flask application, Filebeat, Logstash, Elasticsearch, and Kibana β€” is running correctly and communicating with each other as expected.

Building Containers

To start the containers in detached mode and ensure any changes in the Dockerfiles are applied, run:

This command rebuilds the images if there are any changes (--build) and starts all containers in the background (-d) so your terminal remains free. It ensures that the latest configuration and code are applied without blocking your terminal.

After starting the containers, it is important to verify that all services are running correctly. Run the following command in your terminal:

This command lists all containers along with their status, names, and ports. You should see that every container β€” the Flask application, Filebeat, Logstash, Elasticsearch, and Kibana β€” is in the UP state.

If any container is not in this state, check its logs to identify and fix the issue before proceeding.

Testing the ELK Logging Pipeline

Open your browser and go to localhost:5601. Kibana runs on this port. Once the interface loads, open the panel on the left and go to the Discover tab.

Click Create data view to specify which logs to display:

  • Enter a name, for example logs;

  • In the Index pattern field, enter flask-logs*. The asterisk means any index starting with flask-logs will be included;

  • Click Save data view.

Kibana will now display logs from the application. At this point, only the initial startup records appear.

Next, test the application by opening localhost:5050 in a new browser tab. Visiting pages creates log events in the container, which are processed by Filebeat and Logstash and displayed in Kibana. Go back to Kibana and click Refresh. Within 10–15 seconds, new logs appear, such as "User opened the home page" or "User clicked the button".

All containers are running, and the ELK pipeline is fully functional. Logs from the Flask app are collected, processed, and displayed in Kibana in real time. Your logging system is now ready to monitor and analyze application activity.

1. Which command correctly starts all containers defined in the Docker Compose file?

2. What port do you use to access Kibana in this setup?

question mark

Which command correctly starts all containers defined in the Docker Compose file?

Select the correct answer

question mark

What port do you use to access Kibana in this setup?

Select the correct answer

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 4. ChapterΒ 6

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

Suggested prompts:

What should I do if one of the containers is not in the UP state?

How can I view the logs in Kibana after starting the containers?

Can you explain how to test if the logging pipeline is working correctly?

Awesome!

Completion rate improved to 3.7

bookTesting the ELK in DevOps

Swipe to show menu

Now that the Docker Compose file is fully configured and all services are defined, it is time to test the system. Testing ensures that each component β€” the Flask application, Filebeat, Logstash, Elasticsearch, and Kibana β€” is running correctly and communicating with each other as expected.

Building Containers

To start the containers in detached mode and ensure any changes in the Dockerfiles are applied, run:

This command rebuilds the images if there are any changes (--build) and starts all containers in the background (-d) so your terminal remains free. It ensures that the latest configuration and code are applied without blocking your terminal.

After starting the containers, it is important to verify that all services are running correctly. Run the following command in your terminal:

This command lists all containers along with their status, names, and ports. You should see that every container β€” the Flask application, Filebeat, Logstash, Elasticsearch, and Kibana β€” is in the UP state.

If any container is not in this state, check its logs to identify and fix the issue before proceeding.

Testing the ELK Logging Pipeline

Open your browser and go to localhost:5601. Kibana runs on this port. Once the interface loads, open the panel on the left and go to the Discover tab.

Click Create data view to specify which logs to display:

  • Enter a name, for example logs;

  • In the Index pattern field, enter flask-logs*. The asterisk means any index starting with flask-logs will be included;

  • Click Save data view.

Kibana will now display logs from the application. At this point, only the initial startup records appear.

Next, test the application by opening localhost:5050 in a new browser tab. Visiting pages creates log events in the container, which are processed by Filebeat and Logstash and displayed in Kibana. Go back to Kibana and click Refresh. Within 10–15 seconds, new logs appear, such as "User opened the home page" or "User clicked the button".

All containers are running, and the ELK pipeline is fully functional. Logs from the Flask app are collected, processed, and displayed in Kibana in real time. Your logging system is now ready to monitor and analyze application activity.

1. Which command correctly starts all containers defined in the Docker Compose file?

2. What port do you use to access Kibana in this setup?

question mark

Which command correctly starts all containers defined in the Docker Compose file?

Select the correct answer

question mark

What port do you use to access Kibana in this setup?

Select the correct answer

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 4. ChapterΒ 6
some-alt