# Grafana Loki

> 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.

App · 7 actions. Web page: https://docs.lodol.com/docs/integrations/grafana-loki

## Actions

### 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 (`labels`, object): 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 (`contains`, text): Only lines containing this text, ignoring case, such as error or timeout.
- Line doesn't contain (`excludes`, text): Leave out lines containing this text, ignoring case, such as healthcheck.
- LogQL query (`query`, text): Instead of labels: a LogQL log query, such as {app="checkout"} |= "error" | json. Leave empty to use the labels.
- Time range (`since`, text): 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_by`, text): A label to count separately for each of its values, such as level or app. Leave empty for one total.
- At (`at_time`, date and time): The moment to count back from. Leave empty for now.

**Outputs**

- `count` (number): How many lines matched, in all
- `groups` (list): The count for each value of the label counted by, most first
- `query` (text): The LogQL query that ran
- `time` (text): The moment counted back from, in UTC (ISO 8601)
- `window` (text): How far back it counted, such as 1h

**Example output**

```json
{
  "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 (`label`, text, required): The label, such as app or host.
- Only on logs with (`labels`, object): Other labels the logs must have, such as env production. Leave empty for all logs.
- Seen in the last (`since`, text): 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 (`limit`, number): The most values to return. Defaults to 1000. From 1 to 5000.

**Outputs**

- `count` (number): How many values were returned
- `has_more` (true/false): True when it has more values than the limit
- `label` (text): The label
- `label_values` (list): Its values, in order

**Example output**

```json
{
  "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 (`since`, text): 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**

- `count` (number): How many labels there are
- `labels` (list): The label names, in order

**Example output**

```json
{
  "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 (`labels`, object): Labels the streams must have, such as app checkout. Leave empty when you give a selector.
- Selector (`query`, text): Instead of labels: a stream selector, such as {app=~"check.*"}.
- Seen in the last (`since`, text): 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 (`limit`, number): The most to return. Defaults to 100. From 1 to 5000.

**Outputs**

- `count` (number): How many streams were returned
- `has_more` (true/false): True when more streams match than the limit
- `selector` (text): The selector the streams match
- `streams` (list): The matching streams' labels

**Example output**

```json
{
  "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 (`query`, text, required): A LogQL metric query, such as sum by (app) (rate({env="production"} |= "error" [5m])).
- At (`at_time`, date and time): The moment to evaluate it at. Leave empty for now.

**Outputs**

- `count` (number): How many results there are
- `query` (text): The LogQL query that ran
- `results` (list): Each result with its labels and value
- `time` (text): The moment it was evaluated at, in UTC (ISO 8601)
- `truncated` (true/false): True when there were more than 1,000 results
- `value` (number): The first result's value; empty when there are none

**Example output**

```json
{
  "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 (`labels`, object): 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 (`contains`, text): Only lines containing this text, ignoring case, such as error or timeout.
- Line doesn't contain (`excludes`, text): Leave out lines containing this text, ignoring case, such as healthcheck.
- LogQL query (`query`, text): Instead of labels: a LogQL log query, such as {app="checkout"} |= "error" | json. Leave empty to use the labels.
- Time range (`since`, text): 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 (`start`, date and time): Instead of the time range: when to start. Leave empty to use the time range.
- To (`end`, date and time): When to stop. Leave empty for now.
- Limit (`limit`, number): The most lines to return. Defaults to 100, up to 5000. From 1 to 5000.
- Order (`direction`, text): Newest lines first (the default), or oldest first. One of: `backward` (Newest first), `forward` (Oldest first). Default: `backward`.

**Outputs**

- `count` (number): How many lines were returned
- `end` (text): Where it ended, in UTC (ISO 8601)
- `limit_reached` (true/false): True when the limit was reached, so there may be more
- `lines` (list): The matching lines, in the order asked for
- `query` (text): The LogQL query that ran
- `start` (text): Where the time range began, in UTC (ISO 8601)
- `text` (text): Every line as text, one a line with its time and labels, ready for an AI step or a message

**Example output**

```json
{
  "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 (`labels`, object, required): 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 (`lines`, text, required): The text to log, one line each, or a list from an earlier step (records are written as JSON).
- Time (`timestamp`, date and time): When it happened. Leave empty for now. Loki refuses times more than about an hour old or ahead.
- Details (`metadata`, object): Extra name and value pairs kept with each line without being labels, such as order_id or trace_id. Needs Loki 3.

**Outputs**

- `count` (number): How many lines were sent
- `first_time` (text): The first line's time, in UTC (ISO 8601)
- `first_timestamp` (text): The first line's time in nanoseconds
- `labels` (object): The labels the lines were filed under
- `last_time` (text): The last line's time, in UTC (ISO 8601)
- `last_timestamp` (text): The last line's time in nanoseconds
- `selector` (text): Those labels as a LogQL selector, such as {app="billing"}, to find the lines again

**Example output**

```json
{
  "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\"}"
}
```
