pico
created pr with
35.1
added 35.2
1: 77aaa29 ! 1: 8d56535 reactor(metric-drain): use caddy json format
-: ------- > 2: a336041 wip
-: ------- > 3: 7ae45b3 chore: wrap
-: ------- > 4: bfa5c4f done
added 35.3
1: 8d56535 < -: ------- reactor(metric-drain): use caddy json format
-: ------- > 1: c7eeb12 reactor(metric-drain): use caddy access logs
2: a336041 < -: ------- wip
3: 7ae45b3 < -: ------- chore: wrap
4: bfa5c4f < -: ------- done
added 35.4
1: c7eeb12 ! 1: 4e0839a reactor(metric-drain): use caddy access logs
changed status to
accepted
cmds
checkout latest patchset:
ssh pr.pico.sh print 35 | git am -3checkout any patchset in a patch request:
ssh pr.pico.sh print 35.[rev] | git am -3add changes to patch request:
git format-patch main --stdout | ssh pr.pico.sh pr add 35set PR to open (enables RSS notifications):
ssh pr.pico.sh pr open 35set PR to draft (stops RSS notifications):
ssh pr.pico.sh pr draft 35
+29
-0
auth/api.go
#
| ... | ... | @@ -662,6 +663,30 @@ func deserializeCaddyAccessLog(dbpool db.DB, access *CaddyAccessLog) (*db.Analyt | |
| 662 | 663 | }, nil | |
| 663 | 664 | } | |
| 664 | 665 | ||
| 666 | + | func containerDrainSub(ctx context.Context, logger *slog.Logger) { | |
| 667 | + | drain := pipe.NewReconnectReadWriteCloser( | |
| 668 | + | ctx, | |
| 669 | + | logger, | |
| 670 | + | shared.NewPicoPipeClient(), | |
| 671 | + | "container logs", | |
| 672 | + | "sub container-drain -k", | |
| 673 | + | 100, | |
| 674 | + | -1, | |
| 675 | + | ) | |
| 676 | + | ||
| 677 | + | fmt.Println("WTFFFFFF") | |
| 678 | + | scanner := bufio.NewScanner(drain) | |
| 679 | + | for scanner.Scan() { | |
| 680 | + | line := scanner.Text() | |
| 681 | + | fmt.Println("HMMMM", line) | |
| 682 | + | if strings.Contains(line, "http.log.access") { | |
| 683 | + | clean := strings.TrimSpace(line) | |
| 684 | + | fmt.Println("LINE", clean) | |
| 685 | + | // TODO: send to metric drain | |
| 686 | + | } | |
| 687 | + | } | |
| 688 | + | } | |
| 689 | + | ||
| 665 | 690 | func metricDrainSub(ctx context.Context, dbpool db.DB, logger *slog.Logger, secret string) { | |
| 666 | 691 | drain := metrics.ReconnectReadMetrics( | |
| 667 | 692 | ctx, |
| ... | ... | @@ -699,6 +724,7 @@ func metricDrainSub(ctx context.Context, dbpool db.DB, logger *slog.Logger, secr | |
| 699 | 724 | logger.Error("could not insert visit record", "err", err) | |
| 700 | 725 | } | |
| 701 | 726 | } | |
| 727 | + | fmt.Println("DROPINNGGGGGGG") | |
| 702 | 728 | } | |
| 703 | 729 | ||
| 704 | 730 | func authMux(apiConfig *shared.ApiConfig) *http.ServeMux { |
| ... | ... | @@ -769,6 +795,9 @@ func StartApiServer() { | |
| 769 | 795 | ||
| 770 | 796 | // gather metrics in the auth service | |
| 771 | 797 | go metricDrainSub(ctx, db, logger, cfg.Secret) | |
| 798 | + | // convert container logs to access logs | |
| 799 | + | // go containerDrainSub(ctx, logger) | |
| 800 | + | ||
| 772 | 801 | defer ctx.Done() | |
| 773 | 802 | ||
| 774 | 803 | apiConfig := &shared.ApiConfig{ |
+0
-0
test.txt
#
Binaries are not rendered as diffs.