Loki Integration
Overview
Grafana Loki is a horizontally scalable, highly available, multi-tenant log aggregation system inspired by Prometheus. Unlike traditional log systems, Loki indexes only metadata (labels) rather than full log content, making it cost-efficient at scale. When alert rules defined in the Loki Ruler detect error conditions or anomalies in log streams, Loki routes those alerts through an external Alertmanager, which delivers a structured webhook payload to the platform.
This integration supports automatic alert creation on firing events and automatic resolution when Alertmanager sends a resolved notification.
Integration Flow
Loki continuously ingests log streams from applications and infrastructure.
The Loki Ruler evaluates LogQL alert rules against incoming log data at a configured interval.
When a rule condition is met, the Ruler sends the alert to an external Alertmanager.
Alertmanager groups the alerts and delivers a webhook POST request to the platform endpoint.
When the log condition clears, Alertmanager sends a
resolvednotification and the platform automatically closes the alert.
Webhook Payload Schema
The payload delivered to the platform follows the standard Prometheus Alertmanager webhook format (version 4).
{
"receiver": "string",
"status": "firing | resolved",
"alerts": [
{
"status": "firing | resolved",
"labels": {
"alertname": "string",
"severity": "string",
"env": "string"
},
"annotations": {
"summary": "string",
"description": "string"
},
"startsAt": "ISO8601 timestamp",
"endsAt": "ISO8601 timestamp",
"generatorURL": "string",
"fingerprint": "string"
}
],
"groupLabels": {},
"commonLabels": {
"alertname": "string",
"severity": "string"
},
"commonAnnotations": {
"summary": "string",
"description": "string"
},
"externalURL": "string",
"version": "4",
"groupKey": "string",
"truncatedAlerts": 0
}Setup
Step 1 — Create an Alert Source on the Platform
Navigate to Sources → Add Source.
Search for Loki and select it.
Give the source a name and click Save.
Copy the generated ITOC360 URL and Token.
Step 2 — Install and Configure Alertmanager
Loki does not include a built-in Alertmanager. You must run an external Prometheus Alertmanager and point Loki's Ruler at it.
Install Alertmanager using your preferred method (binary, Docker, Helm). Then configure it to forward alerts to the platform:
alertmanager.yml
send_resolved: trueis required for automatic alert resolution on the platform.
Step 3 — Configure the Loki Ruler
Point the Loki Ruler to your external Alertmanager in loki-config.yaml:
Step 4 — Create Alert Rules
Create rule files in the configured rules directory. Loki uses LogQL for alert expressions, allowing you to alert on log content, patterns, and rates.
Example: rules/production.yaml
The
severitylabel inlabelsis used by the platform for priority mapping (see table below).
Loki alert rules use LogQL syntax — log stream selectors (
{app="api"}) combined with filter expressions (|= "ERROR") and metric queries (rate,count_over_time).
Step 5 — Verify the Integration
After starting Loki and Alertmanager:
Check Alertmanager UI at
http://<alertmanager-host>:9093— active alerts should appear there first.Trigger a test rule and wait for the
group_waitperiod.Confirm the alert appears on the platform under the source you created.
Sample Payload
The following is a real payload captured during integration testing.
ALERT (firing):
RESOLVE (resolved):
Field Mapping Reference
status
Top-level event type: firing → ALERT, resolved → RESOLVE
alerts[0].fingerprint
Unique identifier per alert label set — used for fingerprint matching
alerts[0].labels.alertname
Name of the alert rule that fired
alerts[0].labels.severity
Severity label from the rule definition — used for priority mapping
alerts[0].annotations.summary
Short human-readable alert title
alerts[0].annotations.description
Detailed description of the alert condition
alerts[0].startsAt
ISO 8601 timestamp when the alert started firing
alerts[0].endsAt
ISO 8601 timestamp when resolved (0001-... means still active)
commonLabels
Labels shared across all alerts in this group
commonAnnotations
Annotations shared across all alerts in this group
groupKey
Alertmanager group key used for deduplication
Priority Mapping
The platform maps the severity label from the alert rule to an internal priority level.
Loki severity Label
Platform Priority
critical
CRITICAL
error
HIGH
warning
MEDIUM
info
LOW
(not set)
MEDIUM (default)
You control the
severitylabel in your alert rule definitions. Use consistent values across your rule files for predictable priority routing.
RESOLVE Detection
The platform automatically resolves an alert when Alertmanager sends a payload with "status": "resolved". This requires send_resolved: true in your Alertmanager webhook configuration (set in Step 2).
The resolved event is matched to the original alert using the fingerprint field, which Alertmanager generates deterministically from the alert's label set. As long as the labels do not change between firing and resolution, the fingerprint will match and the alert will be closed.
Last updated
Was this helpful?

