Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aorith/varnishlog-parser
A varnishlog parser library and web user interface
https://github.com/aorith/varnishlog-parser
golang templ varnish varnishlog
Last synced: 13 days ago
JSON representation
A varnishlog parser library and web user interface
- Host: GitHub
- URL: https://github.com/aorith/varnishlog-parser
- Owner: aorith
- License: mit
- Created: 2024-11-01T10:34:57.000Z (15 days ago)
- Default Branch: master
- Last Pushed: 2024-11-01T10:38:29.000Z (15 days ago)
- Last Synced: 2024-11-01T11:25:58.940Z (15 days ago)
- Topics: golang, templ, varnish, varnishlog
- Language: Go
- Homepage:
- Size: 0 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# varnishlog-parser
> A varnishlog parser library and web user interface
An instance is available here: https://varnishlog.iou.re/
## Run the web-ui locally
Either clone this repository and run:
```sh
go run . server
```Or with docker/podman:
```sh
docker run --rm -p 8080:8080 ghcr.io/aorith/varnishlog-parser:latest
```## Use as a library
Here's an example:
```go
package mainimport (
"fmt"
"strings""github.com/aorith/varnishlog-parser/vsl"
)const incompleteExample = `* << Session >> 1
- Begin sess 0 HTTP/1
- SessOpen 192.168.50.1 55650 http 192.168.50.10 80 1728889150.256391 26
- Link req 2 rxreq
- SessClose REM_CLOSE 0.123
- End
** << Request >> 2
-- Begin req 1 rxreq
-- Timestamp Start: 1728889150.256523 0.021300 0.021300
-- VCL_use boot
-- End
`func main() {
p := vsl.NewTransactionParser(strings.NewReader(incompleteExample))
txsSet, err := p.Parse()
if err != nil {
fmt.Println(err)
return
}// Iterate all the transactions VSL log records
for _, tx := range txsSet.Transactions() {
fmt.Printf("%v\n", tx.TXID())
for _, r := range tx.LogRecords() {
switch record := r.(type) {
case vsl.TimestampRecord:
fmt.Printf(" [%s] %s: %s\n", record.Tag(), record.EventLabel(), record.SinceLast().String())
case vsl.SessCloseRecord:
fmt.Printf(" [%s] %s: %s\n", record.Tag(), record.Reason(), record.Duration().String())
default:
fmt.Printf(" [%s] %s\n", record.Tag(), record.Value())
}
}
}
}
```Output:
```
1_sess
[Begin] sess 0 HTTP/1
[SessOpen] 192.168.50.1 55650 http 192.168.50.10 80 1728889150.256391 26
[Link] req 2 rxreq
[SessClose] REM_CLOSE: 123ms
[End]
2_req
[Begin] req 1 rxreq
[Timestamp] Start: 21.3ms
[VCL_use] boot
[End]
```