
Grafana QueryRange
CertifiedRun range LogQL query in Loki
Grafana QueryRange
Run range LogQL query in Loki
Calls the /loki/api/v1/query_range endpoint over a window. Start defaults to now-1h, end to now, limit to 100, direction BACKWARD. Step is required for matrix queries; interval applies to stream queries only.
type: io.kestra.plugin.grafana.loki.QueryRangeExamples
Query error logs from the last hour using relative time
id: query_loki_errors
namespace: company.team
tasks:
- id: fetch_errors
type: io.kestra.plugin.grafana.loki.QueryRange
url: http://localhost:3100
query: '{job="api"} |= "error"'
since: 1h
limit: 1000
Query with authentication and absolute time range
id: query_loki
namespace: company.team
tasks:
- id: fetch_logs
type: io.kestra.plugin.grafana.loki.QueryRange
url: https://loki.example.com
token: "{{ secret('LOKI_TOKEN') }}"
tenantId: team-a
query: '{namespace="production", container="frontend"}'
start: "2024-01-01T00:00:00Z"
end: "2024-01-01T23:59:59Z"
limit: 5000
direction: BACKWARD
Metric query with step interval
id: loki_test
namespace: company.team
tasks:
- id: query_metrics
type: io.kestra.plugin.grafana.loki.QueryRange
url: http://localhost:3100
query: 'rate({job="api"}[5m])'
start: "{{ now() | dateAdd(-6, 'HOURS') }}"
step: 1m
Properties
query *Requiredstring
LogQL query
Rendered LogQL expression sent to Loki (e.g., '{job="api"} |= "error"')
url *Requiredstring
Loki base URL
HTTPS endpoint of the Loki API, including scheme (e.g., http://localhost: 3100 or https://logs.example.com)
authToken string
Bearer token
Authorization header value for secured Loki deployments; render from secrets when possible
connectTimeout integerstring
30HTTP connect timeout
Connection timeout in seconds; defaults to 30
direction string
BACKWARDFORWARDBACKWARDSort direction
Use FORWARD for ascending timestamps or BACKWARD for descending; defaults to BACKWARD
end string
End time
Window end as nanosecond epoch or RFC3339; defaults to current time.
interval string
Interval
Sampling interval for stream responses (e.g., '1m'); ignored for matrix results.
limit integerstring
100Result limit
Maximum number of entries to return; defaults to 100
pluginDefaultsRef Non-dynamicstring
Reference (ref) of the pluginDefaults to apply to this task.
readTimeout integerstring
60HTTP read timeout
Read timeout in seconds; defaults to 60
since string
Since
Duration offset from end to compute start (e.g., '1h'); alternative to setting start explicitly.
start string
Start time
Window start as nanosecond epoch or RFC3339; defaults to one hour before end time.
step string
Step
Resolution step (duration like '1m' or seconds) for matrix/metric queries; ignored for stream results.
tenantId string
Tenant ID
X-Scope-OrgID header used by multi-tenant Loki clusters
Outputs
logs array
List of log entries
Each entry contains timestamp, labels, and log line
resultType string
Result type
Type of result returned by Loki (streams or matrix)
Metrics
Records counter
Total number of log entries retrieved from Loki range query