Grafana QueryRange

Grafana QueryRange

Certified

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.

yaml
type: io.kestra.plugin.grafana.loki.QueryRange

Query error logs from the last hour using relative time

yaml
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

yaml
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

yaml
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

LogQL query

Rendered LogQL expression sent to Loki (e.g., '{job="api"} |= "error"')

Loki base URL

HTTPS endpoint of the Loki API, including scheme (e.g., http://localhost: 3100 or https://logs.example.com)

Bearer token

Authorization header value for secured Loki deployments; render from secrets when possible

Default30

HTTP connect timeout

Connection timeout in seconds; defaults to 30

DefaultBACKWARD
Possible Values
FORWARDBACKWARD

Sort direction

Use FORWARD for ascending timestamps or BACKWARD for descending; defaults to BACKWARD

End time

Window end as nanosecond epoch or RFC3339; defaults to current time.

Interval

Sampling interval for stream responses (e.g., '1m'); ignored for matrix results.

Default100

Result limit

Maximum number of entries to return; defaults to 100

Reference (ref) of the pluginDefaults to apply to this task.

Default60

HTTP read timeout

Read timeout in seconds; defaults to 60

Since

Duration offset from end to compute start (e.g., '1h'); alternative to setting start explicitly.

Start time

Window start as nanosecond epoch or RFC3339; defaults to one hour before end time.

Step

Resolution step (duration like '1m' or seconds) for matrix/metric queries; ignored for stream results.

Tenant ID

X-Scope-OrgID header used by multi-tenant Loki clusters

SubTypeobject

List of log entries

Each entry contains timestamp, labels, and log line

Result type

Type of result returned by Loki (streams or matrix)

Total number of log entries retrieved from Loki range query