Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Apprendre Challenge: Log Error Extractor | Monitoring and Log Analysis
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Python for DevOps Beginners

bookChallenge: Log Error Extractor

In DevOps, being able to quickly identify errors in log files is essential for diagnosing issues and maintaining system reliability. Log files can be lengthy and filled with a variety of information, but your ability to extract and count error messages efficiently can save valuable troubleshooting time. In this challenge, you will write a Python script that processes a hardcoded list of log entries, extracts all lines containing the word ERROR, prints each error line, and counts the total number of errors found. This exercise simulates a simple log monitoring tool, a fundamental skill for any DevOps professional.

Tâche

Swipe to start coding

Implement a script that extracts and counts error messages from a list of log entries.

  • Iterate through each string in the log_entries list.
  • Identify log entries that contain the word "ERROR".
  • Print each error log entry.
  • Print the total count of error entries.

Solution

Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 2. Chapitre 3
single

single

Demandez à l'IA

expand

Demandez à l'IA

ChatGPT

Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion

Suggested prompts:

Can you show me an example of the log entries list?

What should the script do if there are no error messages in the logs?

Can you explain how to handle different error formats in the log entries?

close

bookChallenge: Log Error Extractor

Glissez pour afficher le menu

In DevOps, being able to quickly identify errors in log files is essential for diagnosing issues and maintaining system reliability. Log files can be lengthy and filled with a variety of information, but your ability to extract and count error messages efficiently can save valuable troubleshooting time. In this challenge, you will write a Python script that processes a hardcoded list of log entries, extracts all lines containing the word ERROR, prints each error line, and counts the total number of errors found. This exercise simulates a simple log monitoring tool, a fundamental skill for any DevOps professional.

Tâche

Swipe to start coding

Implement a script that extracts and counts error messages from a list of log entries.

  • Iterate through each string in the log_entries list.
  • Identify log entries that contain the word "ERROR".
  • Print each error log entry.
  • Print the total count of error entries.

Solution

Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 2. Chapitre 3
single

single

some-alt