# Error saving alert annotation batch

**URL:** <https://community.grafana.com/t/error-saving-alert-annotation-batch/162761>\
**Category:** Grafana\
**Tags:** alerting\
**Created:** [May 4, 2026, 3:32pm UTC](https://community.grafana.com/t/error-saving-alert-annotation-batch/162761 "2026-05-04T15:32:20Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![scootertramp](https://avatars.discourse-cdn.com/v4/letter/s/3bc359/32.png) [@scootertramp](https://community.grafana.com/u/scootertramp)\
**Post date:** [May 4, 2026, 3:32pm UTC](https://community.grafana.com/t/error-saving-alert-annotation-batch/162761/1 "2026-05-04T15:32:20Z")

</div>

Grafana version : Grafana v13.0.1 (a100054f)

Noticed this error of late.

\<30\>1 2026-05-04T10:59:40.20063-04:00 raspberry05 grafana 247674 - - logger=ngalert.state.historian backend=annotations rule\_uid=cf50q8nv3ooaoe org\_id=1 t=2026-05-04T10:59:40.200174121-04:00 level=error msg=“Failed to save history batch” samples=6 err=“error saving alert annotation batch: SQL logic error: too many SQL variables (1)”

Is there something I can do to eliminate this from happening?

---

<div class="post-metadata">

**Author:** ![scootertramp](https://avatars.discourse-cdn.com/v4/letter/s/3bc359/32.png) [@scootertramp](https://community.grafana.com/u/scootertramp)\
**Post date:** [May 4, 2026, 3:50pm UTC](https://community.grafana.com/t/error-saving-alert-annotation-batch/162761/2 "2026-05-04T15:50:57Z")

</div>

Just going back three hours I see it has happen 10 times.

---

<div class="post-metadata">

**Author:** ![infofcc3](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/infofcc3/32/51248_2.png) [@infofcc3](https://community.grafana.com/u/infofcc3)\
**Post date:** [May 5, 2026, 7:12am UTC](https://community.grafana.com/t/error-saving-alert-annotation-batch/162761/3 "2026-05-05T07:12:58Z")

</div>

hellow @scootertramp what is your evaluation interval , increased it.  
Reduce labels in alerts  
or  
Move Grafana DB to: Postgresql if needed

---

<div class="post-metadata">

**Author:** ![scootertramp](https://avatars.discourse-cdn.com/v4/letter/s/3bc359/32.png) [@scootertramp](https://community.grafana.com/u/scootertramp)\
**Post date:** [May 5, 2026, 12:28pm UTC](https://community.grafana.com/t/error-saving-alert-annotation-batch/162761/4 "2026-05-05T12:28:42Z")

</div>

Evaluation was 30 seconds with a pending period of 30 seconds.

I changed it to 10 seconds with a pending period of 20 seconds.

What would moving to Postgres solve? The current Grafana db is rather small at 260M.

The update frequency isn’t all that high since this is a Home Lab monitoring set-up.

---

<div class="post-metadata">

**Author:** ![scootertramp](https://avatars.discourse-cdn.com/v4/letter/s/3bc359/32.png) [@scootertramp](https://community.grafana.com/u/scootertramp)\
**Post date:** [May 5, 2026, 1:38pm UTC](https://community.grafana.com/t/error-saving-alert-annotation-batch/162761/5 "2026-05-05T13:38:59Z")

</div>

Here are six messages that meet the alert settings. These are pretty consistent as they happen every hour. Also attached is my alert definition

[Rsyslog.json](https://community.grafana.com/uploads/short-url/uKkhLE8UPuQVh0QwuTe6ClEjQkg.json) (1.2 KB)

.

warn \<4\>1 2026-05-05T08:58:51.961732-04:00 xt8-down kernel - - [meta sequenceId=“3240”] replay\_ctr:

warn \<4\>1 2026-05-05T08:58:51.961732-04:00 xt8-down kernel - - [meta sequenceId=“3241”] 0000: 00 00 00 00 00 00 00 4b

warn \<4\>1 2026-05-05T08:58:51.955346-04:00 xt8-down kernel - - [meta sequenceId=“3238”] kek:

warn \<4\>1 2026-05-05T08:58:51.955346-04:00 xt8-down kernel - - [meta sequenceId=“3239”] 0000: 3e b4 44 6b 2f 04 0a 09 c9 8a f5 b7 50 aa 34 e8

warn \<4\>1 2026-05-05T08:58:51.954313-04:00 xt8-down kernel - - [meta sequenceId=“3236”] kck:

warn \<4\>1 2026-05-05T08:58:51.954313-04:00 xt8-down kernel - - [meta sequenceId=“3237”] 0000: a0 a5 1b 2d 55 5c 00 15 ee dd 8e 6a de 94 ef c7

---

<div class="post-metadata">

**Author:** ![scootertramp](https://avatars.discourse-cdn.com/v4/letter/s/3bc359/32.png) [@scootertramp](https://community.grafana.com/u/scootertramp)\
**Post date:** [May 6, 2026, 12:00pm UTC](https://community.grafana.com/t/error-saving-alert-annotation-batch/162761/6 "2026-05-06T12:00:02Z")

</div>

Changing interval had no effect. I tried ungrouping alert emails since the samples size seemed to match the number of warning alerts. Did not resolve error.

---

<div class="post-metadata">

**Author:** ![scootertramp](https://avatars.discourse-cdn.com/v4/letter/s/3bc359/32.png) [@scootertramp](https://community.grafana.com/u/scootertramp)\
**Post date:** [May 7, 2026, 6:48pm UTC](https://community.grafana.com/t/error-saving-alert-annotation-batch/162761/7 "2026-05-07T18:48:40Z")

</div>

Just more background information. It appears this started on May 2nd.

Grafana was last upgraded on Apr 18th.

dpkg.log.1:2026-04-18 06:48:19 status unpacked grafana:arm64 13.0.1  
dpkg.log.1:2026-04-18 06:48:19 status half-configured grafana:arm64 13.0.1  
dpkg.log.1:2026-04-18 06:48:20 status installed grafana:arm64 13.0.1

 ![Screenshot 2026-05-07 142857](https://us1.discourse-cdn.com/grafana/original/3X/3/d/3de1450e7acd60e197c6f70fb621de76ff452c1e.png)

 ![Screenshot 2026-05-07 142942](https://us1.discourse-cdn.com/grafana/original/3X/d/d/dd36d24c139716014b58dffb0148e4eed65efd4a.png)

---

<div class="post-metadata">

**Author:** ![scootertramp](https://avatars.discourse-cdn.com/v4/letter/s/3bc359/32.png) [@scootertramp](https://community.grafana.com/u/scootertramp)\
**Post date:** [May 13, 2026, 5:00pm UTC](https://community.grafana.com/t/error-saving-alert-annotation-batch/162761/8 "2026-05-13T17:00:47Z")

</div>

Since i am using the default Grafana Contact point with the Grafana default Notification Policy and Grafana Built-in Templates. Can anybody provide any insights in to why I am getting this error for every alert that fires.

error saving alert annotation batch: SQL logic error: too many SQL variables

This looks like a Grafana bug.

---

<div class="post-metadata">

**Author:** ![scootertramp](https://avatars.discourse-cdn.com/v4/letter/s/3bc359/32.png) [@scootertramp](https://community.grafana.com/u/scootertramp)\
**Post date:** [June 4, 2026, 10:57am UTC](https://community.grafana.com/t/error-saving-alert-annotation-batch/162761/9 "2026-06-04T10:57:48Z")

</div>

No change in behavior after upgrading Grafana to 13.0.2.

 ![Screenshot 2026-06-04 065655](https://us1.discourse-cdn.com/grafana/original/3X/f/9/f9f7612d56cf8b04b0c0f69a43176ca620f624d8.png)

\<30\>1 2026-06-04T06:50:10.261409-04:00 raspberry05 grafana 8217 - - logger=ngalert.state.historian backend=annotations rule\_uid=cf50q8nv3ooaoe org\_id=1 t=2026-06-04T06:50:10.261053441-04:00 level=error msg=“Failed to save history batch” samples=1 err=“error saving alert annotation batch: SQL logic error: too many SQL variables (1)”

---

<div class="post-metadata">

**Author:** ![scootertramp](https://avatars.discourse-cdn.com/v4/letter/s/3bc359/32.png) [@scootertramp](https://community.grafana.com/u/scootertramp)\
**Post date:** [June 23, 2026, 2:35pm UTC](https://community.grafana.com/t/error-saving-alert-annotation-batch/162761/10 "2026-06-23T14:35:03Z")

</div>

No change in behavior after upgrading Grafana to 13.1.0

 ![Screenshot 2026-06-23 100236](https://us1.discourse-cdn.com/grafana/original/3X/3/0/303c4bce40c5c0d0d679c47852c6397ba4e2bab4.png)

\<30\>1 2026-06-23T10:31:10.241667-04:00 raspberry05 grafana 42357 - - logger=ngalert.state.historian backend=annotations rule\_uid=cf50q8nv3ooaoe org\_id=1 t=2026-06-23T10:31:10.241336634-04:00 level=error msg=“Failed to save history batch” samples=1 err=“error saving alert annotation batch: SQL logic error: too many SQL variables (1)”

---

<div class="post-metadata">

**Author:** ![infofcc3](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/infofcc3/32/51248_2.png) [@infofcc3](https://community.grafana.com/u/infofcc3)\
**Post date:** [June 24, 2026, 10:31am UTC](https://community.grafana.com/t/error-saving-alert-annotation-batch/162761/11 "2026-06-24T10:31:13Z")

</div>

This is a Grafana bug → the default `annotations` historian generates a batch SQL insert that exceeds SQLite’s variable limit. Upgrading Grafana will not fix it.

**Edit `/etc/grafana/grafana.ini`:**

If you have Loki:

ini

```auto
[unified_alerting.state_history]
enabled = true
backend = loki
loki_remote_url = http://localhost:3100

```

If you have Prometheus:

ini

```auto
[unified_alerting.state_history]
enabled = true
backend = prometheus
prometheus_target_datasource_uid = <UID found at Connections → Data Sources → your Prometheus → copy UID from URL>

```

If you have neither, migrate Grafana’s database to PostgreSQL or MySQL → both handle this correctly without SQLite’s variable limit.

**Restart:**

bash

```auto
sudo systemctl restart grafana-server

```

**Confirm it:**

bash

```auto
sudo journalctl -fu grafana-server | grep historian

```

No `Failed to save history batch` = fixed.

Please also file a bug at [Sign in to GitHub · GitHub](https://github.com/grafana/grafana/issues/new/choose)

---

<div class="post-metadata">

**Author:** ![scootertramp](https://avatars.discourse-cdn.com/v4/letter/s/3bc359/32.png) [@scootertramp](https://community.grafana.com/u/scootertramp)\
**Post date:** [June 24, 2026, 1:24pm UTC](https://community.grafana.com/t/error-saving-alert-annotation-batch/162761/12 "2026-06-24T13:24:47Z")

</div>

Thank You.

I added to settings for loki and no more errors. I also run prometheus but have not added the settings for it as yet.

---

<div class="post-metadata">

**Author:** ![scootertramp](https://avatars.discourse-cdn.com/v4/letter/s/3bc359/32.png) [@scootertramp](https://community.grafana.com/u/scootertramp)\
**Post date:** [August 8, 2026, 2:50pm UTC](https://community.grafana.com/t/error-saving-alert-annotation-batch/162761/13 "2026-08-08T14:50:35Z")

</div>

Unfortunately moving the alert annotations out of Grafana sqllite to Loki just moved what error  
I am seeing.

[https://community.grafana.com/t/loki-errors-when-viewing-some-alert-rules-history/163864](https://community.grafana.com/t/loki-errors-when-viewing-some-alert-rules-history/163864)
