Skip to content

Commit

Permalink
Fix groupping in Rule histogram query and migaration deps
Browse files Browse the repository at this point in the history
  • Loading branch information
VladimirFilonov committed Nov 24, 2024
1 parent 6eae448 commit 70c67fa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions keep/api/core/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -1804,7 +1804,7 @@ def get_rule_distribution(tenant_id, minute=False):
session.query(
Rule.id.label("rule_id"),
Rule.name.label("rule_name"),
Incident.id.label("group_id"),
Incident.id.label("incident_id"),
Incident.rule_fingerprint.label("rule_fingerprint"),
timestamp_format.label("time"),
func.count(LastAlertToIncident.fingerprint).label("hits"),
Expand All @@ -1817,7 +1817,7 @@ def get_rule_distribution(tenant_id, minute=False):
)
.filter(Rule.tenant_id == tenant_id) # Filter by tenant_id
.group_by(
"rule_id", "rule_name", "incident_id", "rule_fingerprint", "time"
Rule.id, "rule_name", Incident.id, "rule_fingerprint", "time"
) # Adjusted here
.order_by("time")
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

# revision identifiers, used by Alembic.
revision = "bdae8684d0b4"
down_revision = "620b6c048091"
down_revision = "192157fd5788"
branch_labels = None
depends_on = None

Expand All @@ -31,7 +31,7 @@ def populate_db():
from alert
join (
select
alert.fingerprint, max(alert.timestamp) as last_received
alert.tenant_id, alert.fingerprint, max(alert.timestamp) as last_received
from alert
group by fingerprint, tenant_id
) as a ON alert.fingerprint = a.fingerprint and alert.timestamp = a.last_received and alert.tenant_id = a.tenant_id
Expand Down

0 comments on commit 70c67fa

Please sign in to comment.