a50c1446c3042a7d8b09cc287b7185729613884e
				
			
			
		
	logmower-shipper
Watches log directory for logs, and ships them to mongo.
- Running: go run .
- Building: go build .
Files
- pkg/globalsdefines globals. This is used for Prometheus namespace, and for forwarding static global CLI configuration with less clutter.
- main.goserves- /metricsand runs- watcher.go.
- pkg/watchermain routine; initializes (including- mongo.go) and watches for new log files.- pkg/mongoprovides statically safe and central tools to interact with the database.
- pkg/utilprovides additional utility functions.
 
- pkg/filehandles file lifecycle; watches files and tails them, streaming lines to- pkg/lines.
- pkg/linesprocesses lines and streams them to- pkg/sender.
- pkg/senderbatches lines and ships them to mongo.
┌──────────────────────────────────────────────────────────────┬─────────┐
│ List directory      New files created                        ) watcher (
│ │                    │                                       └─────────┤
│ └► Simulate initial ─┴─► File watcher ──► Parse filename (k8s)         │
│     create events                              ┌─◄───┘                 │
│                                 Ignore files   │─◄─┐Namespace filters  │
│ ┌─ Launch file collector ◄──── based on filter ┘─◄─┘Pod prefix filters │
└─▼──────────────────────────────────────────────────────────────────────┘
  │                                         ┌──────┐
  │ Retry any downstream error with backoff ) file ( ┌──────────┬────────┐
┌─▼─────────────────────────────────────────┴──────┤ │  Submit  ) sender (
│┌┴─► mongo: get offset     create channels  ┌─────► │ to mongo └────────┤
││      │                 + chan processors  │     │ ├────▲────┬─────────┘
│└──┐───┘      ┌─────────────┘           └───┼─────► ) batcher (
└───▼──────────▼──────────────────────────┐  │     │ ├────▲────┤
┌───┴────┐ ┌───────┬────────────────────┐ │  └─────► │  queue  │
) tailer ( ) lines (      combine       │ └────────┘ └────▲────┘
└───▼────┘ ├───────┘   partial lines    │                 │
    │      │            ▲       │       │   {possible processing plugins}
    └──────► parse k8s  │       ▼       │                 ▲
           │ line metadata ─────┴───────►─────────────────┘
           │                            │
           └────────────────────────────┘
Skaffold
export NS=gitdbd-5cym5
kubectl apply -f k8s/dev/mongodb.yaml -n "$NS"
kubectl apply -f k8s/dev/prom.yaml -n "$NS"
skaffold dev --namespace "$NS"
hwatch kubectl get pods --namespace "$NS"
Description
				
					Languages
				
				
								
								
									Go
								
								98.3%
							
						
							
								
								
									Dockerfile
								
								1.7%