# Alloy DaemonSet & Log Position File / State Persistence

**URL:** <https://community.grafana.com/t/alloy-daemonset-log-position-file-state-persistence/157545>\
**Category:** Grafana Alloy\
**Tags:** alloy\
**Created:** [September 16, 2025, 8:23pm UTC](https://community.grafana.com/t/alloy-daemonset-log-position-file-state-persistence/157545 "2025-09-16T20:23:31Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![sumith](https://avatars.discourse-cdn.com/v4/letter/s/e274bd/32.png) [@sumith](https://community.grafana.com/u/sumith)\
**Post date:** [September 16, 2025, 8:23pm UTC](https://community.grafana.com/t/alloy-daemonset-log-position-file-state-persistence/157545/1 "2025-09-16T20:23:31Z")

</div>

Hi all,

I’m setting up **Grafana Alloy as a DaemonSet** to collect pod logs from each node. I understand that Alloy keeps a **position file or state file** to track which log lines it has already read.

My question:

- If an Alloy pod restarts on a node, will it **re-read logs from the beginning** , or does it persist the position somewhere?
- What’s the recommended approach to **avoid duplicate log ingestion** in this scenario?
  - Should I mount a **hostPath volume** for Alloy’s storagePath?
  - Or is there a built-in way for Alloy to persist state per node?

I want to make sure we **don’t duplicate log lines** while still using DaemonSet mode for full node coverage.

---

<div class="post-metadata">

**Author:** ![tonyswumac](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/tonyswumac/32/22401_2.png) [@tonyswumac](https://community.grafana.com/u/tonyswumac)\
**Post date:** [September 16, 2025, 9:13pm UTC](https://community.grafana.com/t/alloy-daemonset-log-position-file-state-persistence/157545/2 "2025-09-16T21:13:43Z")

</div>

> [@sumith](#):
>
> - Should I mount a **hostPath volume** for Alloy’s storagePath?

You should do this.

---

<div class="post-metadata">

**Author:** ![sumith](https://avatars.discourse-cdn.com/v4/letter/s/e274bd/32.png) [@sumith](https://community.grafana.com/u/sumith)\
**Post date:** [September 16, 2025, 9:33pm UTC](https://community.grafana.com/t/alloy-daemonset-log-position-file-state-persistence/157545/3 "2025-09-16T21:33:06Z")

</div>

For persisting Alloy’s position/state file in DaemonSet mode, is this the correct way to configure it in the Alloy operator values file?

```auto
alloy:
  storagePath: /var/lib/alloy/data
  mounts:
    extra:
      - name: data-vol
        mountPath: /var/lib/alloy/data

```

And then define the volume:

```auto
controller:
  volumes:
    extra:
      - name: data-vol
        hostPath:
          path: /var/lib/alloy/data
          type: DirectoryOrCreate

```

I want to confirm that this ensures Alloy keeps its state across pod restarts without duplicating logs.

---

<div class="post-metadata">

**Author:** ![tonyswumac](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/tonyswumac/32/22401_2.png) [@tonyswumac](https://community.grafana.com/u/tonyswumac)\
**Post date:** [September 16, 2025, 9:46pm UTC](https://community.grafana.com/t/alloy-daemonset-log-position-file-state-persistence/157545/4 "2025-09-16T21:46:29Z")

</div>

Yes, that looks correct. You’ll want to test it a bit, of course.

---

<div class="post-metadata">

**Author:** ![sumith](https://avatars.discourse-cdn.com/v4/letter/s/e274bd/32.png) [@sumith](https://community.grafana.com/u/sumith)\
**Post date:** [September 16, 2025, 10:55pm UTC](https://community.grafana.com/t/alloy-daemonset-log-position-file-state-persistence/157545/5 "2025-09-16T22:55:59Z")

</div>

Error: failed to create the remotecfg service: mkdir /var/lib/alloy/data/remotecfg: permission denied

---

<div class="post-metadata">

**Author:** ![tonyswumac](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/tonyswumac/32/22401_2.png) [@tonyswumac](https://community.grafana.com/u/tonyswumac)\
**Post date:** [September 17, 2025, 11:23pm UTC](https://community.grafana.com/t/alloy-daemonset-log-position-file-state-persistence/157545/6 "2025-09-17T23:23:24Z")

</div>

Make sure you mount the directory with RW, and that it’s writable to all on the host if you aren’t running alloy in privileged mode.

---

<div class="post-metadata">

**Author:** ![sumith](https://avatars.discourse-cdn.com/v4/letter/s/e274bd/32.png) [@sumith](https://community.grafana.com/u/sumith)\
**Post date:** [September 17, 2025, 11:28pm UTC](https://community.grafana.com/t/alloy-daemonset-log-position-file-state-persistence/157545/7 "2025-09-17T23:28:06Z")

</div>

```
  securityContext:
    runAsUser: 0
    runAsGroup: 0
    fsGroup: 0

```

---

<div class="post-metadata">

**Author:** ![tonyswumac](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/tonyswumac/32/22401_2.png) [@tonyswumac](https://community.grafana.com/u/tonyswumac)\
**Post date:** [September 17, 2025, 11:40pm UTC](https://community.grafana.com/t/alloy-daemonset-log-position-file-state-persistence/157545/8 "2025-09-17T23:40:31Z")

</div>

Is the mount RW?

---

<div class="post-metadata">

**Author:** ![sumith](https://avatars.discourse-cdn.com/v4/letter/s/e274bd/32.png) [@sumith](https://community.grafana.com/u/sumith)\
**Post date:** [September 17, 2025, 11:45pm UTC](https://community.grafana.com/t/alloy-daemonset-log-position-file-state-persistence/157545/9 "2025-09-17T23:45:26Z")

</div>

i tried this way.

> extra:  
> - name: data-vol  
> mountPath: /var/lib/alloy/data  
> readOnly: false # ensure writable

---

<div class="post-metadata">

**Author:** ![tonyswumac](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/tonyswumac/32/22401_2.png) [@tonyswumac](https://community.grafana.com/u/tonyswumac)\
**Post date:** [September 18, 2025, 12:03am UTC](https://community.grafana.com/t/alloy-daemonset-log-position-file-state-persistence/157545/10 "2025-09-18T00:03:25Z")

</div>

Since you mentioned daemon set, I assume you are using kubernetes? Can you post your entire helm chart or whatever your deployment uses?

---

<div class="post-metadata">

**Author:** ![sumith](https://avatars.discourse-cdn.com/v4/letter/s/e274bd/32.png) [@sumith](https://community.grafana.com/u/sumith)\
**Post date:** [September 18, 2025, 12:11am UTC](https://community.grafana.com/t/alloy-daemonset-log-position-file-state-persistence/157545/11 "2025-09-18T00:11:13Z")

</div>

```auto
apiVersion: collectors.grafana.com/v1alpha1
kind: Alloy
metadata:
  name: alloy-logs
  namespace: test
spec:
  controller:
    type: daemonset
    # enableStatefulSetAutoDeletePVC: true
    tolerations:
      - effect: NoSchedule
        operator: Exists
    volumes:
      extra:
        - name: pod-logs
          hostPath:
            path: /var/log/pods
            type: DirectoryOrCreate
        - name: container-logs
          hostPath:
            path: /var/log/containers
            type: DirectoryOrCreate            
        - name: data-vol
	  hostPath:
            path: /var/alloy
            type: DirectoryOrCreate
        - name: alloy-client-cert
          secret:
            secretName: alloy-client-cert
    volumeMounts:
      extra:
        - name: pod-logs
          mountPath: /var/log/pods
          readOnly: true
        - name: container-logs
          mountPath: /var/log/containers
          readOnly: true
        - name: alloy-client-cert
          mountPath: /etc/alloy/certs
          readOnly: true
  serviceAccount:
    create: false
    name: alloy-sa
    automountServiceAccountToken: true
  rbac:
    create: true
  alloy:
    mounts:
      varlog: true
      extra:
      - name: data-vol
        mountPath: /var/alloy
        readOnly: false
    configMap:
      create: false
      name: alloy-config
      key: alloy-logs
    storagePath: /var/alloy
    securityContext:
        runAsUser: 0
        runAsGroup: 0
        fsGroup: 0

```

---

<div class="post-metadata">

**Author:** ![tonyswumac](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/tonyswumac/32/22401_2.png) [@tonyswumac](https://community.grafana.com/u/tonyswumac)\
**Post date:** [September 18, 2025, 6:39pm UTC](https://community.grafana.com/t/alloy-daemonset-log-position-file-state-persistence/157545/12 "2025-09-18T18:39:37Z")

</div>

> [@sumith](#):
>
> ```auto
> volumes:
> extra:
> 
> ```

Are you sure that’s correct?

---

<div class="post-metadata">

**Author:** ![sumith](https://avatars.discourse-cdn.com/v4/letter/s/e274bd/32.png) [@sumith](https://community.grafana.com/u/sumith)\
**Post date:** [September 18, 2025, 8:27pm UTC](https://community.grafana.com/t/alloy-daemonset-log-position-file-state-persistence/157545/13 "2025-09-18T20:27:37Z")

</div>

> [@sumith](#):
>
> ```auto
> volumeMounts:
> extra:
> 
> ```

 ![image](https://us1.discourse-cdn.com/grafana/original/3X/6/2/629b75a5c636f6a8094547757cfb7df6cd34b0e7.png)

but volumeMounts is not avilable.

reference : [https://raw.githubusercontent.com/grafana/alloy/main/operations/helm/charts/alloy/values.yaml](https://raw.githubusercontent.com/grafana/alloy/main/operations/helm/charts/alloy/values.yaml)

---

<div class="post-metadata">

**Author:** ![tonyswumac](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/tonyswumac/32/22401_2.png) [@tonyswumac](https://community.grafana.com/u/tonyswumac)\
**Post date:** [September 19, 2025, 11:03pm UTC](https://community.grafana.com/t/alloy-daemonset-log-position-file-state-persistence/157545/14 "2025-09-19T23:03:53Z")

</div>

I don’t use that helm chart myself, maybe your configuration is right. I would double check your container, check your pod description, and figure out why the mount is not writable.

---

<div class="post-metadata">

**Author:** ![sumith](https://avatars.discourse-cdn.com/v4/letter/s/e274bd/32.png) [@sumith](https://community.grafana.com/u/sumith)\
**Post date:** [September 19, 2025, 11:06pm UTC](https://community.grafana.com/t/alloy-daemonset-log-position-file-state-persistence/157545/15 "2025-09-19T23:06:36Z")

</div>

yeh i will check that

---

<div class="post-metadata">

**Author:** ![dlbarduzzi](https://avatars.discourse-cdn.com/v4/letter/d/a88e57/32.png) [@dlbarduzzi](https://community.grafana.com/u/dlbarduzzi)\
**Post date:** [February 2, 2026, 10:59pm UTC](https://community.grafana.com/t/alloy-daemonset-log-position-file-state-persistence/157545/16 "2026-02-02T22:59:38Z")

</div>

Just in case other folks look into this. The `extra` field above is only part of the `values.yaml` file in you helm chart. That shouldn’t be added to the daemonset template yaml file.
