Skip to content

Commit

Permalink
Varnish k8s plugin support (#1282)
Browse files Browse the repository at this point in the history
* add selectors to config and updated dashboard

* updated overview dashboard filter labels

* update allValues to .+ for job and instance labels

* removed log_type because filename is present in a k8s context due to the nature of log collection

* fix typo

* added section to readme around varnish logs in k8s

* added instructions around log file names
  • Loading branch information
algchoo authored Jul 23, 2024
1 parent 1d877bb commit 33fd33f
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 71 deletions.
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

0 comments on commit 33fd33f

Please sign in to comment.