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)

Assets this task consumes as inputs or produces as outputs, for lineage tracking and the asset graph (Enterprise Edition). A flow declaring this property on a task is rejected in the open-source edition.

Definitions
assetFailureBehaviorstring
Possible Values
IGNOREFAILWARN

Asset failure behavior

Behavior applied to the task state when a declared asset fails to render, emit, or be persisted (e.g. a lock conflict): FAIL escalates it to FAILED, WARN (default) warns it if it would otherwise succeed, IGNORE leaves the state untouched.

enableAutobooleanstring

Whether to auto-register assets referenced dynamically at runtime that are not statically declared in inputs or outputs.

inputsarray

The assets consumed as inputs.

id*string
Min length1
typestring
outputs

The assets produced as outputs.

id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*string
Min length1

Custom asset type

descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150

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

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