More in Setting up a platform

Log watcher

Turn errors in your logs into tickets the agent investigates, one ticket per distinct error, with a daily limit.

In the appPlatformSettingsLog watcher

The log watcher finds errors in your logs before anyone reports them. Every 5 minutes it reads this platform's new log lines from Loki and looks for errors: crashes, exceptions, stack traces, null-pointer errors. Each distinct error becomes one ticket, and the agent investigates it at once.

It never replies to anyone outside your team. The outcome is the agent's findings and, if you approve one, a fix.

The label at the top of the page says how it stands: Watching, Off, or Can't read the logs when the last check failed.

What you need first#

  • Loki connected. Loki is the store your logs are kept in. Connect it under Settings › Live system › Grafana Loki. See Loki logs. Until it is, the page shows Your logs are not connected.
  • The namespaces to watch. By default the watcher reads the namespaces listed in Namespaces it may look at, under Settings › Live system › Kubernetes. See Kubernetes access. If you don't use Kubernetes, write your own search instead (see Your own search, below).

Switch it on#

  1. 1

    Go to Settings › Log watcher.

  2. 2

    Under Watching, switch on Watching this platform's logs.

  3. 3

    Under Daily limit, set New errors per day.

  4. 4

    Choose what happens When an error goes quiet.

  5. 5

    Click Save at the bottom.

The first check runs within 5 minutes.

RowWhat it does
WatchingThe switch turns the watcher on or off. Off stops new tickets from the logs. Tickets already open stay as they are.
What to watchErrors and stack traces in this platform's namespaces, unless you write your own search. Click Use your own search (LogQL) to change it. See below.
Daily limitNew errors per day, from 1 to 500. The default is 20. It counts the errors the log watcher opened or reopened a ticket for in the past 24 hours. The agent's later work on those tickets, such as a fix or a follow-up after an approval, doesn't count. Errors past the limit still get a ticket, but it is held back until someone starts it.
When an error goes quietClose the ticket after a number of quiet days, or Leave it open until someone closes it. With Close the ticket, set Quiet days before it closes, from 1 to 365. The default is 7.
Ignore errors fromNames to ignore: pods or programs to skip, one name per line, with * for anything. It starts with *-probe-*, debug-*, tmp-*, test-* and adhoc-*: pods someone starts by hand to run a query or look around. A typo there is not a fault in your platform.

Only owners and admins can change these settings.

How it decides what is an error#

A line counts as an error when it:

  • is marked with the level error, fatal or critical, as level=error or as JSON "level": "error"
  • contains the word ERROR, FATAL or CRITICAL in capitals
  • starts a Python traceback (Traceback (most recent call last))
  • names an exception or error, such as ValueError: or NullPointerException
  • is a Go panic (panic:)

Lines that say they are INFO, DEBUG or TRACE are ignored, even if they mention an error. For example, a logged web request whose address contains the word "error".

Lines from the same pod within 3 seconds of each other count as one occurrence. That keeps a stack trace together as one error.

One ticket per error#

The watcher recognises the same error when it happens again, even if the time, IDs or numbers in the message differ. It matches on where the error came from (the container or app) and the error message.

What happensResult
A new error appearsA ticket titled Error in the logs: … opens, and the agent investigates it.
The same error appears againThe ticket's count goes up. No new ticket, no new investigation.
A closed ticket's error comes backThe ticket opens again and the agent looks at the new lines. This counts towards the daily limit.
An error stays away for your chosen number of daysIts ticket closes by itself.

The ticket shows the log lines, with secrets removed, and where they came from.

Held tickets#

When the daily limit is reached, new errors still get a ticket, but no investigation. The ticket is Not started, and its Now says Start the agent, with Held back: the log watcher's daily limit was reached. Click Start the agent on the ticket when you're ready, or start several at once from Tickets (status Not started).

Approving the results#

Log-watcher tickets have no requester. On a platform with no ticket system, approving the agent's reply only records your decision and marks the ticket done. Nothing is sent anywhere. The useful part is the agent's findings, and any fix it proposes. See Approving a fix.

By default the watcher searches this platform's namespaces for the error lines described above. Under What to watch, click Use your own search (LogQL). While the box is empty, What it searches now shows exactly what it searches.

To search something else, write your own search in Your own search (LogQL), up to 2,000 characters. LogQL is Loki's search language. Your search replaces the default completely, including the error filter. For example:

{namespace="shop-prod", app=~"api|worker"} |~ "(?i)error|exception|panic"

Leave it empty to go back to the default. Hide closes the box again while it is empty.

Your log collector must collect it

The watcher can only see what reaches Loki. If a namespace's logs aren't collected, it can't find errors there. Use Check connection under Settings › Live system › Grafana Loki to see the labels Loki has.

Last check#

The strip under the title shows when the watcher Last checked, and what it found then:

ShownMeaning
New errorsNew tickets that started an investigation.
Seen againRepeats added to open tickets.
Opened againClosed tickets whose error came back.
Over daily limitNew tickets held back, waiting for someone to start them.
Closed as quietTickets closed because their error stopped.

Before the first check, it says Not checked yet. The first check runs within 5 minutes.

If the last check failed, The last check failed shows under the strip with the reason. Common reasons are that Loki isn't connected yet, or that no namespaces are chosen to watch. If the reason is about Loki, the box links to Settings › Live system.