---
title: Insights CLI reference
description: Execute BadgerQL queries against your Honeybadger Insights data from the command line.
url: https://docs.honeybadger.io/resources/cli/insights/
---

The `insights` command lets you execute BadgerQL queries against your Honeybadger Insights data.

## Query Insights data

```shell
hb insights query --project-id 12345 --query "fields @ts, @preview | sort @ts"
```

### With timezone

```shell
hb insights query --project-id 12345 \
  --query "fields @ts, @preview | sort @ts" \
  --timezone "America/New_York"
```

### With timestamp filter

```shell
hb insights query --project-id 12345 \
  --query "fields @ts, @preview | sort @ts" \
  --ts "2024-01-15T00:00:00Z"
```

### Output as JSON

```shell
hb insights query --project-id 12345 \
  --query "fields @ts, @preview" \
  --output json
```

**Required flags:**

* `--project-id` — Project ID
* `-q, --query` — BadgerQL query to execute

**Optional flags:**

* `--ts` — Timestamp in RFC3339 format
* `--timezone` — Timezone for results (e.g., `America/New_York`)
* `-o, --output` — Output format: `table` or `json` (default: `table`)

## Example queries

### Recent errors

```shell
hb insights query --project-id 12345 \
  --query "filter @type = 'error' | fields @ts, error.class, error.message | sort @ts desc | limit 10"
```

### Count by error class

```shell
hb insights query --project-id 12345 \
  --query "filter @type = 'error' | stats count() by error.class"
```

### Host metrics

```shell
hb insights query --project-id 12345 \
  --query "filter @type = 'metric' | fields @ts, cpu.usage, memory.used | sort @ts desc"
```

See the [Insights documentation](https://docs.honeybadger.io/guides/insights/) and [BadgerQL reference](https://docs.honeybadger.io/guides/insights/badgerql/) for more query examples.

---

## Try Honeybadger for FREE

Intelligent logging, error tracking, and Just Enough APM™ in one dev-friendly platform. Find and fix problems before users notice.

[Start free trial](https://app.honeybadger.io/users/sign_up)

[See plans and pricing](https://www.honeybadger.io/plans/)
