Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion logsight/enterprise.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ class AnomalyScore:
def score_event(event: EnrichedLog, recent: list[EnrichedLog]) -> AnomalyScore:
"""Combine frequency and structural signals into a deterministic score."""
template = event.template or extract_template(event.message)
same = sum(1 for item in recent if (item.template or extract_template(item.message)) == template)
same = sum(
1 for item in recent if (item.template or extract_template(item.message)) == template
)
error_rate = sum(item.level in {"ERROR", "CRITICAL"} for item in recent) / max(len(recent), 1)
rarity = 1.0 / (same + 1)
severity = 1.0 if event.level in {"ERROR", "CRITICAL"} else 0.0
Expand Down
4 changes: 3 additions & 1 deletion logsight/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ def insert_events(self, events: list[dict[str, Any]]) -> None:


class QdrantStore:
def __init__(self, base_url: str = "http://localhost:6333", collection: str = "logsight") -> None:
def __init__(
self, base_url: str = "http://localhost:6333", collection: str = "logsight"
) -> None:
self.base_url = base_url.rstrip("/")
self.collection = collection

Expand Down
8 changes: 7 additions & 1 deletion tests/test_enterprise.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
"""Tests for enterprise observability primitives."""

from logsight.enterprise import WebhookNotifier, enrich, extract_template, score_event, semantic_features
from logsight.enterprise import (
WebhookNotifier,
enrich,
extract_template,
score_event,
semantic_features,
)
from logsight.parser import parse_line


Expand Down
Loading