Grafana Query

Grafana Query

Certified

Run instant LogQL query in Loki

Calls the /loki/api/v1/query endpoint at a single timestamp. Defaults to limit 100 and BACKWARD sort; time defaults to now.

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
namespace: company.team

tasks:
  - id: query
    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
namespace: company.team

tasks:
  - id: query
    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

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

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

Tenant ID

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

Evaluation time

Timestamp for the instant query in nanoseconds or RFC3339; rendered from flow context. Defaults to current time.

SubTypeobject

Query results

Entries include timestamp, labels, and either log line (streams) or value (vector/matrix)

Result type

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

Total number of log entries retrieved from Loki instant query