Time format with time zone in Home Assistant parser

Aperta Adatta ai principianti
#1,998 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
backend

Direzione di ricerca

Inizia dal parser Home Assistant nell’hub ed esamina il suo pattern per i timestamp insieme alla riga di log di esempio nell’issue. Verifica come il parser gestisce i timestamp con secondi frazionari e un offset del fuso orario, quindi esegui la convalida o i test pertinenti del parser. Il lavoro è concluso quando la riga di log fornita viene analizzata correttamente con il suo timestamp e i formati già supportati continuano a funzionare.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Describe the bug
The home Assistant parser fails in my case because the log has the time zone in the tilestamp whereas the parser doesn't expect this.

To Reproduce
I don't have any non-default settings regarding log format. Home Assistant runs in a container, crowdsec on the host.

Expected behavior
I clearly want the logs to be parsed.

Screenshots

line: 2026-11-07 18:32:15.251+01:00 WARNING (MainThread) [homeassistant.components.http.ban] Login attempt or request with invalid authentication from ... (192.168.200.247). Requested URL: '/auth/login_flow/44165863569aa262be5d51e7f037cd58'. (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/157.0.0.0 Safari/537.36 Edg/157.0.0.0)
        ├ s00-raw
        |       ├ 🔴 crowdsecurity/syslog-logs
        |       └ 🟢 crowdsecurity/non-syslog (+5 ~8)
        |               └ update evt.ExpectMode : %!s(int=0) -> 1
        |               └ update evt.Stage :  -> s01-parse
        |               └ update evt.Line.Raw :  -> 2026-11-07 18:32:15.251+01:00 WARNING (MainThread) [homeassistant.components.http.ban] Login attempt or request with invalid authentication from ... (192.168.200.247). Requested URL: '/auth/login_flow/44165863569aa262be5d51e7f037cd58'. (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/157.0.0.0 Safari/537.36 Edg/157.0.0.0)
        |               └ update evt.Line.Src :  -> /home/.../home-assistant.log
        |               └ update evt.Line.Time : 0001-01-01 00:00:00 +0000 UTC -> 2026-11-07 17:38:00.991955445 +0000 UTC
        |               └ create evt.Line.Labels.type : home-assistant
        |               └ update evt.Line.Process : %!s(bool=false) -> true
        |               └ update evt.Line.Module :  -> file
        |               └ create evt.Parsed.message : 2026-11-07 18:32:15.251+01:00 WARNING (MainThread) [homeassistant.components.http.ban] Login attempt or request with invalid authentication from ... (192.168.200.247). Requested URL: '/auth/login_flow/44165863569aa262be5d51e7f037cd58'. (Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/157.0.0.0 Safari/537.36 Edg/157.0.0.0)
        |               └ create evt.Parsed.program : home-assistant
        |               └ update evt.Time : 0001-01-01 00:00:00 +0000 UTC -> 2026-11-07 17:38:00.992091047 +0000 UTC
        |               └ create evt.Meta.datasource_path : /home/.../home-assistant.log
        |               └ create evt.Meta.datasource_type : file
        ├ s01-parse
        |       ├ 🔴 crowdsecurity/appsec-logs
        |       ├ 🔴 LePresidente/authelia-logs
        |       ├ 🔴 crowdsecurity/caddy-logs
        |       ├ 🔴 crowdsecurity/home-assistant-logs
        |       ├ 🔴 gauth-fr/immich-logs
        |       ├ 🔴 LePresidente/jellyfin-logs
        |       ├ 🔴 LearningSpot/open-webui-logs
        |       ├ 🔴 crowdsecurity/sshd-logs
        |       └ 🔴 crowdsecurity/sshd-success-logs
        └-------- parser failure 🔴

Additional context
With the help of ChatGPT, I fixed the parser with this pattern:

pattern_syntax:
  TIMESTAMP: '%{YEAR}-%{MONTHNUM}-%{MONTHDAY} %{HOUR}:%{MINUTE}:%{SECOND}(?:\.%{INT})?(?:%{ISO8601_TIMEZONE})?'
Lingua principale
Python
Stelle
257
Fork
235
Merge medio
3g 20h
PR unite (30g)
27

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di crowdsecurity/hub

Tutte le issue di crowdsecurity/hub

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.