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)
authToken string
Authentication token
Bearer token for authentication if Loki is secured
connectTimeout integerstring
30Connection timeout
HTTP connection timeout in seconds
direction string
BACKWARDFORWARDBACKWARDDirection
Determines the sort order of logs. Use FORWARD for ascending order, or BACKWARD for descending order. Defaults to BACKWARD.
end string
End time
The end time for the query as a nanosecond Unix epoch or another supported format (e.g., RFC3339). Defaults to now.
interval string
Interval
Entries are returned at the specified interval. Only applies to log queries that return stream responses (e.g., '1m', '30s').
limit integerstring
100Limit
Maximum number of entries to return
readTimeout integerstring
60Read timeout
HTTP read timeout in seconds
since string
Since
Duration to calculate start time relative to end time (e.g., '1h', '30m'). Alternative to specifying absolute start time.
start string
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.
step string
Step
Query resolution step width in duration format (e.g., '1m', '30s') or seconds. Applies only to metric queries that return matrix responses.
tenantId string
Grafana Loki Tenant ID
X-Scope-OrgID header value for multi-tenant Loki setups
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