Grafana Loki
App · 7 actions
Search your Grafana Loki logs without writing LogQL, count matching lines, run LogQL metric queries and send log lines from workflows. Start a workflow for each new matching line, or when a count of lines crosses a threshold.
Actions
| Action | What it does |
|---|---|
| Count log lines | Count the log lines that match in the last few minutes or hours, such as errors from checkout in the last 15 minutes, in all or for each value of a label, to compare with a threshold. |
| List label values | List the values a label takes, such as every app or host sending logs, optionally only on logs with some other labels. |
| List labels | List the labels Loki's logs are filed under, such as app, env and level. |
| List streams | List the log streams (each set of labels, such as one app on one server) that match, and so which are sending logs. |
| Run metric query | Run a LogQL metric query, such as an error rate or bytes logged per app, and get its numbers. |
| Search logs | Find the log lines from some apps or servers that contain a word, in the last few minutes or hours or between two times, newest first. |
| Send log lines | Send one or several log lines to Loki under labels you choose, such as an audit trail of what a workflow did. |
Count log lines
Count the log lines that match in the last few minutes or hours, such as errors from checkout in the last 15 minutes, in all or for each value of a label, to compare with a threshold.
Inputs
- Labels
labelsobject - Which logs: labels and the value each must have, such as app checkout and env production. Leave empty when you give a LogQL query.
- Line contains
containstext - Only lines containing this text, ignoring case, such as error or timeout.
- Line doesn't contain
excludestext - Leave out lines containing this text, ignoring case, such as healthcheck.
- LogQL query
querytext - Instead of labels: a LogQL log query, such as {app="checkout"} |= "error" | json. Leave empty to use the labels.
- Time range
sincetext - How far back to look. Defaults to the last hour. A length of time such as 30m or 2d works too, up to 30 days.One of:
5m(Last 5 minutes),15m(Last 15 minutes),1h(Last hour),6h(Last 6 hours),24h(Last 24 hours),7d(Last 7 days). Default:1h. - Count for each
group_bytext - A label to count separately for each of its values, such as level or app. Leave empty for one total.
- At
at_timedate and time - The moment to count back from. Leave empty for now.
Outputs
countnumber- How many lines matched, in all
groupslist- The count for each value of the label counted by, most first
querytext- The LogQL query that ran
timetext- The moment counted back from, in UTC (ISO 8601)
windowtext- How far back it counted, such as 1h
Example output
{
"count": 151,
"groups": [
{
"count": 97,
"group": "info",
"labels": {
"level": "info"
}
},
{
"count": 54,
"group": "error",
"labels": {
"level": "error"
}
}
],
"query": "sum by (level)(count_over_time({app=\"checkout\"} [1h]))",
"time": "2026-11-09T14:30:00Z",
"window": "1h"
}List label values
List the values a label takes, such as every app or host sending logs, optionally only on logs with some other labels.
Inputs
- Label
labeltextRequired - The label, such as app or host.
- Only on logs with
labelsobject - Other labels the logs must have, such as env production. Leave empty for all logs.
- Seen in the last
sincetext - Only values on logs from this far back. Defaults to the last hour.One of:
5m(Last 5 minutes),15m(Last 15 minutes),1h(Last hour),6h(Last 6 hours),24h(Last 24 hours),7d(Last 7 days). Default:1h. - Limit
limitnumber - The most values to return. Defaults to 1000.From 1 to 5000.
Outputs
countnumber- How many values were returned
has_moretrue/false- True when it has more values than the limit
labeltext- The label
label_valueslist- Its values, in order
Example output
{
"count": 3,
"has_more": false,
"label": "app",
"label_values": [
"api",
"checkout",
"worker"
]
}List labels
List the labels Loki's logs are filed under, such as app, env and level.
Inputs
- Seen in the last
sincetext - Only labels on logs from this far back. Defaults to the last hour.One of:
5m(Last 5 minutes),15m(Last 15 minutes),1h(Last hour),6h(Last 6 hours),24h(Last 24 hours),7d(Last 7 days). Default:1h.
Outputs
countnumber- How many labels there are
labelslist- The label names, in order
Example output
{
"count": 4,
"labels": [
"app",
"env",
"host",
"level"
]
}List streams
List the log streams (each set of labels, such as one app on one server) that match, and so which are sending logs.
Inputs
- Labels
labelsobject - Labels the streams must have, such as app checkout. Leave empty when you give a selector.
- Selector
querytext - Instead of labels: a stream selector, such as {app=~"check.*"}.
- Seen in the last
sincetext - Only streams with logs from this far back. Defaults to the last hour.One of:
5m(Last 5 minutes),15m(Last 15 minutes),1h(Last hour),6h(Last 6 hours),24h(Last 24 hours),7d(Last 7 days). Default:1h. - Limit
limitnumber - The most to return. Defaults to 100.From 1 to 5000.
Outputs
countnumber- How many streams were returned
has_moretrue/false- True when more streams match than the limit
selectortext- The selector the streams match
streamslist- The matching streams' labels
Example output
{
"count": 1,
"has_more": false,
"selector": "{app=\"checkout\"}",
"streams": [
{
"app": "checkout",
"env": "production",
"level": "error"
}
]
}Run metric query
Run a LogQL metric query, such as an error rate or bytes logged per app, and get its numbers. 'value' holds the first result's number.
Inputs
- Metric query
querytextRequired - A LogQL metric query, such as sum by (app) (rate({env="production"} |= "error" [5m])).
- At
at_timedate and time - The moment to evaluate it at. Leave empty for now.
Outputs
countnumber- How many results there are
querytext- The LogQL query that ran
resultslist- Each result with its labels and value
timetext- The moment it was evaluated at, in UTC (ISO 8601)
truncatedtrue/false- True when there were more than 1,000 results
valuenumber- The first result's value; empty when there are none
Example output
{
"count": 1,
"query": "sum by (app)(rate({env=\"production\"} |= \"error\" [5m]))",
"results": [
{
"labels": {
"app": "checkout"
},
"raw_value": "0.42",
"value": 0.42
}
],
"time": "2026-11-09T14:30:00Z",
"truncated": false,
"value": 0.42
}Search logs
Find the log lines from some apps or servers that contain a word, in the last few minutes or hours or between two times, newest first. Get each line with its time and labels, and all of them as text for an AI step or a message.
Inputs
- Labels
labelsobject - Which logs: labels and the value each must have, such as app checkout and env production. Leave empty when you give a LogQL query.
- Line contains
containstext - Only lines containing this text, ignoring case, such as error or timeout.
- Line doesn't contain
excludestext - Leave out lines containing this text, ignoring case, such as healthcheck.
- LogQL query
querytext - Instead of labels: a LogQL log query, such as {app="checkout"} |= "error" | json. Leave empty to use the labels.
- Time range
sincetext - How far back to look. Defaults to the last hour. A length of time such as 30m or 2d works too, up to 30 days.One of:
5m(Last 5 minutes),15m(Last 15 minutes),1h(Last hour),6h(Last 6 hours),24h(Last 24 hours),7d(Last 7 days). Default:1h. - From
startdate and time - Instead of the time range: when to start. Leave empty to use the time range.
- To
enddate and time - When to stop. Leave empty for now.
- Limit
limitnumber - The most lines to return. Defaults to 100, up to 5000.From 1 to 5000.
- Order
directiontext - Newest lines first (the default), or oldest first.One of:
backward(Newest first),forward(Oldest first). Default:backward.
Outputs
countnumber- How many lines were returned
endtext- Where it ended, in UTC (ISO 8601)
limit_reachedtrue/false- True when the limit was reached, so there may be more
lineslist- The matching lines, in the order asked for
querytext- The LogQL query that ran
starttext- Where the time range began, in UTC (ISO 8601)
texttext- Every line as text, one a line with its time and labels, ready for an AI step or a message
Example output
{
"count": 1,
"end": "2026-11-09T14:30:00Z",
"limit_reached": false,
"lines": [
{
"labels": {
"app": "checkout",
"env": "production",
"level": "error"
},
"line": "level=error payment declined for order 48213: card expired",
"time": "2026-11-09T14:21:07.418532907Z",
"timestamp": "1794234067418532907"
}
],
"query": "{app=\"checkout\"} |~ \"(?i)declined\"",
"start": "2026-11-09T13:30:00Z",
"text": "2026-11-09T14:21:07.418532907Z [app=checkout, env=production, level=error] level=error payment declined for order 48213: card expired"
}Send log lines
Send one or several log lines to Loki under labels you choose, such as an audit trail of what a workflow did. Each line keeps its order.
Inputs
- Labels
labelsobjectRequired - The labels to file the lines under, such as app billing-workflow and env production. Keep them to a few values that repeat; put ids and details in the line.
- Log lines
linestextRequired - The text to log, one line each, or a list from an earlier step (records are written as JSON).
- Time
timestampdate and time - When it happened. Leave empty for now. Loki refuses times more than about an hour old or ahead.
- Details
metadataobject - Extra name and value pairs kept with each line without being labels, such as order_id or trace_id. Needs Loki 3.
Outputs
countnumber- How many lines were sent
first_timetext- The first line's time, in UTC (ISO 8601)
first_timestamptext- The first line's time in nanoseconds
labelsobject- The labels the lines were filed under
last_timetext- The last line's time, in UTC (ISO 8601)
last_timestamptext- The last line's time in nanoseconds
selectortext- Those labels as a LogQL selector, such as {app="billing"}, to find the lines again
Example output
{
"count": 2,
"first_time": "2026-11-09T14:30:00Z",
"first_timestamp": "1794234600000000000",
"labels": {
"app": "billing-workflow",
"env": "production"
},
"last_time": "2026-11-09T14:30:00.000000001Z",
"last_timestamp": "1794234600000000001",
"selector": "{app=\"billing-workflow\", env=\"production\"}"
}