---
name: azion-query-function-console-logs
description: >-
  Read what a function wrote with console.log from the functionConsoleEvents dataset, in Azion Console and with a GraphQL query.
---

# Query function console logs

You can read the lines a function wrote with `console.log` from Azion Console or with a GraphQL query. [Real-Time Events](/en/documentation/platform/real-time-events/) keeps them in the Functions Console data source. The GraphQL API serves the same records as the `functionConsoleEvents` dataset, named `cellsConsoleEvents` before.

One request leaves several lines behind it rather than one record. The **ID** variable, which the GraphQL API names `id`, is the request identifier, and it groups every line of a single request. A result that holds five rows for one request is the expected shape.

Azion Runtime writes lines of its own alongside the ones your code writes. **Line Source** separates the two: `CONSOLE` marks a line written with `console.log`, and `RUNTIME` marks a line Azion Runtime produced, such as an exception.

---

## Prerequisites

- A function that has run at least once. Creating a function does not execute it, and a function that never runs writes no lines.
- Access to Azion Console, for the Console procedure.
- A personal token, for the GraphQL query. To create one, refer to [Personal Tokens](/en/documentation/fundamentals/personal-tokens/).

---

## Read the lines a function wrote

Both interfaces read the same records, and both bound the search by a period first. The names they take differ. **Filter by** takes the variable in lowercase with underscores, and the GraphQL API takes the camelCase field, so the variable **Function ID** reads `function_id` in one and `functionId` in the other.

The period a search can ask for and the rows one query returns are both bounded. For each bound, refer to [Limits](/en/documentation/platform/real-time-events/limits/).

**Console**

To read the lines from Azion Console:

1. **Open Real-Time Events**

   Access [Azion Console](https://console.azion.com) > **Products menu** > **Observe** > **Real-Time Events**.

2. **Select the data source**

   In **Data Sources**, select *Functions Console*.

3. **Set the period**

   In **Time Filter**, select a period that covers the run you want to read.

4. **Narrow the result to one function**

   In **Filter by**, enter the identifier of the function:

   ```text
   function_id='<your-function-id>'
   ```

5. **Select Refresh**

The table holds the lines that function wrote inside the period, one row per line.

**Filter by** reads SQL, so `key='value'` matches a value exactly. Select a row to open **More details**, which carries every variable of that record, including **Line**, the message itself. For every variable the data source carries, refer to [Data sources](/en/documentation/platform/real-time-events/data-sources/).

**API**

The GraphQL API serves the same lines as the `functionConsoleEvents` dataset. Send the query to `https://api.azion.com/v4/events/graphql` with an `Authorization: Token [TOKEN VALUE]` header. The same address serves the GraphiQL Playground in a browser, where the query runs without a request of your own. For the terminal path, refer to [GraphQL API first steps](/en/documentation/devtools/graphql/first-steps/).

This query returns 10 lines from a time range, the oldest first:

```graphql
query ConsoleLog {
  functionConsoleEvents(
    limit: 10,
    filter: {
      tsRange: {begin: "2026-09-21T11:30:00", end: "2026-09-21T13:00:00"}
    }
    orderBy: [ts_ASC]
  )
  {
    ts
    solutionId
    configurationId
    functionId
    id
    lineSource
    level
    line
  }
}
```

The response carries the matching lines as JSON:

```json
{
    "data": {
        "functionConsoleEvents": [
            {
                "ts": "2026-09-21T12:09:54Z",
                "solutionId": "1234567890",
                "configurationId": "1234567891",
                "functionId": "9483",
                "id": "fa498cd9-cbep-4382-8bbb-32b029fe7411",
                "lineSource": "RUNTIME",
                "level": "ERROR",
                "line": "TypeError: Object not found"
            },
            {
                "ts": "2026-09-21T12:09:54Z",
                "solutionId": "1234567890",
                "configurationId": "1234567891",
                "functionId": "9483",
                "id": "fa498cd9-cbep-4382-8bbb-32b029fe7411",
                "lineSource": "RUNTIME",
                "level": "ERROR",
                "line": "TypeError: Object not found"
            },
            {
                "ts": "2026-09-21T12:09:54Z",
                "solutionId": "1234567890",
                "configurationId": "1234567891",
                "functionId": "9483",
                "id": "fa498cd9-cbep-4382-8bbb-32b029fe7411",
                "lineSource": "RUNTIME",
                "level": "ERROR",
                "line": "    at async mainFetch (ext:cells_fetch/26_fetch.js:266:12)"
            }
        ]
    }
}
```

The three rows carry one `id`, because one request produced all of them. Each reads `RUNTIME` in `lineSource` and `ERROR` in `level`, so Azion Runtime wrote them. A line written with `console.log` reads `CONSOLE` and `LOG` in the same two fields.

`functionId` identifies the function, and `configurationId` identifies the workload the request arrived on. To return only the lines whose message matches a pattern, add `lineLike` to the filter. The `%` character stands for any sequence of characters, so `lineLike: "%TypeError%"` matches every line that contains `TypeError`. For every field the dataset carries, refer to [Real-Time Events GraphQL API fields](/en/documentation/devtools/graphql/gql-real-time-events-fields/#functionconsoleevents-previous-cellsconsoleevents-azion-runtime).

---

## Next steps

- [Read an event record](/en/documentation/guides/platform/observability/understand-logs.md): Open one record in Azion Console and read every variable the event wrote.
- [Filter events](/en/documentation/guides/platform/observability/add-filters-events.md): The full Filter by syntax, with the wildcards that widen a match.
- [Query HTTP request events](/en/documentation/guides/platform/observability/query-workload-events.md): Read the records of a request to a workload from the workloadEvents dataset.
- [Real-Time Events fields](/en/documentation/devtools/graphql/gql-real-time-events-fields.md): Every field functionConsoleEvents carries, and the fields of every other dataset.
