
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 *string
LogQL query
Rendered LogQL expression sent to Loki (e.g., '{job="api"} |= "error"')
url *string
Loki base URL
HTTPS endpoint of the Loki API, including scheme (e.g., http://localhost: 3100 or https://logs.example.com)
assets
Assets this task consumes as inputs or produces as outputs, for lineage tracking and the asset graph (Enterprise Edition). A flow declaring this property on a task is rejected in the open-source edition.
io.kestra.core.models.assets.AssetsDeclaration
IGNOREFAILWARNAsset failure behavior
Behavior applied to the task state when a declared asset fails to render, emit, or be persisted (e.g. a lock conflict): FAIL escalates it to FAILED, WARN (default) warns it if it would otherwise succeed, IGNORE leaves the state untouched.
Whether to auto-register assets referenced dynamically at runtime that are not statically declared in inputs or outputs.
The assets consumed as inputs.
io.kestra.core.models.assets.AssetIdentifier
1The assets produced as outputs.
io.kestra.plugin.ee.assets.Dataset
1150{}1150io.kestra.plugin.ee.assets.File
1150{}1150io.kestra.plugin.ee.assets.Table
1150{}1150io.kestra.plugin.ee.assets.VM
1150{}1150io.kestra.core.models.assets.External
1150{}1150io.kestra.core.models.assets.Custom
11501Custom asset type
{}1150authToken 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
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