Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Varnish k8s plugin support #1282

Merged
merged 7 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions varnish-mixin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,27 @@ scrape_configs:
__path__: /var/log/varnish/varnishncsa*.log*
```

#### Varnish Cache logs in Kubernetes

To collect logs from Varnish Cache when running in a kubernetes environment, `varnishncsa` and Alloy sidecars must be added to the deployment configuration. Additional ConfigMaps for custom Alloy configurations must be created. The deployment will need an additional volume for logs and all sidecars will need `volumeMounts` for that volume.

> For `varnishncsa` to run, the log file needs to already exist. This can be accomplished with an `initContainer`.

The mixin is expecting `filename` to match with the following regex patterns for frontend and/or backend logs:
```regex
/var/log/varnish/varnishncsa-frontend.*.log|/opt/varnish/log/varnishncsa-frontend.*.log
/var/log/varnish/varnishncsa-backend.*.log|/opt/varnish/log/varnishncsa-backend.*.log
```
It is necessary for the log location in your deployment to match these patterns.

The `varnishncsa` sidecars need to run as a user with the appropriate permissions to write to the log file(s). If there are
frontend and backend logs, two separate sidecars will need to be defined, customized to start `varnishncsa` with the appropriate flags.

Refer to [this documentation](https://grafana.com/docs/grafana-cloud/monitor-infrastructure/integrations/integration-reference/integration-varnish-cache/#set-up-varnish-cache-logging) for more information on the commands and flags needed for frontend/backend logging. Additionally, for further details on varnishncsa refer to [this documentation](https://varnish-cache.org/docs/trunk/reference/varnishncsa.html).

A single Alloy sidecar with a custom configuration can be defined to collect all the logs, assuming the appropriate volumes are
mounted and that the log files are all located in the same location.

## Alerts overview

| Alert | Summary |
Expand Down
3 changes: 3 additions & 0 deletions varnish-mixin/config.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@
alertsCriticalSessionsDropped: 0,
alertsCriticalBackendUnhealthy: 0,
enableLokiLogs: true,
enableMultiCluster: false,
multiclusterSelector: 'job=~"$job"',
varnishSelector: if self.enableMultiCluster then 'job=~"$job", cluster=~"$cluster"' else 'job=~"$job"',
},
}
Loading
Loading