
QueryRange
Query logs from Grafana Loki within a time range
Execute LogQL queries against Loki over a specified time range. Supports both log queries (returning stream responses) and metric queries (returning matrix responses).
type: "io.kestra.plugin.grafana.loki.QueryRange"Examples
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
The LogQL query to execute (e.g., '{job="api"} |= "error"')
url*Requiredstring
Loki base URL
The base URL of your Loki instance (e.g., http://localhost: 3100 or https://logs.example.com)
authTokenstring
Authentication token
Bearer token for authentication if Loki is secured
connectTimeoutintegerstring
30Connection timeout
HTTP connection timeout in seconds
directionstring
BACKWARDFORWARDBACKWARDDirection
Determines the sort order of logs. Use FORWARD for ascending order, or BACKWARD for descending order. Defaults to BACKWARD.
endstring
End time
The end time for the query as a nanosecond Unix epoch or another supported format (e.g., RFC3339). Defaults to now.
intervalstring
Interval
Entries are returned at the specified interval. Only applies to log queries that return stream responses (e.g., '1m', '30s').
limitintegerstring
100Limit
Maximum number of entries to return
readTimeoutintegerstring
60Read timeout
HTTP read timeout in seconds
sincestring
Since
Duration to calculate start time relative to end time (e.g., '1h', '30m'). Alternative to specifying absolute start time.
startstring
Start time
The start time for the query as a nanosecond Unix epoch or another supported format (e.g., RFC3339). Defaults to one hour ago.
stepstring
Step
Query resolution step width in duration format (e.g., '1m', '30s') or seconds. Applies only to metric queries that return matrix responses.
tenantIdstring
Grafana Loki Tenant ID
X-Scope-OrgID header value for multi-tenant Loki setups
Outputs
logsarray
List of log entries
Each entry contains timestamp, labels, and log line
resultTypestring
Result type
Type of result returned by Loki (streams or matrix)
Metrics
Recordscounter
Total number of log entries retrieved from Loki range query