Query logs from Grafana Loki at a single point in time

Execute instant LogQL queries against Loki at a specific point in time. This endpoint is primarily used for metric-type LogQL queries and returns vector results.

yaml
type: "io.kestra.plugin.grafana.loki.Query"

Query current error rate

yaml
id: query_loki_instant
namespace: company.team

tasks:
  - id: fetch_error_rate
    type: io.kestra.plugin.grafana.loki.Query
    url: http://localhost:3100
    query: 'sum(rate({job="api"} |= "error" [5m]))'
    limit: 100

Query metrics at a specific time

yaml
id: query_historical_metrics
type: io.kestra.plugin.grafana.loki.Query
url: https://loki.example.com
token: "{{ secret('LOKI_TOKEN') }}"
tenantId: team-a
query: 'sum(rate({namespace="production"}[10m])) by (level)'
time: "2024-01-01T12:00:00Z"

Query with authentication

yaml
id: query_metrics
type: io.kestra.plugin.grafana.loki.Query
url: https://loki.example.com
token: "{{ secret('LOKI_TOKEN') }}"
query: 'count_over_time({environment="staging"}[1h])'
direction: FORWARD
Properties

LogQL query

The LogQL query to execute (e.g., '{job="api"} |= "error"')

Loki base URL

The base URL of your Loki instance (e.g., http://localhost: 3100 or https://logs.example.com)

Authentication token

Bearer token for authentication if Loki is secured

Default 30

Connection timeout

HTTP connection timeout in seconds

Default BACKWARD
Possible Values
FORWARDBACKWARD

Direction

Determines the sort order of logs. Use FORWARD for ascending order, or BACKWARD for descending order. Defaults to BACKWARD.

Default 100

Limit

Maximum number of entries to return

Default 60

Read timeout

HTTP read timeout in seconds

Grafana Loki Tenant ID

X-Scope-OrgID header value for multi-tenant Loki setups

Evaluation time

The evaluation time for the query as a nanosecond Unix epoch or another supported format (e.g., RFC3339). Defaults to now.

SubType object

List of query results

Each entry contains timestamp, labels, and either log line (for stream results) or value (for vector/matrix results)

Result type

Type of result returned by Loki (vector, streams, or matrix)

Total number of log entries retrieved from Loki instant query